summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/debug.c4
-rw-r--r--source3/lib/messages.c9
-rw-r--r--source3/lib/util_sec.c24
3 files changed, 10 insertions, 27 deletions
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);
@@ -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
****************************************************************************/