summaryrefslogtreecommitdiffstats
path: root/sysif.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-01-23 10:06:53 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-01-23 10:06:53 -0800
commite080b5acbbe235d3ac32ccaf19826a8fd67e2eaf (patch)
treeb6abd783f6a63dabefc4f6c4174b0c10089c05df /sysif.h
parent7d250092d842e502bf5a571cefad999838997313 (diff)
downloadtxr-e080b5acbbe235d3ac32ccaf19826a8fd67e2eaf.tar.gz
txr-e080b5acbbe235d3ac32ccaf19826a8fd67e2eaf.tar.bz2
txr-e080b5acbbe235d3ac32ccaf19826a8fd67e2eaf.zip
Support setuid operation.
* sysif.c (orig_euid, real_uid, repress_called, is_setuid): New static variables. (repress_privilege, drop_privilage, simulate_setuid): New functions. (RC_MAGIC): New preprocessor symbol. * sysif.c (repress_privilege, drop_privilage, simulate_setuid): Declared. * txr.c (txr_main): Call repress_privilege to check and remember whether we are in setuid mode, and temporarily drop the effective uid to the real one. (txr_main): Permanently drop privileges in all cases except script execution. In script execution cases, go through simulate_setuid to either set or preserve the effective user ID, or else drop privs. * txr.1: Documented setuid operation in new section.
Diffstat (limited to 'sysif.h')
-rw-r--r--sysif.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/sysif.h b/sysif.h
index 051f1d6d..22431823 100644
--- a/sysif.h
+++ b/sysif.h
@@ -49,4 +49,13 @@ off_t off_t_num(val num);
val num_off_t(off_t offnum);
val stdio_ftell(FILE *);
val stdio_fseek(FILE *, val, int whence);
+#if HAVE_GETEUID
+void repress_privilege(void);
+void drop_privilege(void);
+void simulate_setuid(val open_script);
+#else
+INLINE repress_privilege(void) { }
+INLINE drop_privilege(void) { }
+INLINE void simulate_setuid(val open_script) { }
+#endif
void sysif_init(void);