OSX login

hchris

Registered
hello,
I work with MacOSX on apples with many different users. the problem is, that I need a loginuser, who is allowed to create new users without administrator rights. With applescript I have no controll on systempreferences, so I failed. I think, I need some help to solve the problem with a shell script.
If someone has a solution to my problem, please explain it step-by-step to me. I am a unix new born baby.
please help!
 

kilowatt

mach-o mach-o man
You might be able to configure webmin (a web browser interface to most admin tasks) to add users, and then just disable enything else that webmin does. And the password to webmin can be different from the root password. It is completely seperate from user passwords.

Also, if you know the script to add users (its avaliable from darwin.org, I think), you could modify the files it effects and the programs it uses (w/chmod) and create a user in that group.

I'm a bit new to this stuff, too, so maybe someone else will chime in here with better instructions.
 

jcpowers21

Registered
#!/bin/tcsh
echo "Login account?"
read inp
if [ "$inp" = "x" ]
then
echo "login needed"
exit
fi
log=$inp
echo "Full name?"
read inp
if [ "x$inp" = "x" ]
then
echo "Full name needed"
exit
fi
nam=$inp
echo "UID ? (next free after 100, this script does no checking)"
read inp
if [ "x$inp" = "x" ]
then
echo "UID needed"
exit
fi
uid=$inp
echo "Shell ? (/bin/tcsh by default)"
read inp
if [ "x$inp" = "x" ]
then
inp="/bin/tcsh"
fi
shl=$inp
echo "Home Dir? (/Users/$log by default)"
read inp
if [ "x$inp" = "x" ]
then
inp="/Users/$log/"
fi
hom=$inp

echo "Can this user su to root (no by default, otherwise type yes) ?"
read inp
if [ "x$inp" = "xyes" ]
then
gid=0
else
gid=20
fi

niutil -create / /users/$log
niutil -createprop / /users/$log shell $shl
niutil -createprop / /users/$log passwd ""
niutil -createprop / /users/$log realname $nam
niutil -createprop / /users/$log uid $uid
niutil -createprop / /users/$log gid $gid
niutil -createprop / /users/$log _shadow_passwd
niutil -appendprop / /groups/staff users $log
if [ "$gid" = "0" ]
then
niutil =appendprop / /groups/wheel users $log
fi
mkdir $hom
niutil -createprop / /users/$log home $hom
passwd $log
chown $log $hom
chgrp staff $hom
niutil -read / /users/$log
exit

That will make a new user as long as you run it as root or using sudo.
 
Top