| OS X - Development and Darwin Discussion and questions about development for Mac OS X. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
|
Guest
Posts: n/a
|
I posted this in the OS area, but I think this is aslo a forum this should be in.
I am attempting to write a script that (when run only by root) will be able to create a user with a password. Now this dosent seem hard, except that the creation has to be done with out interaction from the user. Hence the command 'passwd ' is out. So I found that in Code:
/private/usr/db/shadow/hash/gnereateduid password. In the netInfo database if passwod_authentication is set to ;Basic; then a htpasswd -nb passwordhere stored in the passwd field works. And as I have heard this is the standard for pre 10.3 versions of X. But 10.3 now allows the ;ShadowHash; option for authentication. And I am wondering how to generate that ShadowHash'd password. Any help would be awesome, even if it's "I dont know at all" would be cool. Thanks -- Dave Walker |
| QUOTE Thanks | |
![]() Member Since: Mar 09, 2004
Location: Miami FL
Posts: 2,860
![]() Mac Specs: G4 1Ghz OS X 10.4.7
|
|
| QUOTE Thanks | |
|
Guest
Posts: n/a
|
The purpose to the password, is that each admin account has a different unknown password, so in the event someone found it, or hacked it.. it would be for that machine, and only for 1 day. |
||||
| QUOTE Thanks | |||||
![]() Member Since: Mar 09, 2004
Location: Miami FL
Posts: 2,860
![]() Mac Specs: G4 1Ghz OS X 10.4.7
|
|
| QUOTE Thanks | |
![]() Member Since: Mar 09, 2004
Location: Miami FL
Posts: 2,860
![]() Mac Specs: G4 1Ghz OS X 10.4.7
|
|
| QUOTE Thanks | |
![]() Member Since: Mar 09, 2004
Location: Miami FL
Posts: 2,860
![]() Mac Specs: G4 1Ghz OS X 10.4.7
|
This can be done - from an article I found:
#!/bin/sh if [[ -z $1 ]]; then # robg note: Please enter the next two lines as one without # any spaces between the "/" and the "R" /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/ Resources/CGSession -suspend else USERID=`id -u $1`; if [[ -z $USERID ]]; then exit -1; fi; # robg note: Please enter the next two lines as one without # any spaces between the "/" and the "R" /System/Library/CoreServices/Menu\ Extras/User.menu/Contents/ Resources/CGSession -switchToUserID $USERID fi; hope this helps! |
| QUOTE Thanks | |
|
Guest
Posts: n/a
|
no i am not looking for fast user switching, via the command line. I am just looking to set a users password via the command line, with out anyone interacting with that password.
I looked through the passwd source, and see that there are calls to ni_* but the ni_* functions do not seem to be available (Apple code???) I did this to see if i could take out the new password: and re-enter new password promompts, and just add another command line argument that passwd would take... ex: passwd user password and it would set that users password with password, and not prompt for anything. |
| QUOTE Thanks | |
![]() Member Since: Mar 09, 2004
Location: Miami FL
Posts: 2,860
![]() Mac Specs: G4 1Ghz OS X 10.4.7
|
|
| QUOTE Thanks | |
|
Guest
Posts: n/a
|
use sudo chpass -a
You asked about the 10.3 hash... how it's generated... The first 64 chars are NTLM MD4 hash, used for File sharing (samba) The remaining 40 chars are SHA1 hash. Not that it's related to your question, since if I understand your question correctly, chpass should do it for you. Last edited by dr_springfield; 04-30-2004 at 03:29 AM. |
| QUOTE Thanks | |
![]() Member Since: Mar 09, 2004
Location: Miami FL
Posts: 2,860
![]() Mac Specs: G4 1Ghz OS X 10.4.7
|
|
| QUOTE Thanks | |
|
Guest
Posts: n/a
|
Hello,
this script creates a password on the commandline, however you have to use 'expect' to create the password via: passwd -i netinfo username You can either run directly an expect script or wrap it with zsh... I pass the parameters via the command line ------ start script #!/bin/zsh username=$1 password=$2 expect<<EOF spawn "passwd -i netinfo" $username expect "ssword:" send $password\r expect "ssword:" send $password\r expect eof EOF ------ end script Hope that helps... I lost about 2 days to find this out.... Best M. |
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
All times are GMT -4. The time now is 04:28 AM.
Powered by vBulletin