I am working on software and configuration for a device that uses Linux.

I have been asked to provide an administrative interface that requires no knowledge of Linux to use and that has restricted capabilities.

I believe that the best way to handle this will be to use a console login (either through ssh or with a serial port) to present a menu of options. Let's say I have a program called admin_menu that handles all my desired tasks.

So, I should be able to create a line in /etc/password like so:

admin:x:230:235:Administrative Interface:/home/admin:/local/sbin/admin_menu

Are there any special considerations I need to be aware of when I create my admin_menu program? Direct answers are good, but pointers to good docs are even better.

General areas that I want more information on are:

  • What environment variables can I expect to be set? Which ones will I need to set myself?
  • Are there any special considerations when spawning child processes?
  • What happens upon termination of my menu process?
  • Do I use STDIO for interaction with the console or some other interface?
  • Good questions. I hoping for those answers, too. I've built a terminal server using minicom-wrappers as login shell. just works. – PEra Nov 18 '09 at 21:10

A script can function as a login shell. You will need to add /local/sbin/admin_menu to /etc/shells. Otherwise, ssh logins(and possibly others) won't work with no explanation of why(if I remember correctly).

There are some environment variables that will be transferred from the client, such as window size. Some will be set on logging into the system. PAM can set some of these, but I don't have an example.

Upon termination of the menu process, the client is logged out, I believe. I base this off of observing what happens when /bin/bash terminates.

If I were you, I'd use stdin/stdout for your input and output source.


You can put any program in place of /bin/sh in a /etc/profile entry, whether shell script or executable binary. The thing you want to watch for is escapes to a shell - if you've tried to capture them in a program, you probably don't want them to get access to a command line.

For example, if the program happened to be something like vi, the user could use ":!/bin/sh" and get to a command line. Similarly, when using a script, often times user input is used as data in a command line - this can be abused to get a command line as well. If the menu interface were to prompt you for a file to print which might get used in a command "lpr $input", what happens if the filename typed in is "myfile.txt; /bin/sh"?

There are several other ways of breaking out to a command line, you need to be very careful when setting up a captured account that takes user input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.