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.
</varlistentry>
<varlistentry>
</varlistentry>
<varlistentry>
- <term><option>debug=</option></term>
+ <term><option>debug<optional>=</optional></option></term>
- <listitem><para>Takes a boolean
- argument. If yes, the module will log
+ <listitem><para>Takes an optional
+ boolean argument. If yes or without
+ the argument, the module will log
debugging information as it
operates.</para></listitem>
</varlistentry>
debugging information as it
operates.</para></listitem>
</varlistentry>
assert(argc >= 0);
assert(argc == 0 || argv);
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 (startswith(argv[i], "class=")) {
if (class)
*class = argv[i] + 6;
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;
+ k = parse_boolean(argv[i] + 6);
+ if (k < 0)
+ pam_syslog(handle, LOG_WARNING, "Failed to parse debug= argument, ignoring.");
+ else if (debug)
pam_syslog(handle, LOG_WARNING, "Unknown parameter '%s', ignoring", argv[i]);
pam_syslog(handle, LOG_WARNING, "Unknown parameter '%s', ignoring", argv[i]);
pam_get_item(handle, PAM_SERVICE, (const void**) &service);
if (streq_ptr(service, "systemd-user")) {
pam_get_item(handle, PAM_SERVICE, (const void**) &service);
if (streq_ptr(service, "systemd-user")) {
+ _cleanup_free_ char *p = NULL, *rt = NULL;
if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) pw->pw_uid) < 0) {
r = PAM_BUF_ERR;
if (asprintf(&p, "/run/systemd/users/%lu", (unsigned long) pw->pw_uid) < 0) {
r = PAM_BUF_ERR;
r = parse_env_file(p, NEWLINE,
"RUNTIME", &rt,
NULL);
r = parse_env_file(p, NEWLINE,
"RUNTIME", &rt,
NULL);
if (r < 0 && r != -ENOENT) {
r = PAM_SESSION_ERR;
if (r < 0 && r != -ENOENT) {
r = PAM_SESSION_ERR;
goto finish;
}
if (rt) {
r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0);
goto finish;
}
if (rt) {
r = pam_misc_setenv(handle, "XDG_RUNTIME_DIR", rt, 0);
if (r != PAM_SUCCESS) {
pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
goto finish;
if (r != PAM_SUCCESS) {
pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
goto finish;