summaryrefslogtreecommitdiffstats
path: root/source3/lib/util_sec.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/util_sec.c')
-rw-r--r--source3/lib/util_sec.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/source3/lib/util_sec.c b/source3/lib/util_sec.c
index ac999e360d..9ccd04e24a 100644
--- a/source3/lib/util_sec.c
+++ b/source3/lib/util_sec.c
@@ -82,6 +82,26 @@ gid_t sec_initial_gid(void)
return initial_gid;
}
+/**
+ * @brief Check if we are running in root mode.
+ *
+ * @return If we samba root privileges it returns true, false otehrwise.
+ */
+bool root_mode(void)
+{
+ uid_t euid;
+
+ euid = geteuid();
+
+#ifndef AUTOCONF_TEST
+ if (uid_wrapper_enabled()) {
+ return (euid == initial_uid || euid == (uid_t)0);
+ }
+#endif
+
+ return (initial_uid == euid);
+}
+
/****************************************************************************
are we running in non-root mode?
****************************************************************************/