summaryrefslogtreecommitdiffstats
path: root/source3/lib
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2013-11-06 18:00:31 +0100
committerStefan Metzmacher <metze@samba.org>2014-04-17 14:56:06 +0200
commit15feb84273c65dbe2d3f502861c7f520c46dc9d3 (patch)
treee1e071f02406e2165dbe2d158105f1dd69de5313 /source3/lib
parent486fa4a134a79e0a25091efc749ccc131dc18f69 (diff)
downloadsamba-15feb84273c65dbe2d3f502861c7f520c46dc9d3.tar.gz
samba-15feb84273c65dbe2d3f502861c7f520c46dc9d3.tar.xz
samba-15feb84273c65dbe2d3f502861c7f520c46dc9d3.zip
s3-lib: Add root_mode() which can deal with uid_wrapper.
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/lib')
-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 ac999e360d1..9ccd04e24ad 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?
****************************************************************************/