Validating A User/Password Pair + Getting Groups On Unix

Tim Daneliuk tundra at tundraware.com
Mon Feb 28 20:17:58 EST 2005


OK, I've Googled for this and cannot seem to quite find what I need.
So, I turn to the Gentle Geniuses here for help.  Here is what I
need to do from within a script:

Given a username and a password (plain text):

   1) Validate that the password is correct for that user *without actually logging in*.

   2) If the password is valid, return a list of all the groups the user belongs to.
      Otherwise, return some error string.

I seem to not be able to crack how to do 1.

I can do 2) by brute force - just parse through /etc/group - but this
misses the primary group a given user may belong to - and that requires
also scanning /etc/passwd and then looking up the corresponding primary
group in /etc/group.  Is there a better way?

TIA,
-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/




More information about the Python-list mailing list