diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-09-10 09:21:09 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-09-10 09:21:09 +0000 |
| commit | 03eaff36d0b59166bb889ab2ae026d397f1a1e3c (patch) | |
| tree | c08f7b7ae8e5f32f8cffc689272deca5ce9be0d7 | |
| parent | feb968189cd74903e653e9e0a657bebcf22e3991 (diff) | |
- added lost chpass-wrapper.py
git-svn-id: https://svn.roundcube.net/trunk@3956 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | plugins/password/drivers/chpass-wrapper.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/password/drivers/chpass-wrapper.py b/plugins/password/drivers/chpass-wrapper.py new file mode 100644 index 000000000..61bba849e --- /dev/null +++ b/plugins/password/drivers/chpass-wrapper.py @@ -0,0 +1,32 @@ +#!/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) |
