From bc45c82904e268327bfbf72cd3f35699ae6e7397 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 5 Apr 2007 23:56:10 +0000 Subject: 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. (This used to be commit f3ffb3f98472b69b476b702dfe5c0575b32da018) --- source3/lib/debug.c | 4 ++-- source3/lib/messages.c | 9 +++++++-- source3/lib/util_sec.c | 24 +----------------------- 3 files changed, 10 insertions(+), 27 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index a2e8574bbd..138c52cdce 100644 --- a/source3/lib/debug.c +++ b/source3/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/source3/lib/messages.c b/source3/lib/messages.c index 336a9349e6..316854f643 100644 --- a/source3/lib/messages.c +++ b/source3/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/source3/lib/util_sec.c b/source3/lib/util_sec.c index 3d997ee76a..1899208697 100644 --- a/source3/lib/util_sec.c +++ b/source3/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); @@ -291,28 +291,6 @@ void restore_re_uid(void) restore_re_uid_fromroot(); } -/**************************************************************************** - 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 -- cgit