Execute a binary/script after login

There is a group of users pooled in a single login class. For this class I want to execute a binary immediately after login. Some years ago I did the same via login.conf on FreeBSD 7 or 8. But now I forgot how I did this and man login.conf gave me no hint. Could anyone advise?
 
You could simply start it through their ~/.profile. That would be the easiest way. But that would require editing the user's profile each time you add a new user.
 
SirDice said:
You could simply start it through their ~/.profile. That would be the easiest way. But that would require editing the user's profile each time you add a new user.
Not to mention that capable users can turn it off, which may or may not be desirable.

@OP: Have you tried searching the login.conf man pages for older releases?
 
Maybe with shell? You'll write a simple script which starts the binary and after run the shell. It's a very-very ugly workaround but maybe it was your way.
 
Depending on the binary you could set the user's shell to that binary. If they exit the application they'd log off. You would have to add it to /etc/shells though. You can do something similar with the shell variable in login.conf. That will overrule the user's shell that's set in passwd. Perhaps that's what you used before?

From login.conf(5):
Code:
  shell	      prog			 Session shell to execute
						 rather	than the shell speci-
						 fied in the passwd file.  The
						 SHELL environment variable
						 will contain the shell	speci-
						 fied in the password file.
 
SirDice said:
Depending on the binary you could set the user's shell to that binary. If they exit the application they'd log off.
Or, combining the two above: set the shell directive in login.conf to a simple script that first runs the binary and then execs the shell in /etc/(master.)passwd:
Code:
#!/bin/sh

# Run the binary.
/path/to/binary option1 option2 etc.

# When done, replace the script with the shell.
exec ${SHELL}
This way, if I'm not mistaken, users cannot easily circumvent having the binary run first.

Don't forget to run cap_mkdb after having modified /etc/login.conf ;)
 
Back
Top