Unix security is a problem of legendary notoriety. Just about every aspect of a Unix system has some security issue associated with it, and it’s usually the system administrator’s job to worry about this issue.
This is not a textbook on Unix system security. Be aware that this section merely touches the tip of the iceberg and that there are myriad other aspects to Unix system security besides how the shell is set up. See the end of the chapter for one book that we recommend.
We first present a list of “tips” for writing shell scripts that
have a better chance of avoiding security problems.
Next we cover the restricted shell, which attempts to
put a straitjacket around the user’s environment.
Then we present the idea of a “trojan horse,” and why such
things should be avoided. Finally we discuss
the Korn shell’s
privileged mode, which is
used with shell scripts that run as if the user were
Here are some tips for writing more secure shell scripts, courtesy of Professor Eugene (Gene) Spafford, the director of Purdue University’s Center for Education and Research in Information Assurance and Security:
This issue was described in Chapter 3. This opens the door wide for “trojan horses,” described in the next section.
Make sure that every directory in
writable only by its owner and by no one else. The same applies to all
the programs in the bin directories. ...