Hi
I am trying to write a login script for network based clients (OSX) that looks up local accounts eg admin, root, etc and exits the script so that it doesn't apply to them. Then for everyone else I make folders eg movies, music, etc that are placed in local harddrive rather than the default place on the server harddrive.
At the moment this script creates the desired effect for the root user no matter who logs in. If I remove the first couple of lines that try to sort out the admin users it works for everyone who logs in. However I want it to work for everyone except root and local users.
ie
#!/bin/sh
#
CURRUSER=`whoami`
ADMINGROUP=`groups | grep admin`
if [ `expr "$ADMINGROUP" != ""` = 1 ]
then
exit 1
fi
I will add the chown part but it still needs something to create the $CURRUSER directories rather than roots . This last sentence makes sense if you read the input at the link above.
Add logic such as a prompt to actually set the value of CURRUSER to the ID of the person who will own the directories. Since you are running as root, then you could issue the command su $CURRUSER without the need to supply a password.
Would I do that just before I make the directories in the script and I am not quite sure how.
I guess I don't understand how your trying to use su.
Could you give an example in my script how you might do it.
Thanks
#I had thought for some reason that the script was being #executed by root and not the everyday user
Are you saying it works for root but not others? Are you getting any permission errors, unable to create directory errors?
How are you executing the script? Does root own the script and do you have the SUID permission bit set? This would allow anyone who executes the script to run the script as if they were root (security issues with SUID's). What permissions are set for this script?
I use a login window manager from (its free)http://www.bombich.com/mactips/loginhooks.html
and this uses unix to login hook (LoginHook (POSIX path)) and it allows you to store a script on the hardrive or server and executes it at login. It runs the script with root permissions ( I assume) otherwise I don't think it would be able to create directories and sub directories. Theres good info on this page (link above) eg
Create a shell script to be run upon login. The name of the script is not important, as long as it is the same as what you will indicate in step 4. Note that the name of the user logging in is sent as an argument ($1) to this script. You can also download this basic script and copy it to /Library/Management (you may have to create this folder). Be sure to check out my Scripts Library for several other scripts that perform various tasks.
All my client machines are Mac osx 10.35 with an Admin and Root local users. Everyone else who logs in are not local users but are located on an Xserve LDAP binded database.
The reason I am trying to create certain directories locally for users as they login rather than have them on the server is because we run a wireless network that can't cope with huge movie and music files.