why doesn't this work...?

tefol tefol at This.Is.Not.An.Address
Sat Oct 13 05:08:29 EDT 2001


  
I have written a script to automate the creation of users on a Red Hat 7.1 
server.   I did a lot of testing on my dev server, and it worked great.

Adds the user to the /etc/passwd file, adds an encrypted passwd to the 
/etc/shadow file.  User can log in fine.

I move the script over to my live server,  and it doesn't work.  It looks like 
it works.  The user I add appears in both the above files.  But it can't log 
in.

This is causing me no end of grief,  as you might imagine.  I can't think of 
what the difference in the two machines might be.

FWIW,  the script is posted below.  I would love to get comments on 
why/what/how the problem is, and also gleefully encourage comments on neatness 
and form of my code.  I am still quite newbie.

Thanks!

Tefol

-+------------------------+-


import sys, crypt, os, string, random, re
from whrandom import choice

usage = """usage:makeuser username password"""

def GenRandStr(length=8, chars=string.letters + string.digits):
        return ''.join([choice(chars) for i in range(length)])

salt = '$1$' + GenRandStr()

try:
    username = sys.argv[1]
    password = sys.argv[2]
except IndexError:
    print usage
else:
    crypted = crypt.crypt(password, salt)
    command = '/usr/sbin/useradd ' + username + ' -s /etc/ftponly -m -p \'' + 
crypted + '\''
    os.system(command)



More information about the Python-list mailing list