Skip to content

Commit

Permalink
messaging: Call messaging_dgm_send under become_root only if necessary
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph Boehme <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
slowfranklin authored and jrasamba committed Sep 12, 2016
1 parent e0de912 commit d2b0694
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions source3/lib/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,14 @@ int messaging_send_iov_from(struct messaging_context *msg_ctx,
iov2[0] = (struct iovec){ .iov_base = hdr, .iov_len = sizeof(hdr) };
memcpy(&iov2[1], iov, iovlen * sizeof(*iov));

become_root();
ret = messaging_dgm_send(dst.pid, iov2, iovlen+1, fds, num_fds);
unbecome_root();

if (ret == EACCES) {
become_root();
ret = messaging_dgm_send(dst.pid, iov2, iovlen+1,
fds, num_fds);
unbecome_root();
}

return ret;
}
Expand Down
9 changes: 7 additions & 2 deletions source4/lib/messaging/messaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,14 @@ NTSTATUS imessaging_send(struct imessaging_context *msg, struct server_id server
pid = getpid();
}

priv = root_privileges();
ret = messaging_dgm_send(pid, iov, num_iov, NULL, 0);
TALLOC_FREE(priv);

if (ret == EACCES) {
priv = root_privileges();
ret = messaging_dgm_send(pid, iov, num_iov, NULL, 0);
TALLOC_FREE(priv);
}

if (ret != 0) {
return map_nt_error_from_unix_common(ret);
}
Expand Down

0 comments on commit d2b0694

Please sign in to comment.