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 111a1b0886f0c1e11a0d8a367a6aec75136689f9..024744c55e5c0ecdf84d0fc67381664ded27f67c 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 b2f6927af03ff29fd4d0c35482f84e245db25031..7fbe157cfd1e231d4c0e00c16aa2ffc130c9f58b 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 *****/