summaryrefslogtreecommitdiff
path: root/src/login/pam-module.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-10-31 00:58:25 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-11-06 14:56:47 -0500
commit05a049cc44d1c7eadfab104eea15b13f0207ab40 (patch)
tree73c9dc11f559f27a1ebfd449b7de5041aa87eece /src/login/pam-module.c
parentf7262a9f282fb3bea713458638cad7e79119c1e2 (diff)
systemd_pam: treat debug as debug=1 and parse all params
systemd_pam would ignore all params after the first invalid one. Instead ignore just this one, and parse the rest. There's just one now, but as a matter of principle ;) Also, allow debug as an alias for debug=1, and don't treat invalid debug= options as fatal.
Diffstat (limited to 'src/login/pam-module.c')
-rw-r--r--src/login/pam-module.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index 81ec15f93a..3b6b163a47 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -51,30 +51,26 @@ static int parse_argv(pam_handle_t *handle,
assert(argc >= 0);
assert(argc == 0 || argv);
- for (i = 0; i < (unsigned) argc; i++) {
- int k;
-
+ for (i = 0; i < (unsigned) argc; i++)
if (startswith(argv[i], "class=")) {
-
if (class)
*class = argv[i] + 6;
- } else if (startswith(argv[i], "debug=")) {
- k = parse_boolean(argv[i] + 6);
+ } else if (streq(argv[i], "debug")) {
+ if (debug)
+ *debug = true;
- if (k < 0) {
- pam_syslog(handle, LOG_ERR, "Failed to parse debug= argument.");
- return k;
- }
+ } else if (startswith(argv[i], "debug=")) {
+ int k;
- if (debug)
+ k = parse_boolean(argv[i] + 6);
+ if (k < 0)
+ pam_syslog(handle, LOG_WARNING, "Failed to parse debug= argument, ignoring.");
+ else if (debug)
*debug = k;
- } else {
+ } else
pam_syslog(handle, LOG_WARNING, "Unknown parameter '%s', ignoring", argv[i]);
- return 0;
- }
- }
return 0;
}
@@ -226,7 +222,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
pam_get_item(handle, PAM_SERVICE, (const void**) &service);
if (streq_ptr(service, "systemd-user")) {
- char *p, *rt = NULL;
+ _cleanup_free_ char *p = NULL, *rt = NULL;
if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) pw->pw_uid) < 0) {
r = PAM_BUF_ERR;
@@ -236,18 +232,13 @@ _public_ PAM_EXTERN int pam_sm_open_session(
r = parse_env_file(p, NEWLINE,
"RUNTIME", &rt,
NULL);
- free(p);
-
if (r < 0 && r != -ENOENT) {
r = PAM_SESSION_ERR;
- free(rt);
goto finish;
}
if (rt) {
r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0);
- free(rt);
-
if (r != PAM_SUCCESS) {
pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
goto finish;