O'Reilly logo

Learning the Korn Shell, 2nd Edition by Bill Rosenblatt, Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

System Security Features

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.

Note

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 root.

Tips for Secure Shell Scripts

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:[128]

Don’t put dot in PATH

This issue was described in Chapter 3. This opens the door wide for “trojan horses,” described in the next section.

Protect bin directories

Make sure that every directory in $PATH is writable only by its owner and by no one else. The same applies to all the programs in the bin directories. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required