summaryrefslogtreecommitdiffstats
path: root/subsurface-core
diff options
context:
space:
mode:
Diffstat (limited to 'subsurface-core')
-rw-r--r--subsurface-core/dive.h3
-rw-r--r--subsurface-core/linux.c5
-rw-r--r--subsurface-core/macos.c5
-rw-r--r--subsurface-core/parse-xml.c2
-rw-r--r--subsurface-core/subsurfacestartup.c4
-rw-r--r--subsurface-core/windows.c6
6 files changed, 23 insertions, 2 deletions
diff --git a/subsurface-core/dive.h b/subsurface-core/dive.h
index d52ef5272..204d34819 100644
--- a/subsurface-core/dive.h
+++ b/subsurface-core/dive.h
@@ -495,7 +495,7 @@ extern const struct units SI_units, IMPERIAL_units;
extern struct units xml_parsing_units;
extern struct units *get_units(void);
-extern int run_survey, verbose, quit;
+extern int run_survey, verbose, quit, force_root;
struct dive_table {
int nr, allocated, preexisting;
@@ -697,6 +697,7 @@ extern struct zip *subsurface_zip_open_readonly(const char *path, int flags, int
extern int subsurface_zip_close(struct zip *zip);
extern void subsurface_console_init(bool dedicated);
extern void subsurface_console_exit(void);
+extern bool subsurface_user_is_root(void);
extern void shift_times(const timestamp_t amount);
extern timestamp_t get_times();
diff --git a/subsurface-core/linux.c b/subsurface-core/linux.c
index a77f378ca..b81f6bf53 100644
--- a/subsurface-core/linux.c
+++ b/subsurface-core/linux.c
@@ -225,3 +225,8 @@ void subsurface_console_exit(void)
{
/* NOP */
}
+
+bool subsurface_user_is_root()
+{
+ return (geteuid() == 0);
+}
diff --git a/subsurface-core/macos.c b/subsurface-core/macos.c
index 70cfc08d4..500412cd8 100644
--- a/subsurface-core/macos.c
+++ b/subsurface-core/macos.c
@@ -211,3 +211,8 @@ void subsurface_console_exit(void)
{
/* NOP */
}
+
+bool subsurface_user_is_root()
+{
+ return (geteuid() == 0);
+}
diff --git a/subsurface-core/parse-xml.c b/subsurface-core/parse-xml.c
index 17bd69d53..e8782251e 100644
--- a/subsurface-core/parse-xml.c
+++ b/subsurface-core/parse-xml.c
@@ -23,7 +23,7 @@
#include "device.h"
#include "membuffer.h"
-int verbose, quit;
+int verbose, quit, force_root;
int metric = 1;
int last_xml_version = -1;
int diveid = -1;
diff --git a/subsurface-core/subsurfacestartup.c b/subsurface-core/subsurfacestartup.c
index 71b2efb5e..6e0dede1c 100644
--- a/subsurface-core/subsurfacestartup.c
+++ b/subsurface-core/subsurfacestartup.c
@@ -217,6 +217,10 @@ void parse_argument(const char *arg)
run_survey = true;
return;
}
+ if (strcmp(arg, "--allow_run_as_root") == 0) {
+ ++force_root;
+ return;
+ }
if (strcmp(arg, "--win32console") == 0)
return;
/* fallthrough */
diff --git a/subsurface-core/windows.c b/subsurface-core/windows.c
index a2386fd83..58d3beaad 100644
--- a/subsurface-core/windows.c
+++ b/subsurface-core/windows.c
@@ -446,3 +446,9 @@ void subsurface_console_exit(void)
FreeConsole();
#endif
}
+
+bool subsurface_user_is_root()
+{
+ /* FIXME: Detect admin rights */
+ return (false);
+}