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>
Tue, 21 Oct 2014 00:07:10 +0000 (01:07 +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 111a1b0..024744c 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 b2f6927..7fbe157 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -274,6 +274,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 *****/