File: pam_afs_session.pod

package info (click to toggle)
libpam-afs-session 2.5-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,300 kB
  • ctags: 662
  • sloc: sh: 11,361; ansic: 6,442; makefile: 170; perl: 58
file content (324 lines) | stat: -rw-r--r-- 14,146 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
=for stopwords
AFS PAG PAGs auth Heimdal libkafs aklog KRB5CCNAME kaserver appdefaults
API unlog kdestroy nopag notokens SIGSYS krb524 Kerberos username login
sshd Kerberos-v5-derived SIGCHLD

=head1 NAME

pam_afs_session - AFS PAG and token PAM module

=head1 SYNOPSIS

  auth          optional        pam_afs_session.so
  session       required        pam_afs_session.so

=head1 DESCRIPTION

The AFS session service module for PAM, typically installed at
F</lib/security/pam_afs_session.so>, establishes new AFS sessions and
obtains AFS tokens when a new session is opened for a user.  It is a
shared object that is dynamically loaded by the PAM subsystem as
necessary, based on the system PAM configuration.  PAM is a system for
plugging in external authentication and session management modules so that
each application doesn't have to know the best way to check user
authentication or create a user session on that system.  For details on
how to configure PAM on your system, see the PAM man page, often pam(7).

This module provides pam_setcred, pam_open_session, and pam_close_session
implementations for AFS.  Because pam_setcred is part of the auth PAM
group, it also implements a dummy pam_authenticate that always succeeds
(otherwise, it can't provide a pam_setcred).

Make sure that this module is NEVER listed as C<sufficient> or as the only
C<required> module in the auth group.  Doing so will potentially allow
users to log on without any password.  There unfortunately isn't a way to
work around this and still provide pam_setcred without running afoul of a
bug in (at least) Linux PAM 0.99.7.1 and probably earlier that causes
authentication to fail when the final module in the auth group returns
PAM_IGNORE and C<[default=done]> was given as the action.

Here are the actions of this module:

=over 4

=item pam_open_session

When a new session is opened, this module will first check to see if AFS
is running on the system.  If not, it will log a message and exit
successfully.  If AFS is running, it will place the user's session in a
new PAG (Process Authentication Group, often implemented as supplemental
groups, which limits user tokens to only processes in that PAG).  It will
then attempt to obtain tokens, either directly if built with the Heimdal
libkafs library and Kerberos support or by running an external B<aklog>
program.  If PAG creation fails, the module will fail; if obtaining tokens
fails, the module will log a warning but still return success.

The module will only attempt to obtain tokens if the environment variable
KRB5CCNAME is set in the environment, unless otherwise configured (see the
always_aklog option).  It will always create a new PAG, however.

=item pam_close_session

If and only if pam_open_session successfully obtained AFS tokens and AFS
is still running on the system, pam_close_session will delete the tokens
in the current PAG (equivalent to running B<unlog>).  To leave the tokens
after session close, set the retain_after_close option.

=item pam_setcred

When pam_setcred is called with the PAM_ESTABLISH_CRED flag, it will do
the same as if pam_open_session was called.  When pam_setcred is called
with the PAM_DELETE_CRED flag, it will do the same as if pam_close_session
was called.  When called with the PAM_REINITIALIZE_CRED flag or the
PAM_REFRESH_CRED flag, it won't create a new PAG but instead will only
attempt to get new tokens (still skipping this unless KRB5CCNAME is set in
the environment or always_aklog is set).

=back

This module is primarily intended for use with a Kerberos v5
authentication module.  It does not itself do any user authentication; it
cannot, for instance, be used to authenticate users to a B<kaserver>.
While it is intended for use with an B<aklog> that uses Kerberos v5 ticket
caches to obtain tokens, it can be used with any B<aklog> implementation
(always_aklog may have to be set if no Kerberos v5 ticket cache will be
present).

This module performs no authorization checks and does not hook into
password changes; it only implements the session functions and
pam_setcred.

=head1 CONFIGURATION

The AFS session PAM module supports the following configuration options,
which may be set in the PAM configuration as arguments listed after
C<pam_afs_session.so> or in the system F<krb5.conf>.

Some of them take arguments, in which case the argument will be given
after C<=>.  The rest are boolean options.  To set a boolean option in the
PAM configuration, just give the name of the option in the arguments.  To
set an option that takes an argument, follow the option name with an equal
sign (C<=>) and the value, with no separating whitespace.  Whitespace in
option arguments is not supported in the PAM configuration files of most
PAM implementations.

To set an option for the PAM module in the system F<krb5.conf> file, put
that option in the [appdefaults] section.  The AFS session PAM module will
look for options either at the top level of the [appdefaults] section or
in a subsection named C<pam-afs-session> (currently, realm-specific
configuration is not checked).  For example, the following fragment of a
F<krb5.conf> file would set I<aklog_homedir> to true and I<minimum_uid> to
100.

    [appdefaults]
        aklog_homedir = true
        pam-afs-session = {
            minimum_uid = 100
        }

There is no difference to the PAM module whether options are specified at
the top level or in a C<pam-afs-session> section; the C<pam-afs-session>
section is supported in case there are options that should be set for the
PAM module but not for other applications.  For more information on the
syntax of F<krb5.conf>, see krb5.conf(5).

If the same option is set in F<krb5.conf> and in the PAM configuration,
the latter takes precedent.  Note, however, that due to the configuration
syntax, there's no way to turn off a boolean option in the PAM
configuration that was turned on in F<krb5.conf>.

=over 4

=item afs_cells=I<cell>[,I<cell>...]

Obtain tokens for the listed cells instead of the default local cell.  If
more than one cell is listed, try to obtain tokens for each cell.  If
specified in F<krb5.conf>, the cells can be separated by any combination
of spaces and commas; if specified in the PAM configuration, they must be
separated by commas.

If the AFS session PAM module is running an external program, this option
is implemented by passing a B<-c> flag with the cell as its argument for
each listed cell to that program.  If aklog_homedir is also set, the B<-c>
flags and the B<-p> flag will all be passed to the external program.

=item aklog_homedir

Try to obtain the necessary tokens to access the user's home directory.
If the libkafs token-obtaining API is used, setting this will cause the
AFS session PAM module to pass the user's home directory into that API and
request that the appropriate tokens be obtained.  If running an external
B<aklog> program, B<aklog> will be called with B<-p> I<home-directory>
where I<home-directory> is the home directory of the local user for which
the session is being opened or refreshed.  This generally will tell
B<aklog> to check that path, find all AFS cells involved in access to that
path, and attempt to obtain tokens for each one.  Note that this means
that if the user's home directory is not in AFS, no tokens will be
obtained.

In either case, the user's home directory is obtained via getpwnam() based
on the username PAM says we are authenticating.

=item always_aklog

Normally, the AFS session PAM module only tries to obtain tokens if
KRB5CCNAME is set in the PAM environment.  If this option is set, it will
always attempt to obtain tokens.  This is only useful if it is configured
to run an external B<aklog> program.

This can be used if your environment doesn't correctly set KRB5CCNAME in
the environment for some reason, or if your B<aklog> doesn't rely on a
Kerberos ticket cache to obtain tokens (or can find the cache on its own
via some other means).

=item debug

If this option is set, additional trace information will be logged to
syslog with priority LOG_DEBUG.

=item ignore_root

If this option is set, the AFS session PAM module won't take any action
(and will exit successfully) if the account for which the session is being
established is named C<root>.

=item kdestroy

If this option is set and the AFS session PAM module was built with
Kerberos support, the user's ticket cache will be destroyed after tokens
are obtained successfully.  If tokens are not obtained successfully, the
ticket cache will be left intact.  Please note that this is not properly a
security feature, since the ticket cache will still be written to disk
between the time the Kerberos PAM module authenticates the user and the
time the AFS session PAM module is run.  It can, however, be used to
reduce the window during which Kerberos ticket caches are lying about if
the only use one has for ticket caches is to obtain AFS tokens.

=item minimum_uid=I<uid>

If this option is set, the AFS session PAM module won't take any action
(and will exit successfully) if the account for which the session is being
established has a UID lower than I<uid>.

=item nopag

If this option is set, no PAG will be created.  Be careful when using this
option, since it means that the user will inherit a PAG from the process
managing the login.  If B<sshd>, for instance, is started in a PAG, every
user who logs in via ssh will be put in the same PAG and will share tokens
if this option is used.

This is the default on Mac OS X, where PAGs are not supported.

=item notokens

If this option is set, the AFS session PAM module will only create a PAG
and not attempt to obtain tokens.  Setting this option overrides all other
settings related to acquiring tokens, including always_aklog.  If both
nopag and notokens are set, the module essentially does nothing.

Setting notokens also implies retain_after_close, meaning that the AFS
session PAM module will also not attempt to delete tokens when the user's
session ends.

=item program=I<path>

The path to the B<aklog> program to run.  Setting this option tells the
AFS session PAM module to always run an external program to obtain tokens
and never use the libkafs interface, even if the latter is available.

You may pass options to this program by separating them with commas (or
spaces or tabs in F<krb5.conf> or if the configuration syntax of your PAM
configuration allows this).  For example, the setting:

    program=/usr/bin/aklog,-noprdb,-524

will run C</usr/bin/aklog -noprdb -524> as the program to obtain tokens.
The arguments are passed directly, not parsed by the shell.

If this option is not set, the default behavior is to call the libkafs
function to obtain tokens, if available, and otherwise to use a default
path to B<aklog> determined at compile time (the first B<aklog> found on
the compiler's path by default).  If no B<aklog> could be found at compile
time and libkafs isn't used, this option must be set.

=item retain_after_close

If this option is set, pam_close_session will do nothing (successfully)
rather than deleting tokens.  This will allow programs started in the
user's PAG that are still running when the log out to continue to use the
user's tokens until they expire.  Normally, the AFS kernel module will
automatically clean up tokens once every process in that PAG has
terminated.

=back

=head1 ENVIRONMENT

=over 4

=item KRB5CCNAME

This module looks for KRB5CCNAME in the PAM environment and by default
does not run B<aklog> if it is not set.

=back

The entire PAM environment is passed to B<aklog> as its environment
(rather than the environment of the process running the PAM functions).

=head1 WARNINGS

As mentioned above, this module implements a dummy pam_authenticate
function so that it can provide a pam_setcred function.  Never list this
module as C<sufficient> or as the only C<required> module or you may allow
users to log on without a password.

While spawning an external B<aklog> program, the AFS session PAM module
resets the SIGCHLD signal handler to the default handler while the program
runs and then restores it afterward.  This is done to avoid having aklog
interfere with process handling in the calling application, but it means
that there's a race condition that can cause children to be incorrectly
handled if they exit while aklog is running.  There is unfortunately no
good solution to this other than building against Heimdal and using the
libkafs interface to obtain tokens instead of an external program.

To detect whether AFS is running on the system, the AFS session PAM module
temporarily sets a SIGSYS handler before attempting an AFS system call.
That handler may also modify a static variable.  Neither of these should
ideally be done in a PAM module, but there is no other good way of
checking for the non-existence of a system call that doesn't crash the
application on some operating systems.  The PAM module will attempt to
restore the previous SIGSYS handler, if any, after the test is done, and
the static variable is used in such a way that running it from multiple
threads shouldn't be an issue, but be aware that the PAM module is doing
this behind the back of the application and may interfere with unusual
SIGSYS handlers or similar application actions.

=head1 NOTES

When using the libkafs interface to obtain tokens, be sure that it is
configured properly for the type of AFS tokens expected at your site.  As
of Heimdal 0.7, the default behavior is to contact the krb524 service to
translate Kerberos v5 tickets into Kerberos v4 tickets to use as tokens.
AFS cells running current server software no longer need this, and if your
site doesn't run the krb524 service, this may break token acquisition.

Sites running AFS servers that understand Kerberos-v5-derived tokens
should add configuration like:

    libkafs = {
        EXAMPLE.ORG = {
            afs-use-524 = no
        }
    }

to the [appdefaults] section of their F<krb5.conf> files to disable use of
the krb524 service.  See the Heimdal kafs(3) man page for more
information.

=head1 SEE ALSO

aklog(1), kafs(3), pam(7), syslog(3), unlog(1)

=cut