diff options
author | Jeremy Allison <jra@samba.org> | 2007-04-05 23:56:10 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:11 -0500 |
commit | f3ffb3f98472b69b476b702dfe5c0575b32da018 (patch) | |
tree | dd0cdaa1e98f214560dea104dd5b62cbbe6e4d51 /source/lib | |
parent | e5c9fc937d40046030c0d3bcfced505410a14caf (diff) | |
download | samba-f3ffb3f98472b69b476b702dfe5c0575b32da018.tar.gz samba-f3ffb3f98472b69b476b702dfe5c0575b32da018.tar.xz samba-f3ffb3f98472b69b476b702dfe5c0575b32da018.zip |
r22096: become_root_uid_only() is unneeded - it's only used in
messages.c. Refactor to use become_root() instead and
make it local to messages.c
Jeremy.
Diffstat (limited to 'source/lib')
-rw-r--r-- | source/lib/debug.c | 4 | ||||
-rw-r--r-- | source/lib/messages.c | 9 | ||||
-rw-r--r-- | source/lib/util_sec.c | 24 |
3 files changed, 10 insertions, 27 deletions
diff --git a/source/lib/debug.c b/source/lib/debug.c index a2e8574bbdd..138c52cdcea 100644 --- a/source/lib/debug.c +++ b/source/lib/debug.c @@ -695,7 +695,7 @@ void check_log_size( void ) if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) { - become_root_uid_only(); + become_root(); (void)reopen_logs(); if( dbf && get_file_size( debugf ) > maxlog ) { @@ -710,7 +710,7 @@ void check_log_size( void ) } } - unbecome_root_uid_only(); + unbecome_root(); } /* diff --git a/source/lib/messages.c b/source/lib/messages.c index 336a9349e63..316854f6436 100644 --- a/source/lib/messages.c +++ b/source/lib/messages.c @@ -183,13 +183,18 @@ static NTSTATUS message_notify(struct process_id procid) SMB_ASSERT(pid > 0); if (euid != 0) { - become_root_uid_only(); + /* If we're not root become so to send the message. */ + save_re_uid(); + set_effective_uid(0); } ret = kill(pid, SIGUSR1); if (euid != 0) { - unbecome_root_uid_only(); + /* Go back to who we were. */ + int saved_errno = errno; + restore_re_uid_fromroot(); + errno = saved_errno; } if (ret == -1) { diff --git a/source/lib/util_sec.c b/source/lib/util_sec.c index 3d997ee76ac..18992086975 100644 --- a/source/lib/util_sec.c +++ b/source/lib/util_sec.c @@ -265,7 +265,7 @@ void save_re_uid(void) and restore them! ****************************************************************************/ -static void restore_re_uid_fromroot(void) +void restore_re_uid_fromroot(void) { #if USE_SETRESUID setresuid(saved_ruid, saved_euid, -1); @@ -292,28 +292,6 @@ void restore_re_uid(void) } /**************************************************************************** - Lightweight become root - no group change. -****************************************************************************/ - -void become_root_uid_only(void) -{ - save_re_uid(); - set_effective_uid(0); -} - -/**************************************************************************** - Lightweight unbecome root - no group change. Expects we are root already, - saves errno across call boundary. -****************************************************************************/ - -void unbecome_root_uid_only(void) -{ - int saved_errno = errno; - restore_re_uid_fromroot(); - errno = saved_errno; -} - -/**************************************************************************** save the real and effective gid for later restoration. Used by the getgroups code ****************************************************************************/ |