|
From: <di...@us...> - 2007-03-08 03:44:21
|
Revision: 443
http://safekeep.svn.sourceforge.net/safekeep/?rev=443&view=rev
Author: dimi
Date: 2007-03-07 19:44:20 -0800 (Wed, 07 Mar 2007)
Log Message:
-----------
Teach safekeep to switch to a given user in server mode.
Controlled via the 'user' property in /etc/safekeep/safekeep.conf
Modified Paths:
--------------
safekeep/trunk/doc/safekeep.conf.txt
safekeep/trunk/safekeep
safekeep/trunk/sample.conf
Modified: safekeep/trunk/doc/safekeep.conf.txt
===================================================================
--- safekeep/trunk/doc/safekeep.conf.txt 2007-03-07 22:40:01 UTC (rev 442)
+++ safekeep/trunk/doc/safekeep.conf.txt 2007-03-08 03:44:20 UTC (rev 443)
@@ -34,6 +34,11 @@
If not specified, `safekeep` will just use
`/usr/sbin/sendmail` to deliver the mail.
+user::
+ The Unix user under which the server will run.
+ If not specified, `safekeep` will just run under the
+ current user.
+
FILES
-----
/etc/safekeep/safekeep.conf
Modified: safekeep/trunk/safekeep
===================================================================
--- safekeep/trunk/safekeep 2007-03-07 22:40:01 UTC (rev 442)
+++ safekeep/trunk/safekeep 2007-03-08 03:44:20 UTC (rev 443)
@@ -799,6 +799,7 @@
usage(2)
mode = None
+ user = None
email = []
smtp = None
cfgfile = None
@@ -874,6 +875,8 @@
props = parse_prop_file(cfgfile)
else:
props = {}
+ if 'user' in props:
+ user = props['user']
if 'email.smtp.server' in props:
smtp = props['email.smtp.server']
if 'email.to' in props:
@@ -895,6 +898,13 @@
ok = False
if not ok: sys.exit(2)
+ if user and mode is not 'keys':
+ import pwd
+ (name, passwd, uid, gid, gecos, dir, shell) = pwd.getpwnam(user)
+ os.setregid(gid, gid)
+ os.setreuid(uid, uid)
+ os.env['HOME'] = dir
+
try:
global is_client, verbosity_level
if mode is 'server':
Modified: safekeep/trunk/sample.conf
===================================================================
--- safekeep/trunk/sample.conf 2007-03-07 22:40:01 UTC (rev 442)
+++ safekeep/trunk/sample.conf 2007-03-08 03:44:20 UTC (rev 443)
@@ -4,6 +4,9 @@
# - keys are separated from values by '='
# - leading and trailing blanks are ignored
+# the user under which the server will run
+# user = safekeep
+
# a comma separated list of emails to receive the logs
# ema...@co...,ro...@co...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|