def login(func):
"""Install Python function as a LoginHook."""
def func_wrapper(hook='login'):
path = '/var/root/Library/mh_%shook.py' % hook
writesource(func, path)
# only root should read and execute
os.chown(path, 0, 0)
os.chmod(path, stat.S_IXUSR | stat.S_IRUSR)
if hook == 'login':
hooks.login(path)
else:
hooks.logout(path)
return path
return func_wrapper
评论列表
文章目录