Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F6068118
chpass-wrapper.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
722 B
Referenced Files
None
Subscribers
None
chpass-wrapper.py
View Options
#!/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
:
sys
.
exit
(
'Malformed input'
)
try
:
user
=
pwd
.
getpwnam
(
username
)
except
KeyError
:
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
)
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Fri, May 22, 5:29 AM (11 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
766552
Default Alt Text
chpass-wrapper.py (722 B)
Attached To
Mode
R3 roundcubemail
Attached
Detach File
Event Timeline
Log In to Comment