2000-05-01
|
FOCUS on Sun and Linux: Pluggable Authentication Modules, Part I
For the better part of its existence, Unix, and Unix machines used
an authentication mechanism based on the DES
algorithm, modified to be utilized as a one way hash. Crypt(3), as it is
commonly referred to, has proven satisfactory for most applications.
In recent years, with the growing popularity of the Internet, many have
felt a need to switch to alternate, more secure mechanisms for
authentication. Several popular schemes for authentication exist; among
them Kerberos, SecureID, x9.9, and S/Key/OPIE. With these new schemes
came the need to replace many system supplied utilities and daemons, often
at a loss of functionality, and possibly with a high degree of trauma
(replacing /bin/login being a fairly traumatic experience for many).
Pluggable Authentication Modules, or PAM, represent a standard whereby
different authentication mechanisms can be utilized without requiring the
replacing of system binaries. Instead, a shared object can be created, and
its utilization be dynamically selected based on the contents of an
easily configured file. In this manner, different sites can select the
authentication mechanism most appropriate for them, without sacrificing
functionality or needing to depend on unsupported software.
Solaris and Linux both support PAM, albeit with slight differences. With the
popularity of these two operating systems, many PAM modules are freely
available. This makes it easy for the integration of new authentication
mechanisms into your environment, should you be interested in trying something
other than crypt(3).
PAM is a fairly simple standard from administration perspective. Installing
a PAM module requires the selection of a module, its placement somewhere on
the file system, and the modification of the /etc/pam.conf file on Solaris,
or the /etc/pam.d/<appname> in Linux. Any further requirements are specific to
the module.
So that we can go step by step, we need to select a module to utilize.
In the next part of this article, we'll write a simple PAM module, but for
the time being, we're going to take advantage of a feature of PAM. PAM allows
for what they call "stacking" of modules. This means it is possible to define
multiple modules for a application requiring authentication. For the purpose of demonstration, a simple module
is used, which only stubs each of the required functions, printing out any arguments passed,
and being as unintrusive as possible (this will all be more easily understood
when we write our own module in the next article). The module is available at
pam_stub.tar.gz. It works for both Solaris and Linux,
and does not require the use of the Linux PAM toolkit under Solaris. Simply
untar it, type 'make' in the directory created (pam_stub/) and build for the
appropriate operating system.
As configuring PAM is somewhat different between Solaris and Linux, we'll
discuss the basic file format, and then look at specifically configuring
our test module on Solaris and Linux.
The PAM configuration file has a number of consistent fields between implementations.
They each specify the type of action to use a given pam module on, on a given
program. These types are as follows:
The disposition of the module and its use is specified via a control flag.
This flag is one of the following:
The configuration file also list the path to a module, and any options
passed to that module. Under Solaris, default modules exist in
/usr/lib/security/, and under Linux, in /lib/security/.
Configuration information for PAM is stored in the /etc/pam.conf file. The
file is broken in to five fields
The service name field specifies the service utilizing PAM; this is coded in
to the program using PAM. Auth, control flag, module path, and options are
all as discussed above.
To add the stub module to login, prior to the execution of other modules, for
the auth module type, you would add:
where the path field is the actual path to the pam_stub.so file. I placed the
pam_stub module as the first module in the /etc/pam.conf file. I elected to make it
optional, since it has no bearing on the authentication being successful or not.
The same module can be used for the account, session and password module types.
Configuration information for PAM is stored in the /etc/pam.d/ directory.
Each application using PAM will have a separate file in the /etc/pam.d
directory, which is coded in to the application using PAM. For login, for
instance, the file is named login. The file contains four fields.
Each of these fields was discussed above.
To add the stub module to login, you would edit the /etc/pam.d/login file, and
add the following entry:
where the path field is the actual path to the pam_stub.so file. I placed the
pam_stub module as the first in the /etc/pam.d/login. I elected to make it
optional, since it has no bearing on the authentication being successful or not.
The same module can be used for the account, session and password module types.
To test the module, simply use the login program. If its configured for each of
the module types, you can see each internal function being called. Try configuring
the passwd and su programs for the stub module to see what happens under the hood
when each is called.
Toy examples may make for an easy way to explain configuration, but this case is not
useful for much besides debugging. There are dozens of modules out there to fill a
variety of roles. In the next part to this article, we'll go step by step, and write
a module that will run under both Linux and Solaris, to perform x9.9 based authentication.
For those of you more interested in actually using PAM, what follows is a list of some of
the more interesting and popular PAM modules out there. The first list is of modules
included with Solaris, followed by a list of modules included with RedHat Linux. Finally,
a list of other interesting modules is presented.
In the next article on PAM, we'll discuss writing a PAM module, and write an example module to
cleanly, generically, and correctly implement x9.9 based authentication in PAM. This is the
type of authentication used with CryptoCards, SNK cards, and other DES based token cards.
We'll implement it with an eye on portability and security.
To read Pluggable Authentication Modules, Part II, click here. |
|
|
