diff options
author | Rob Austein <sra@hactrn.net> | 2013-02-01 05:08:08 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2013-02-01 05:08:08 +0000 |
commit | 2f9828622d5ba395a0666dea34fb6cf48ab0b406 (patch) | |
tree | f9f376fee8afe9f2973ff7fb9ed6ff6a0764da8e | |
parent | 1750b16a9ab7b208de25a1deafbd610dfd38e7f5 (diff) |
chown() lock file to rcynic user when creating it as root.
svn path=/branches/tk377/; revision=4999
-rw-r--r-- | rcynic/rcynic-cron.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/rcynic/rcynic-cron.py b/rcynic/rcynic-cron.py index fff921b0..ba96ec6b 100644 --- a/rcynic/rcynic-cron.py +++ b/rcynic/rcynic-cron.py @@ -26,6 +26,7 @@ import subprocess import sys import fcntl import os +import pwd # Stuff we need from autoconf: # @@ -76,6 +77,9 @@ def run(*cmd, **kwargs): try: lock = os.open(os.path.join(AC_RCYNIC_DIR, "data/lock"), os.O_RDONLY | os.O_CREAT | os.O_NONBLOCK, 0666) fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) + if we_are_root: + pw = pwd.getpwnam(AC_RCYNIC_USER) + os.fchown(lock, pw.pw_uid, pw.pw_gid) except (IOError, OSError), e: sys.exit("Error %r opening lock %r" % (e.strerror, os.path.join(AC_RCYNIC_DIR, "data/lock"))) |