summaryrefslogtreecommitdiffstats
path: root/subsurface-desktop-main.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2016-03-25 09:21:45 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-26 20:08:08 -0700
commite216f91ebc5686040b028267baac0d9e649cc47a (patch)
treebda0bef779d46818e23a56f7a8cfcbead954680d /subsurface-desktop-main.cpp
parentd99c9312195c2d5b867fa85e7b5aae8530fbf9b9 (diff)
downloadsubsurface-e216f91ebc5686040b028267baac0d9e649cc47a.tar.gz
Prevent unintentionally running as root
Some users try to run Subsurface as root for example to get around permission problems with dive computer devices. This is a bad idea since config files get touched as root and then cannot be read as normal user anymore. This patch allows running as root only with verbose option on. We can assume if somebody manages to start subsurface as root this happens from the command line. For some reason, I couldn't get translation working at this stage. Windows version is a stub. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-desktop-main.cpp')
-rw-r--r--subsurface-desktop-main.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/subsurface-desktop-main.cpp b/subsurface-desktop-main.cpp
index 2b7bf89f6..b93b642bd 100644
--- a/subsurface-desktop-main.cpp
+++ b/subsurface-desktop-main.cpp
@@ -59,6 +59,11 @@ int main(int argc, char **argv)
files.push_back(a);
}
}
+ if (subsurface_user_is_root() && !force_root) {
+ printf("You are running Subsurface as root. This is not recommended.\n");
+ printf("If you insist to do so, run with option --allow_run_as_root.\n");
+ exit(0);
+ }
#if !LIBGIT2_VER_MAJOR && LIBGIT2_VER_MINOR < 22
git_threads_init();
#else