chiark / gitweb /
secnet: provide will_droppriv
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 30 Sep 2014 17:07:10 +0000 (18:07 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 2 Oct 2014 15:40:18 +0000 (16:40 +0100)
polypath is going to want to know whether to do privsep.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
secnet.c
secnet.h

index a29a42925b02371cabbf3066c49a3a7fc7676c27..3cf7eeb1b9d2c7cc6c26e04d59abe34895a5b960 100644 (file)
--- a/secnet.c
+++ b/secnet.c
@@ -383,6 +383,12 @@ static void run(void)
     free(fds);
 }
 
+bool_t will_droppriv(void)
+{
+    assert(current_phase >= PHASE_SETUP);
+    return !!uid;
+}
+
 /* Surrender privileges, if necessary */
 static void droppriv(void)
 {
index 2e73238a9a075ee5af0546d3f9729008986e814d..2d5ce002941668be1f3ef4fdd48a8386483a0e50 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -271,6 +271,11 @@ extern void enter_phase(uint32_t new_phase);
 extern bool_t require_root_privileges;
 extern cstring_t require_root_privileges_explanation;
 
+/* Some modules may want to know whether secnet is going to drop
+   privilege, so that they know whether to do privsep.  Call only
+   in phases SETUP and later. */
+bool_t will_droppriv(void);
+
 /***** END of program lifetime support *****/
 
 /***** MODULE support *****/