Personal tools
Document Actions


Up to table of contents

This FAQ applies to: Any version.

How do I check unix password?
import pwd, crypt

def login(user, password):
"Check if user would be able to login using password"
pw1 = pwd.getpwnam(user)[1]
pw2 = crypt.crypt(password, pw1[:2])
return pw1 == pw2
except KeyError:
return 0 # no such user

user = raw_input("username:")
password = raw_input("password:")

if login(user, password):
print "welcome", user
print "login failed"
by yongzhao — last modified 2006-11-04 14:17 Molecular Graphics Laboratory, TSRI

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: