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.

bash has two features that help solve this problem: the restricted shell, which is intentionally “brain damaged,” and privileged mode, which is used with shell scripts that run as if the user were root.

Restricted Shell

The restricted shell is designed to put the user into an environment where his or her ability to move around and write files is severely limited. It’s usually used for “guest” accounts. [137]You can make a user’s login shell restricted by putting rbash in the user’s /etc/passwd entry. [138]

The specific constraints imposed by the restricted shell disallow the user from doing the following:

  • Changing working directories: cd is inoperative. If you try to use it, you will get the error message bash: cd: restricted.

  • Redirecting output to a file: the redirectors >, >|, <>, and >> are not allowed.

  • Assigning a new value to the environment variables SHELL or PATH.

  • Specifying any pathnames with slashes (/) in them. The shell will treat files outside of the current directory as “not found.”

  • Using the exec built-in.

  • Specifying a filename containing a / as an argument to the . built-in command.

  • Importing function definitions from the shell environment at startup.

  • Adding or deleting built-in commands with the -f and -d options to the enable built-in command. ...

Get Learning the bash Shell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.