[Zope] useradd command in Zope

Tino Wildenhain tino at wildenhain.de
Mon Nov 7 04:30:30 EST 2005


ajit mote schrieb:
> this is what i tried ....
> 
> #External script addUser.py (stored in instance/Extensions folder)
> import crypt
> import os
> def addUser(userName,password):
>         password=crypt.crypt(password,"5Ag5zoM9")
>         command="/usr/sbin/adduser -p "+password+" "+ userName
>         return os.system(command)
> 

Heaven! Is this external method available via web? If so
be prepared for massive attack :-)
That aside you may consider md5 instead of crypt to make
it not too easy to crack (otoh, its not really important
as your script really allows for any command)

> ///////////////
>  attaching the application ....
>      exported from zope2.8.1 ,python-2.3.4-11,mysql-3.23.58-13 and   
> Linux  2.6.9-1.667 ....
> ////////////////////////
> now i hope that , problem defination is very clear and open......
> ///////////////////

Well no, at least not your "it does not work" problem you told us.

Still missing: the call to the script as "User which runs zope"
which might be zope or nobody or something, depending on your
configuration and the way you start zope.

Add the following lines to your external method and you can
run it as script too:

if __name__=='__main__':
    import sys
    try:
         user=sys.argv[1]
         pass=sys.argv[2]
    except IndexError:
         sys.stderr.write("Please start me with %s <username> 
<password>\n" % sys.argv[0])
         sys.exit(20)

     addUser(user,pass)



and try it like this:

su zope (or whoever your zope runs)
./yourmethod.py someuser somepass

You will see it fail (apart from the fact you need
the #!/path/to/python.bin and set the execution bit
with chmod a+x before you try)

Because you did not use sudo as adviced.

Please try to copy the way mails are cited from other
mails in this list. Dont put all your text on the
top of a full quote. Thank you.

Regards
Tino


More information about the Zope mailing list