Mercurial > hg > rc1
view plugins/password/helpers/chpass-wrapper.py @ 0:1e000243b222
vanilla 1.3.3 distro, I hope
author | Charlie Root |
---|---|
date | Thu, 04 Jan 2018 15:50:29 -0500 |
parents | |
children |
line wrap: on
line source
#!/usr/bin/env python import sys import pwd import subprocess BLACKLIST = ( # add blacklisted users here #'user1', ) try: username, password = sys.stdin.readline().split(':', 1) except ValueError, e: sys.exit('Malformed input') try: user = pwd.getpwnam(username) except KeyError, e: sys.exit('No such user: %s' % username) if user.pw_uid < 1000: sys.exit('Changing the password for user id < 1000 is forbidden') if username in BLACKLIST: sys.exit('Changing password for user %s is forbidden (user blacklisted)' % username) handle = subprocess.Popen('/usr/sbin/chpasswd', stdin = subprocess.PIPE) handle.communicate('%s:%s' % (username, password)) sys.exit(handle.returncode)