I want to have a user in Debian 7.x with the following restrictions:
- When the user logs in, a command-line program will automatically start in the user shell session. Then the program will parse the user input for ever and will execute commands until the user types a specific exit command.
- When the program terminates, the user must be automatically logged out.
- CTRL+C must either do nothing or abort the program and log out the user.
- To sum up, the user must not be allowed to interact with the system in any way other than this automatically started program. This should hold true, regardless of the way the session is started, whether SSH or other means.
As a starting point, I have added this lines at the end of the new user's
.bashrc (user's shell is bash):
exec /path/to/myprogram logout
Generally, it works. However, if the start of session is slow, a (not particularly fast) user could hit CTRL-C and be happily prompted on the terminal before
myprogram starts. How can I avoid this?
Assigning a fake shell such as
/bin/false to the user will not work, as it would not allow to start the program either.