Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SlickShoes

macrumors 6502a
Original poster
Jan 24, 2011
640
0
Hi,

I want to run a command in terminal when a user logs on to the machine.

Here it is:

dseditgroup -o edit -u admin -P password -t user -a "$USER" _developer

It adds the currently logged on user to the developer group. I need this to run at logon as I run labs in a university i can never tell who will log on to which computer so cant make this a permanent change manually.

If anyone can throw me a bone here that would be awesome.
 
In a normal Unix environment, you'd place this in /etc/profile or /etc/bashrc.
 
While you could do this with either a loginhook (reasonable) or a launchdaemon[1], I think you are missing a much better solution: add your LDAP users group (I am presuming LDAP/AD) nested in your _developer group. That way anyone who logs in from that group is automatically seen as being part of that group. That way you are not constantly messing with your dslocal domain.


[1] If you really have to do this as a launchd item, then you probably need to do this with a launchdaemon with its LimitLoadToSessionType key set to Aqua. This will run it as root, but run when things go into an Aqua session. This will work with console logins, but not ssh logins. But you are going to have to go through some gyrations to get the user name (look at the owner of the loginwindow process), and things get complicated if you enable fast user switching (my advice is to disable this for a lab).
 
While you could do this with either a loginhook (reasonable) or a launchdaemon[1], I think you are missing a much better solution: add your LDAP users group (I am presuming LDAP/AD) nested in your _developer group. That way anyone who logs in from that group is automatically seen as being part of that group. That way you are not constantly messing with your dslocal domain.


[1] If you really have to do this as a launchd item, then you probably need to do this with a launchdaemon with its LimitLoadToSessionType key set to Aqua. This will run it as root, but run when things go into an Aqua session. This will work with console logins, but not ssh logins. But you are going to have to go through some gyrations to get the user name (look at the owner of the loginwindow process), and things get complicated if you enable fast user switching (my advice is to disable this for a lab).

Your suggestion above, i take it that means that anyone logging in via Active Directory will be put in the developer group? That sounds like it is definately the way to go, i will try and look into doing that first before getting into those other solutions.

Also you are correct about fast user switching i always have that turned off for my labs!

Thanks for the help guys!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.