chiark / gitweb /
Prep v239: Uncomment header inclusions that are new or needed now.
[elogind.git] / src / login / pam_elogind.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include <endian.h>
4 #include <errno.h>
5 #include <fcntl.h>
6 #include <pwd.h>
7 #include <security/_pam_macros.h>
8 #include <security/pam_ext.h>
9 #include <security/pam_misc.h>
10 #include <security/pam_modules.h>
11 #include <security/pam_modutil.h>
12 #include <sys/file.h>
13
14 #include "alloc-util.h"
15 #include "audit-util.h"
16 #include "bus-common-errors.h"
17 #include "bus-error.h"
18 #include "bus-util.h"
19 #include "def.h"
20 #include "fd-util.h"
21 #include "fileio.h"
22 #include "format-util.h"
23 #include "hostname-util.h"
24 #include "login-util.h"
25 #include "macro.h"
26 #include "parse-util.h"
27 #include "process-util.h"
28 #include "socket-util.h"
29 #include "strv.h"
30 #include "terminal-util.h"
31 #include "util.h"
32 #include "path-util.h"
33 #include "cgroup-util.h"
34
35 static int parse_argv(
36                 pam_handle_t *handle,
37                 int argc, const char **argv,
38                 const char **class,
39                 const char **type,
40                 bool *debug) {
41
42         unsigned i;
43
44         assert(argc >= 0);
45         assert(argc == 0 || argv);
46
47         for (i = 0; i < (unsigned) argc; i++) {
48                 if (startswith(argv[i], "class=")) {
49                         if (class)
50                                 *class = argv[i] + 6;
51
52                 } else if (startswith(argv[i], "type=")) {
53                         if (type)
54                                 *type = argv[i] + 5;
55
56                 } else if (streq(argv[i], "debug")) {
57                         if (debug)
58                                 *debug = true;
59
60                 } else if (startswith(argv[i], "debug=")) {
61                         int k;
62
63                         k = parse_boolean(argv[i] + 6);
64                         if (k < 0)
65                                 pam_syslog(handle, LOG_WARNING, "Failed to parse debug= argument, ignoring.");
66                         else if (debug)
67                                 *debug = k;
68
69                 } else
70                         pam_syslog(handle, LOG_WARNING, "Unknown parameter '%s', ignoring", argv[i]);
71         }
72
73         return 0;
74 }
75
76 static int get_user_data(
77                 pam_handle_t *handle,
78                 const char **ret_username,
79                 struct passwd **ret_pw) {
80
81         const char *username = NULL;
82         struct passwd *pw = NULL;
83         int r;
84
85         assert(handle);
86         assert(ret_username);
87         assert(ret_pw);
88
89         r = pam_get_user(handle, &username, NULL);
90         if (r != PAM_SUCCESS) {
91                 pam_syslog(handle, LOG_ERR, "Failed to get user name.");
92                 return r;
93         }
94
95         if (isempty(username)) {
96                 pam_syslog(handle, LOG_ERR, "User name not valid.");
97                 return PAM_AUTH_ERR;
98         }
99
100         pw = pam_modutil_getpwnam(handle, username);
101         if (!pw) {
102                 pam_syslog(handle, LOG_ERR, "Failed to get user data.");
103                 return PAM_USER_UNKNOWN;
104         }
105
106         *ret_pw = pw;
107         *ret_username = username;
108
109         return PAM_SUCCESS;
110 }
111
112 static int get_seat_from_display(const char *display, const char **seat, uint32_t *vtnr) {
113         union sockaddr_union sa = {
114                 .un.sun_family = AF_UNIX,
115         };
116         _cleanup_free_ char *p = NULL, *tty = NULL;
117         _cleanup_close_ int fd = -1;
118         struct ucred ucred;
119         int v, r;
120
121         assert(display);
122         assert(vtnr);
123
124         /* We deduce the X11 socket from the display name, then use
125          * SO_PEERCRED to determine the X11 server process, ask for
126          * the controlling tty of that and if it's a VC then we know
127          * the seat and the virtual terminal. Sounds ugly, is only
128          * semi-ugly. */
129
130         r = socket_from_display(display, &p);
131         if (r < 0)
132                 return r;
133         strncpy(sa.un.sun_path, p, sizeof(sa.un.sun_path)-1);
134
135         fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
136         if (fd < 0)
137                 return -errno;
138
139         if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
140                 return -errno;
141
142         r = getpeercred(fd, &ucred);
143         if (r < 0)
144                 return r;
145
146         r = get_ctty(ucred.pid, NULL, &tty);
147         if (r < 0)
148                 return r;
149
150         v = vtnr_from_tty(tty);
151         if (v < 0)
152                 return v;
153         else if (v == 0)
154                 return -ENOENT;
155
156         if (seat)
157                 *seat = "seat0";
158         *vtnr = (uint32_t) v;
159
160         return 0;
161 }
162
163 static int export_legacy_dbus_address(
164                 pam_handle_t *handle,
165                 uid_t uid,
166                 const char *runtime) {
167
168         _cleanup_free_ char *s = NULL;
169         int r = PAM_BUF_ERR;
170
171         /* FIXME: We *really* should move the access() check into the
172          * daemons that spawn dbus-daemon, instead of forcing
173          * DBUS_SESSION_BUS_ADDRESS= here. */
174
175         s = strjoin(runtime, "/bus");
176         if (!s)
177                 goto error;
178
179         if (access(s, F_OK) < 0)
180                 return PAM_SUCCESS;
181
182         s = mfree(s);
183         if (asprintf(&s, DEFAULT_USER_BUS_ADDRESS_FMT, runtime) < 0)
184                 goto error;
185
186         r = pam_misc_setenv(handle, "DBUS_SESSION_BUS_ADDRESS", s, 0);
187         if (r != PAM_SUCCESS)
188                 goto error;
189
190         return PAM_SUCCESS;
191
192 error:
193         pam_syslog(handle, LOG_ERR, "Failed to set bus variable.");
194         return r;
195 }
196
197 static int append_session_memory_max(pam_handle_t *handle, sd_bus_message *m, const char *limit) {
198         uint64_t val;
199         int r;
200
201         if (isempty(limit))
202                 return 0;
203
204         if (streq(limit, "infinity")) {
205                 r = sd_bus_message_append(m, "(sv)", "MemoryMax", "t", (uint64_t)-1);
206                 if (r < 0) {
207                         pam_syslog(handle, LOG_ERR, "Failed to append to bus message: %s", strerror(-r));
208                         return r;
209                 }
210         } else {
211                 r = parse_percent(limit);
212                 if (r >= 0) {
213                         r = sd_bus_message_append(m, "(sv)", "MemoryMaxScale", "u", (uint32_t) (((uint64_t) UINT32_MAX * r) / 100U));
214                         if (r < 0) {
215                                 pam_syslog(handle, LOG_ERR, "Failed to append to bus message: %s", strerror(-r));
216                                 return r;
217                         }
218                 } else {
219                         r = parse_size(limit, 1024, &val);
220                         if (r >= 0) {
221                                 r = sd_bus_message_append(m, "(sv)", "MemoryMax", "t", val);
222                                 if (r < 0) {
223                                         pam_syslog(handle, LOG_ERR, "Failed to append to bus message: %s", strerror(-r));
224                                         return r;
225                                 }
226                         } else
227                                 pam_syslog(handle, LOG_WARNING, "Failed to parse elogind.limit: %s, ignoring.", limit);
228                 }
229         }
230
231         return 0;
232 }
233
234 static int append_session_tasks_max(pam_handle_t *handle, sd_bus_message *m, const char *limit)
235 {
236         uint64_t val;
237         int r;
238
239         /* No need to parse "infinity" here, it will be set unconditionally later in manager_start_scope() */
240         if (isempty(limit) || streq(limit, "infinity"))
241                 return 0;
242
243         r = safe_atou64(limit, &val);
244         if (r >= 0) {
245                 r = sd_bus_message_append(m, "(sv)", "TasksMax", "t", val);
246                 if (r < 0) {
247                         pam_syslog(handle, LOG_ERR, "Failed to append to bus message: %s", strerror(-r));
248                         return r;
249                 }
250         } else
251                 pam_syslog(handle, LOG_WARNING, "Failed to parse elogind.limit: %s, ignoring.", limit);
252
253         return 0;
254 }
255
256 static int append_session_cg_weight(pam_handle_t *handle, sd_bus_message *m, const char *limit, const char *field) {
257         uint64_t val;
258         int r;
259
260         if (!isempty(limit)) {
261                 r = cg_weight_parse(limit, &val);
262                 if (r >= 0) {
263                         r = sd_bus_message_append(m, "(sv)", field, "t", val);
264                         if (r < 0) {
265                                 pam_syslog(handle, LOG_ERR, "Failed to append to bus message: %s", strerror(-r));
266                                 return r;
267                         }
268                 } else if (streq(field, "CPUWeight"))
269                         pam_syslog(handle, LOG_WARNING, "Failed to parse elogind.cpu_weight: %s, ignoring.", limit);
270                 else
271                         pam_syslog(handle, LOG_WARNING, "Failed to parse elogind.io_weight: %s, ignoring.", limit);
272         }
273
274         return 0;
275 }
276
277 _public_ PAM_EXTERN int pam_sm_open_session(
278                 pam_handle_t *handle,
279                 int flags,
280                 int argc, const char **argv) {
281
282         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
283         _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
284         const char
285                 *username, *id, *object_path, *runtime_path,
286                 *service = NULL,
287                 *tty = NULL, *display = NULL,
288                 *remote_user = NULL, *remote_host = NULL,
289                 *seat = NULL,
290                 *type = NULL, *class = NULL,
291                 *class_pam = NULL, *type_pam = NULL, *cvtnr = NULL, *desktop = NULL,
292                 *memory_max = NULL, *tasks_max = NULL, *cpu_weight = NULL, *io_weight = NULL;
293         _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
294         int session_fd = -1, existing, r;
295         bool debug = false, remote;
296         struct passwd *pw;
297         uint32_t vtnr = 0;
298         uid_t original_uid;
299
300         assert(handle);
301
302 #if 0 /// with elogind, it is always a "logind system".
303         /* Make this a NOP on non-logind systems */
304         if (!logind_running())
305                 return PAM_SUCCESS;
306 #endif // 0
307
308         if (parse_argv(handle,
309                        argc, argv,
310                        &class_pam,
311                        &type_pam,
312                        &debug) < 0)
313                 return PAM_SESSION_ERR;
314
315         if (debug)
316                 pam_syslog(handle, LOG_DEBUG, "pam-elogind initializing");
317
318         r = get_user_data(handle, &username, &pw);
319         if (r != PAM_SUCCESS) {
320                 pam_syslog(handle, LOG_ERR, "Failed to get user data.");
321                 return r;
322         }
323
324         /* Make sure we don't enter a loop by talking to
325          * elogind when it is actually waiting for the
326          * background to finish start-up. If the service is
327          * "elogind-user" we simply set XDG_RUNTIME_DIR and
328          * leave. */
329
330         pam_get_item(handle, PAM_SERVICE, (const void**) &service);
331         if (streq_ptr(service, "elogind-user")) {
332                 _cleanup_free_ char *rt = NULL;
333
334                 if (asprintf(&rt, "/run/user/"UID_FMT, pw->pw_uid) < 0)
335                         return PAM_BUF_ERR;
336
337                 r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0);
338                 if (r != PAM_SUCCESS) {
339                         pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
340                         return r;
341                 }
342
343                 r = export_legacy_dbus_address(handle, pw->pw_uid, rt);
344                 if (r != PAM_SUCCESS)
345                         return r;
346
347                 return PAM_SUCCESS;
348         }
349
350         /* Otherwise, we ask logind to create a session for us */
351
352         pam_get_item(handle, PAM_XDISPLAY, (const void**) &display);
353         pam_get_item(handle, PAM_TTY, (const void**) &tty);
354         pam_get_item(handle, PAM_RUSER, (const void**) &remote_user);
355         pam_get_item(handle, PAM_RHOST, (const void**) &remote_host);
356
357         seat = pam_getenv(handle, "XDG_SEAT");
358         if (isempty(seat))
359                 seat = getenv("XDG_SEAT");
360
361         cvtnr = pam_getenv(handle, "XDG_VTNR");
362         if (isempty(cvtnr))
363                 cvtnr = getenv("XDG_VTNR");
364
365         type = pam_getenv(handle, "XDG_SESSION_TYPE");
366         if (isempty(type))
367                 type = getenv("XDG_SESSION_TYPE");
368         if (isempty(type))
369                 type = type_pam;
370
371         class = pam_getenv(handle, "XDG_SESSION_CLASS");
372         if (isempty(class))
373                 class = getenv("XDG_SESSION_CLASS");
374         if (isempty(class))
375                 class = class_pam;
376
377         desktop = pam_getenv(handle, "XDG_SESSION_DESKTOP");
378         if (isempty(desktop))
379                 desktop = getenv("XDG_SESSION_DESKTOP");
380
381         tty = strempty(tty);
382
383         if (strchr(tty, ':')) {
384                 /* A tty with a colon is usually an X11 display,
385                  * placed there to show up in utmp. We rearrange
386                  * things and don't pretend that an X display was a
387                  * tty. */
388
389                 if (isempty(display))
390                         display = tty;
391                 tty = NULL;
392         } else if (streq(tty, "cron")) {
393                 /* cron has been setting PAM_TTY to "cron" for a very
394                  * long time and it probably shouldn't stop doing that
395                  * for compatibility reasons. */
396                 type = "unspecified";
397                 class = "background";
398                 tty = NULL;
399         } else if (streq(tty, "ssh")) {
400                 /* ssh has been setting PAM_TTY to "ssh" for a very
401                  * long time and probably shouldn't stop doing that
402                  * for compatibility reasons. */
403                 type ="tty";
404                 class = "user";
405                 tty = NULL;
406         } else
407                 /* Chop off leading /dev prefix that some clients specify, but others do not. */
408                 tty = skip_dev_prefix(tty);
409
410         /* If this fails vtnr will be 0, that's intended */
411         if (!isempty(cvtnr))
412                 (void) safe_atou32(cvtnr, &vtnr);
413
414         if (!isempty(display) && !vtnr) {
415                 if (isempty(seat))
416                         get_seat_from_display(display, &seat, &vtnr);
417                 else if (streq(seat, "seat0"))
418                         get_seat_from_display(display, NULL, &vtnr);
419         }
420
421         if (seat && !streq(seat, "seat0") && vtnr != 0) {
422                 pam_syslog(handle, LOG_DEBUG, "Ignoring vtnr %"PRIu32" for %s which is not seat0", vtnr, seat);
423                 vtnr = 0;
424         }
425
426         if (isempty(type))
427                 type = !isempty(display) ? "x11" :
428                            !isempty(tty) ? "tty" : "unspecified";
429
430         if (isempty(class))
431                 class = streq(type, "unspecified") ? "background" : "user";
432
433         remote = !isempty(remote_host) && !is_localhost(remote_host);
434
435         (void) pam_get_data(handle, "elogind.memory_max", (const void **)&memory_max);
436         (void) pam_get_data(handle, "elogind.tasks_max",  (const void **)&tasks_max);
437         (void) pam_get_data(handle, "elogind.cpu_weight", (const void **)&cpu_weight);
438         (void) pam_get_data(handle, "elogind.io_weight",  (const void **)&io_weight);
439
440         /* Talk to logind over the message bus */
441
442         r = sd_bus_open_system(&bus);
443         if (r < 0) {
444                 pam_syslog(handle, LOG_ERR, "Failed to connect to system bus: %s", strerror(-r));
445                 return PAM_SESSION_ERR;
446         }
447
448         if (debug) {
449                 pam_syslog(handle, LOG_DEBUG, "Asking logind to create session: "
450                            "uid="UID_FMT" pid="PID_FMT" service=%s type=%s class=%s desktop=%s seat=%s vtnr=%"PRIu32" tty=%s display=%s remote=%s remote_user=%s remote_host=%s",
451                            pw->pw_uid, getpid_cached(),
452                            strempty(service),
453                            type, class, strempty(desktop),
454                            strempty(seat), vtnr, strempty(tty), strempty(display),
455                            yes_no(remote), strempty(remote_user), strempty(remote_host));
456                 pam_syslog(handle, LOG_DEBUG, "Session limits: "
457                            "memory_max=%s tasks_max=%s cpu_weight=%s io_weight=%s",
458                            strna(memory_max), strna(tasks_max), strna(cpu_weight), strna(io_weight));
459         }
460
461         r = sd_bus_message_new_method_call(
462                         bus,
463                         &m,
464                         "org.freedesktop.login1",
465                         "/org/freedesktop/login1",
466                         "org.freedesktop.login1.Manager",
467                         "CreateSession");
468         if (r < 0) {
469                 pam_syslog(handle, LOG_ERR, "Failed to create CreateSession method call: %s", strerror(-r));
470                 return PAM_SESSION_ERR;
471         }
472
473         r = sd_bus_message_append(m, "uusssssussbss",
474                         (uint32_t) pw->pw_uid,
475                         (uint32_t) getpid_cached(),
476                         service,
477                         type,
478                         class,
479                         desktop,
480                         seat,
481                         vtnr,
482                         tty,
483                         display,
484                         remote,
485                         remote_user,
486                         remote_host);
487         if (r < 0) {
488                 pam_syslog(handle, LOG_ERR, "Failed to append to bus message: %s", strerror(-r));
489                 return PAM_SESSION_ERR;
490         }
491
492         r = sd_bus_message_open_container(m, 'a', "(sv)");
493         if (r < 0) {
494                 pam_syslog(handle, LOG_ERR, "Failed to open message container: %s", strerror(-r));
495                 return PAM_SYSTEM_ERR;
496         }
497
498         r = append_session_memory_max(handle, m, memory_max);
499         if (r < 0)
500                 return PAM_SESSION_ERR;
501
502         r = append_session_tasks_max(handle, m, tasks_max);
503         if (r < 0)
504                 return PAM_SESSION_ERR;
505
506         r = append_session_cg_weight(handle, m, cpu_weight, "CPUWeight");
507         if (r < 0)
508                 return PAM_SESSION_ERR;
509
510         r = append_session_cg_weight(handle, m, io_weight, "IOWeight");
511         if (r < 0)
512                 return PAM_SESSION_ERR;
513
514         r = sd_bus_message_close_container(m);
515         if (r < 0) {
516                 pam_syslog(handle, LOG_ERR, "Failed to close message container: %s", strerror(-r));
517                 return PAM_SYSTEM_ERR;
518         }
519
520         r = sd_bus_call(bus, m, 0, &error, &reply);
521         if (r < 0) {
522                 if (sd_bus_error_has_name(&error, BUS_ERROR_SESSION_BUSY)) {
523                         pam_syslog(handle, LOG_DEBUG, "Cannot create session: %s", bus_error_message(&error, r));
524                         return PAM_SUCCESS;
525                 } else {
526                         pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error, r));
527                         return PAM_SYSTEM_ERR;
528                 }
529         }
530
531         r = sd_bus_message_read(reply,
532                                 "soshusub",
533                                 &id,
534                                 &object_path,
535                                 &runtime_path,
536                                 &session_fd,
537                                 &original_uid,
538                                 &seat,
539                                 &vtnr,
540                                 &existing);
541         if (r < 0) {
542                 pam_syslog(handle, LOG_ERR, "Failed to parse message: %s", strerror(-r));
543                 return PAM_SESSION_ERR;
544         }
545
546         if (debug)
547                 pam_syslog(handle, LOG_DEBUG, "Reply from logind: "
548                            "id=%s object_path=%s runtime_path=%s session_fd=%d seat=%s vtnr=%u original_uid=%u",
549                            id, object_path, runtime_path, session_fd, seat, vtnr, original_uid);
550
551         r = pam_misc_setenv(handle, "XDG_SESSION_ID", id, 0);
552         if (r != PAM_SUCCESS) {
553                 pam_syslog(handle, LOG_ERR, "Failed to set session id.");
554                 return r;
555         }
556
557         if (original_uid == pw->pw_uid) {
558                 /* Don't set $XDG_RUNTIME_DIR if the user we now
559                  * authenticated for does not match the original user
560                  * of the session. We do this in order not to result
561                  * in privileged apps clobbering the runtime directory
562                  * unnecessarily. */
563
564                 r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", runtime_path, 0);
565                 if (r != PAM_SUCCESS) {
566                         pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
567                         return r;
568                 }
569
570                 r = export_legacy_dbus_address(handle, pw->pw_uid, runtime_path);
571                 if (r != PAM_SUCCESS)
572                         return r;
573         }
574
575         if (!isempty(seat)) {
576                 r = pam_misc_setenv(handle, "XDG_SEAT", seat, 0);
577                 if (r != PAM_SUCCESS) {
578                         pam_syslog(handle, LOG_ERR, "Failed to set seat.");
579                         return r;
580                 }
581         }
582
583         if (vtnr > 0) {
584                 char buf[DECIMAL_STR_MAX(vtnr)];
585                 sprintf(buf, "%u", vtnr);
586
587                 r = pam_misc_setenv(handle, "XDG_VTNR", buf, 0);
588                 if (r != PAM_SUCCESS) {
589                         pam_syslog(handle, LOG_ERR, "Failed to set virtual terminal number.");
590                         return r;
591                 }
592         }
593
594         r = pam_set_data(handle, "systemd.existing", INT_TO_PTR(!!existing), NULL);
595         if (r != PAM_SUCCESS) {
596                 pam_syslog(handle, LOG_ERR, "Failed to install existing flag.");
597                 return r;
598         }
599
600         if (session_fd >= 0) {
601                 session_fd = fcntl(session_fd, F_DUPFD_CLOEXEC, 3);
602                 if (session_fd < 0) {
603                         pam_syslog(handle, LOG_ERR, "Failed to dup session fd: %m");
604                         return PAM_SESSION_ERR;
605                 }
606
607                 r = pam_set_data(handle, "systemd.session-fd", FD_TO_PTR(session_fd), NULL);
608                 if (r != PAM_SUCCESS) {
609                         pam_syslog(handle, LOG_ERR, "Failed to install session fd.");
610                         safe_close(session_fd);
611                         return r;
612                 }
613         }
614
615         return PAM_SUCCESS;
616 }
617
618 _public_ PAM_EXTERN int pam_sm_close_session(
619                 pam_handle_t *handle,
620                 int flags,
621                 int argc, const char **argv) {
622
623         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
624         _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
625         const void *existing = NULL;
626         const char *id;
627         int r;
628
629         assert(handle);
630
631         /* Only release session if it wasn't pre-existing when we
632          * tried to create it */
633         pam_get_data(handle, "systemd.existing", &existing);
634
635         id = pam_getenv(handle, "XDG_SESSION_ID");
636         if (id && !existing) {
637
638                 /* Before we go and close the FIFO we need to tell
639                  * logind that this is a clean session shutdown, so
640                  * that it doesn't just go and slaughter us
641                  * immediately after closing the fd */
642
643                 r = sd_bus_open_system(&bus);
644                 if (r < 0) {
645                         pam_syslog(handle, LOG_ERR, "Failed to connect to system bus: %s", strerror(-r));
646                         return PAM_SESSION_ERR;
647                 }
648
649                 r = sd_bus_call_method(bus,
650                                        "org.freedesktop.login1",
651                                        "/org/freedesktop/login1",
652                                        "org.freedesktop.login1.Manager",
653                                        "ReleaseSession",
654                                        &error,
655                                        NULL,
656                                        "s",
657                                        id);
658                 if (r < 0) {
659                         pam_syslog(handle, LOG_ERR, "Failed to release session: %s", bus_error_message(&error, r));
660                         return PAM_SESSION_ERR;
661                 }
662         }
663
664         /* Note that we are knowingly leaking the FIFO fd here. This
665          * way, logind can watch us die. If we closed it here it would
666          * not have any clue when that is completed. Given that one
667          * cannot really have multiple PAM sessions open from the same
668          * process this means we will leak one FD at max. */
669
670         return PAM_SUCCESS;
671 }