from .pidfile import PidFileError, InvalidPidFileError, PidFileInUseError, PidFile
-__version__ = '0.6.2'
+__version__ = '0.6.3'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def _run(self):
- if os.geteuid():
+ my_uid = os.geteuid()
+ if my_uid:
if self.simulate:
LOG.warn("You must be root to execute this script.")
- LOG.warn("But hey - this is simulation mode ...")
+ group_ids = {}
+ for group in grp.getgrall():
+ for g_username in group.gr_mem:
+ g_uid = pwd.getpwnam(g_username).pw_uid
+ if g_uid == my_uid:
+ group_ids[group.gr_name] = group.gr_gid
+ if self.verbose > 2:
+ LOG.debug("You are a member of the groups:\n{}".format(group_ids))
+ if self.named_group in group_ids:
+ LOG.warn((
+ "But hey - this is simulation mode, "
+ "and you are a member of group {!r} ...").format(
+ self.named_group))
+ else:
+ LOG.error((
+ "But also in simulation mode you has to be a member "
+ "of group {!r}!").format(self.named_group))
+ self.exit(1)
time.sleep(1)
else:
LOG.error("You must be root to execute this script.")