summaryrefslogtreecommitdiff
path: root/source3/lib/messages.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/messages.c')
-rw-r--r--source3/lib/messages.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 57e4514b58..bae4052964 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -117,7 +117,10 @@ static void ping_message(int msg_type, struct process_id src,
BOOL message_init(void)
{
- if (tdb) return True;
+ sec_init();
+
+ if (tdb)
+ return True;
tdb = tdb_open_log(lock_path("messages.tdb"),
0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
@@ -164,6 +167,10 @@ static TDB_DATA message_key_pid(struct process_id pid)
static BOOL message_notify(struct process_id procid)
{
pid_t pid = procid.pid;
+ int saved_errno;
+ int ret;
+ uid_t euid = geteuid();
+
/*
* Doing kill with a non-positive pid causes messages to be
* sent to places we don't want.
@@ -171,15 +178,28 @@ static BOOL message_notify(struct process_id procid)
SMB_ASSERT(pid > 0);
- if (kill(pid, SIGUSR1) == -1) {
- if (errno == ESRCH) {
+ if (euid != 0) {
+ save_re_uid();
+ set_effective_uid(0);
+ }
+
+ ret = kill(pid, SIGUSR1);
+ saved_errno = errno;
+
+ if (euid != 0) {
+ restore_re_uid();
+ }
+
+ if (ret == -1) {
+ if (saved_errno == ESRCH) {
DEBUG(2,("pid %d doesn't exist - deleting messages record\n", (int)pid));
tdb_delete(tdb, message_key_pid(procid));
} else {
- DEBUG(2,("message to process %d failed - %s\n", (int)pid, strerror(errno)));
+ DEBUG(2,("message to process %d failed - %s\n", (int)pid, strerror(saved_errno)));
}
return False;
}
+
return True;
}