Merge commit 'c5bab7026b8e0ac44b25ee08507ea360f177d844' into merges
[unleashed.git] / share / man / man3pam / pam_sm.3pam
blob7320f7eced11674506f1205c60e022a362347196
1 '\" te
2 .\" Copyright (C) 2002, Sun Microsystems, Inc.
3 .\" All Rights Reserved
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH PAM_SM 3PAM "Mar 16, 2005"
8 .SH NAME
9 pam_sm \- PAM Service Module APIs
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <security/pam_appl.h>
14 #include <security/pam_modules.h>
15 \fBcc\fR [ \fIflag\fR ...] \fIfile\fR ... \fB-lpam\fR [ \fIlibrary\fR ...]
16 .fi
18 .SH DESCRIPTION
19 .sp
20 .LP
21 \fBPAM\fR gives system administrators the flexibility of choosing any
22 authentication service available on the system to perform authentication. The
23 framework also allows new authentication service modules to be plugged in and
24 made available without modifying the applications.
25 .sp
26 .LP
27 The \fBPAM\fR framework, \fBlibpam\fR, consists of an interface library and
28 multiple authentication  service modules. The \fBPAM\fR interface library is
29 the layer that implements the Application Programming Interface ( \fBAPI\fR ).
30 The authentication service modules are a set of dynamically loadable objects
31 invoked by the \fBPAM\fR \fBAPI\fR to provide a particular type of user
32 authentication.
33 .sp
34 .LP
35 This manual page gives an overview of the \fBPAM\fR \fBAPIs\fR for the service
36 modules, also called the Service Provider Interface (\fBPAM\fR-\fBSPI\fR).
37 .SS "Interface Overview"
38 .sp
39 .LP
40 The \fBPAM\fR service module interface consists of functions which can be
41 grouped into four categories. The names for all the authentication library
42 functions start with \fBpam_sm\fR. The only difference between the
43 \fBpam_*()\fR interfaces and their corresponding \fBpam_sm_*()\fR interfaces is
44 that all the \fBpam_sm_*()\fR interfaces require extra parameters to pass
45 service-specific options to the shared modules. They are otherwise identical.
46 .sp
47 .LP
48 The first category contains functions to authenticate an individual user,
49 \fBpam_sm_authenticate\fR(3PAM), and to set the credentials of the user,
50 \fBpam_sm_setcred\fR(3PAM). These back-end functions implement the
51 functionality of \fBpam_authenticate\fR(3PAM) and \fBpam_setcred\fR(3PAM)
52 respectively.
53 .sp
54 .LP
55 The second category contains the function to do account management:
56 \fBpam_sm_acct_mgmt\fR(3PAM). This includes checking for password aging and
57 access-hour restrictions. This back-end function implements the functionality
58 of \fBpam_acct_mgmt\fR(3PAM).
59 .sp
60 .LP
61 The third category contains the functions \fBpam_sm_open_session\fR(3PAM) and
62 \fBpam_sm_close_session\fR(3PAM) to perform session management after access to
63 the system has been granted. These back-end functions implement the
64 functionality of \fBpam_open_session\fR(3PAM) and
65 \fBpam_close_session\fR(3PAM), respectively.
66 .sp
67 .LP
68 The fourth category consists a function to change authentication tokens
69 \fBpam_sm_chauthtok\fR(3PAM). This back-end function implements the
70 functionality of \fBpam_chauthtok\fR(3PAM).
71 .SS "Stateful Interface"
72 .sp
73 .LP
74 A sequence of calls sharing a common set of state information is referred to as
75 an authentication transaction. An authentication transaction begins with a call
76 to \fBpam_start()\fR. \fBpam_start()\fR allocates space, performs various
77 initialization activities, and assigns an authentication handle to be used for
78 subsequent calls to the library. Note that the service modules do not get
79 called or initialized when \fBpam_start()\fR is called. The modules are loaded
80 and the symbols resolved upon first use of that function.
81 .sp
82 .LP
83 The \fBPAM\fR handle keeps certain information about the transaction that can
84 be accessed through the \fBpam_get_item()\fR \fBAPI\fR. Though the modules can
85 also use \fBpam_set_item()\fR to change any of the item information, it is
86 recommended that nothing be changed except \fBPAM_AUTHTOK\fR and
87 \fBPAM_OLDAUTHTOK\fR.
88 .sp
89 .LP
90 If the modules want to store any module specific state information then they
91 can use the \fBpam_set_data\fR(3PAM) function to store that information with
92 the \fBPAM\fR handle. The data should be stored with a name which is unique
93 across all modules and module types. For example,
94 \fBSUNW_PAM_UNIX_AUTH_userid\fR can be used as a name by the UNIX module to
95 store information about the state of user's authentication. Some modules use
96 this technique to share data across two different module types.
97 .sp
98 .LP
99 Also, during the call to \fBpam_authenticate()\fR, the UNIX module may store
100 the authentication status (success or reason for failure) in the handle, using
101 a unique name such as \fBSUNW_SECURE_RPC_DATA\fR. This information is intended
102 for use by \fBpam_setcred()\fR.
105 During the call to \fBpam_acct_mgmt()\fR, the account modules may store data in
106 the handle to indicate which passwords have aged. This information is intended
107 for use by \fBpam_chauthtok()\fR.
110 The module can also store a cleanup function associated with the data. The
111 \fBPAM\fR framework calls this cleanup function, when the application calls
112 \fBpam_end()\fR to close the transaction.
113 .SS "Interaction with the User"
116 The \fBPAM\fR service modules do not communicate directly with the user;
117 instead they rely on the application to perform all such interactions. The
118 application passes a pointer to the function, \fBconv()\fR, along with any
119 associated application data pointers, through the \fBpam_conv\fR structure when
120 it initiates an authentication transaction (by means of a call to
121 \fBpam_start()\fR. The service module will then use the function, \fBconv()\fR,
122 to prompt the user for data, output error messages, and display text
123 information. Refer to \fBpam_start\fR(3PAM) for more information. The modules
124 are responsible for the localization of all messages to the user.
125 .SS "Conventions"
128 By convention, applications that need to prompt for a user name should call
129 \fBpam_set_item()\fR and set the value of \fBPAM_USER_PROMPT\fR before calling
130 \fBpam_authenticate()\fR. The service module's \fBpam_sm_authenticate()\fR
131 function will then call \fBpam_get_user()\fR to prompt for the user name. Note
132 that certain \fBPAM\fR service modules (such as a smart card module) may
133 override the value of \fBPAM_USER_PROMPT\fR and pass in their own prompt.
136 Though the \fBPAM\fR framework enforces no rules about the module's names,
137 location, options and such, there are certain conventions that all module
138 providers are expected to follow.
141 By convention, the modules should be located in the \fB/usr/lib/security\fR
142 directory. Additional modules may be located in \fB/opt/<pkg>/lib\fR.
143 Architecture specific libraries (for example, sparcv9 or amd64) are located in
144 their respective subdirectories.
147 For every such module, there should be a corresponding manual page in section 5
148 which should describe the \fImodule_type\fR it supports, the functionality of
149 the module, along with the options it supports. The dependencies should be
150 clearly identified to the system administrator. For example, it should be made
151 clear whether this module is a stand-alone module or depends upon the presence
152 of some other module. One should also specify whether this module should come
153 before or after some other module in the stack.
156 By convention, the modules should support the following options:
158 .ne 2
160 \fB\fBdebug\fR\fR
162 .RS 10n
163 Syslog debugging information at \fBLOG_DEBUG\fR level. Be careful as to not log
164 any sensitive information such as passwords.
168 .ne 2
170 \fB\fBnowarn\fR\fR
172 .RS 10n
173 Turn off warning messages such as "password is about to expire."
178 If an unsupported option is passed to the modules, it should syslog the error
179 at \fBLOG_ERR\fR level.
182 The permission bits on the service module should be set such that it is not
183 writable by either "group" or "other." The service module should also be owned
184 by root. The \fBPAM\fR framework will not load the module if the above
185 permission rules are not followed.
186 .SH ERRORS
189 If there are any errors, the modules should log them using \fBsyslog\fR(3C) at
190 the \fBLOG_ERR\fR level.
191 .SH RETURN VALUES
194 The \fBPAM\fR service module functions may return any of the \fBPAM\fR error
195 numbers specified in the specific man pages. It can also return a
196 \fBPAM_IGNORE\fR error number to mean that the \fBPAM\fR framework should
197 ignore this module regardless of whether it is required, optional or
198 sufficient. This error number is normally returned when the module does not
199 contribute to the decision being made by the \fBPAM\fR framework.
200 .SH ATTRIBUTES
203 See \fBattributes\fR(5) for description of the following attributes:
208 box;
209 c | c
210 l | l .
211 ATTRIBUTE TYPE  ATTRIBUTE VALUE
213 Interface Stability      Stable
215 MT-Level        MT-Safe with exceptions
218 .SH SEE ALSO
221 \fBpam\fR(3PAM), \fBpam_authenticate\fR(3PAM), \fBpam_chauthtok\fR(3PAM),
222 \fBpam_get_user\fR(3PAM), \fBpam_open_session\fR(3PAM),
223 \fBpam_setcred\fR(3PAM), \fBpam_set_item\fR(3PAM),
224 \fBpam_sm_authenticate\fR(3PAM), \fBpam_sm_chauthtok\fR(3PAM),
225 \fBpam_sm_open_session\fR(3PAM), \fBpam_sm_setcred\fR(3PAM),
226 \fBpam_start\fR(3PAM), \fBpam_strerror\fR(3PAM), \fBsyslog\fR(3C),
227 \fBpam.conf\fR(4), \fBattributes\fR(5), \fBpam_authtok_check\fR(5),
228 \fBpam_authtok_get\fR(5), \fBpam_authtok_store\fR(5), \fBpam_dhkeys\fR(5),
229 \fBpam_passwd_auth\fR(5), \fBpam_unix_account\fR(5), \fBpam_unix_auth\fR(5),
230 \fBpam_unix_session\fR(5)
231 .SH NOTES
234 The interfaces in \fBlibpam\fR are MT-Safe only if each thread within the
235 multithreaded application uses its own \fBPAM\fR handle.