Allow cron to target remote user (#4270)

This commit is contained in:
BradLook
2016-08-10 14:30:09 -07:00
committed by Matt Clay
parent 03022875c4
commit 766413e79d

View File

@@ -476,7 +476,7 @@ class CronTab(object):
return "%s -l %s" % (pipes.quote(CRONCMD), pipes.quote(self.user))
elif platform.system() == 'HP-UX':
return "%s %s %s" % (CRONCMD , '-l', pipes.quote(self.user))
else:
elif os.getlogin() != self.user:
user = '-u %s' % pipes.quote(self.user)
return "%s %s %s" % (CRONCMD , user, '-l')
@@ -488,7 +488,7 @@ class CronTab(object):
if self.user:
if platform.system() in ['SunOS', 'HP-UX', 'AIX']:
return "chown %s %s ; su '%s' -c '%s %s'" % (pipes.quote(self.user), pipes.quote(path), pipes.quote(self.user), CRONCMD, pipes.quote(path))
else:
elif os.getlogin() != self.user:
user = '-u %s' % pipes.quote(self.user)
return "%s %s %s" % (CRONCMD , user, pipes.quote(path))