PAM is a more recent system for
providing modular authentication, which uses an even more flexible
mechanism than the TIS FWTK authentication server. The basic
principle is much the same; programs that need to do authentication
are modified to use the PAM system, after which you can completely
control what kind of authentication they use through PAM, without
making further changes to the individual programs. PAM differs from
the authentication server in that it is a local service; PAM operates
by dynamically loading authentication modules into applications that
have been configured to use them. Authentication modules execute with
the same privileges as the application that loaded them.
A program can ask PAM to authenticate a user or to change a password.
The password change feature saves users from having to learn a new
password change mechanism for each new authentication mechanism.
An administrator can configure PAM to do extra work in addition to
authenticating the user. For instance, it can grant or deny access
based on criteria other than whether or not the user authenticated
properly. This allows you to control what time of day people can use
a service, or how many simultaneous users there can be, or whether or
not they're accessible from the machine's console. PAM
can also set up the environment that the service will execute in, by
setting environment variables or by running programs (for instance,
it can use chroot to limit the parts of the
filesystem that the service has access to).
Authentication modules can be stacked up, either to allow for
fail-over (if you can't authenticate one way, try another) or
to enforce complicated rules (allow George to log in only at the
console and only between 3:00 and 5:00 in the morning, but allow
everybody else to log in from the local network with reusable
passwords, or from the Internet with a one-time password). It's
also easy to add new authentication modules, but you should use new
modules with caution. When you trust a piece of code to authenticate
users, you are trusting it with the security of your system;
that's not something you should do lightly.
PAM is an extraordinarily flexible system, and as a natural
consequence, it can be hard to configure. Configuration errors will
often result in an unusable computer, but it's also easy to
accidentally produce a configuration that has unexpected
insecurities. The module-stacking features, for instance, provide any
number of ways to accidentally allow access that you intended to
deny. Effectively, they give you an entire programming language with
obscure and varying syntax, and an error as simple as using the
keyword "required" instead of "requisite" can
have unfortunate consequences.
Like any powerful tool, PAM should be used with caution:
In most installations, PAM will allow you to use one single
configuration file that contains the configuration for all services,
or a directory with a separate file for each service. You should use
a separate file for each service; it will help keep configuration
errors for one service from propagating to others.
No matter how you set up the configuration files, you will need to
specify a default behavior for the service called
"other", which will be used if there is no specific
information for a PAM-enabled service. You should set this up so that
it denies access and logs this fact; this way, if you accidentally
install a PAM-enabled service without installing configuration
information for it, you will not grant access to it. Of course, if
you accidentally remove the configuration for an existing service,
you will turn off all access to it. This is unpleasant, but not as
unpleasant as a compromised machine.