diff options
author | Andreas Schneider <asn@samba.org> | 2013-11-06 18:00:31 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2014-04-17 14:56:06 +0200 |
commit | 15feb84273c65dbe2d3f502861c7f520c46dc9d3 (patch) | |
tree | e1e071f02406e2165dbe2d158105f1dd69de5313 | |
parent | 486fa4a134a79e0a25091efc749ccc131dc18f69 (diff) | |
download | samba-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>
-rw-r--r-- | source3/include/proto.h | 1 | ||||
-rw-r--r-- | source3/lib/util_sec.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index a6a68153558..3197b76af7d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -511,6 +511,7 @@ bool token_sid_in_ace(const struct security_token *token, const struct security_ void sec_init(void); uid_t sec_initial_uid(void); gid_t sec_initial_gid(void); +bool root_mode(void); bool non_root_mode(void); void gain_root_privilege(void); void gain_root_group_privilege(void); 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? ****************************************************************************/ |