The configuration files in Fedora are found in /etc/pam.d. These files are named for the service they control, and the format is as follows:
type control module-path module-arguments
The type field is the management group to which the rule corresponds. The control field tells PAM what to do if authentication fails. The final two items deal with the PAM module used and any arguments it needs. Programs that use PAM typically come pack aged with appropriate entries for the /etc/pam.d directory. To achieve greater security, the system administrator can modify the default entries. Misconfiguration can have unpredictable results, so back up the configuration files before you modify them. The defaults provided by Fedora are adequate for home and small office users.
An example of a PAM configuration file with the formatted entries as described previously is shown next. Here are the contents of /etc/pam.d/system-config-users:
#%PAM-1.0
auth include config-util
account include config-util
session include config-util
Amusingly, even the PAM documents state that you do not really need (or want) to know a lot about PAM to use it effectively.
You will likely need only the PAM system administrator's guide. Look under the /usr/share/doc/pam* directory for additional documents in PostScript, text, and HTML formats.
Managing Password Security for Users
Selecting appropriate user passwords is always an exercise in trade-offs. A password such as password (don't laugh, it has been used too often before in the real world) is just too easy to guess by an intruder, as are simple words or number combinations (a street address, for example). A security auditor for one of my former employers used to take the cover sheet from an employee's personnel file (which contained the usual personal information of name, address, birth date, and so on) and then attempt to log on to a terminal with passwords constructed from that information—and often succeeded in logging on.
On the other hand, a password such as 2a56u'"F($84u&#*Hiu44Ik%$([#EJD is sure to present great difficulty to an intruder (or an auditor). However, that password is so difficult to remember that it would be likely that the password owner would write that password down and tape it next to her keyboard. I worked for a business in which the safe combination was written on the ceiling tile over the safe; the manager could not remember it and was told he should not keep it on a piece of paper in his wallet. This is but one of many examples of poor security in the field.
The sysadmin has control, with settings in the /etc/shadow file, over how often the pass word must be changed. The settings can be changed with a text editor, the change command, or a configuration tool such as Fedora's User Manager, as shown in Figure 10.1. Click the Password Info tab under that particular user's Properties to set individual password policies.
Changing Passwords in a Batch
On a large system, there might be times when a large number of users and their pass words need some attention. The super user can change passwords in a batch by using the chpasswd command, which accepts input as a name/password pair per line in the following form:
# chpasswd username:password
You can change passwords en masse by redirecting a list of name and password pairs to the command. An appropriate shell script can be constructed with the information gleaned from this chapter.
However, Fedora also provides the newusers command to add users in a batch from a text file. This command also allows a user to be added to a group, and a new directory can be added for the user, too.
Granting System Administrator Privileges to Regular Users
It may be necessary for regular users to run a command as if they were the root user. They usually do not need these powers, but they might on occasion — for example, to temporarily access certain devices or run a command for testing purposes.
There are two ways to run commands with root privileges: The first is useful if you are the super user and the user; the second if you are not the regular user (as on a large, multiuser network).
Temporarily Changing User Identity with the su Command
What if you are also root, but are logged on as a regular user because you are performing nonadministrative tasks and you need to do something that only the super user can do? The su command is available for this purpose.
A popular misconception is that the su command is short for super user; it just means substitute user. An important but often overlooked distinction is that between su and su -. In the former instance, you become that user but keep your own environmental variables (such as paths). In the latter, you inherit the environment of that user. This is most noticeable when you use su to become the super user, root. Without appending the -, you do not inherit the path variable that includes /bin or /sbin, so you must always enter the full path to those commands when you just su to root.
Because almost all Linux file system security revolves around file permissions, it can be useful to occasionally become a different user with permission to access files belonging to other users or groups or to access special files (such as the communications port /dev/ttyS0 when using a modem, or the sound device /dev/audio when playing a game). You can use the su command to temporarily switch to another user identity, and then switch back.
It is never a good idea to use an Internet Relay Chat (IRC) client as the root user, and you might not want to run it using your regular user account. Just create a special new user just for IRC and su to that user in a terminal widow to launch your IRC client.
The su command spawns a new shell, changing both the UID and GID of the existing user and automatically changes the environmental variables associated with that user. This behavior is known as inheriting the environment. See Chapter 4, "Command-Line Quick Start," for more information on environmental variables.
The syntax for the su command is this:
$ su option username arguments
The man page for su gives more details, but some highlights of the su command are as follows:
-c, --command COMMAND
pass a single COMMAND to the shell with -c
-m, --preserve-environment
do not reset environment variables
-l a full login simulation for the substituted user, the same as specifying the dash alone
You can invoke the su command in different ways that yield diverse results. By using su alone, you can become root, but you keep your regular user environment. You can verify this by using the printenv command before and after the change. Note that the working directory (you can execute pwd as a command line to print the current working directory) has not changed. By executing the following, you become root and inherit root's environ ment: