summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-11-27 17:22:54 +0100
committerLennart Poettering <lennart@poettering.net>2024-01-04 15:01:38 +0100
commit3d010bc53db5779ac4d41db61df4f5f822bb5565 (patch)
tree7238433e80295dbe2273532531c5618e7697271e /src
parentexecute: make sure Type=exec and PAMName= work together (diff)
downloadsystemd-3d010bc53db5779ac4d41db61df4f5f822bb5565.tar.xz
systemd-3d010bc53db5779ac4d41db61df4f5f822bb5565.zip
pam_systemd: drop unnecessary strempty() of 'tty' variable
This probably predates our introduction of streq_ptr(). Let's drop this now however, as we actually want this to be NULL, further down, and handle that just fine. In particular as all the special cases we have explicitly set this to NULL anyway. No real change in behaviour, just some normalization of handling.
Diffstat (limited to 'src')
-rw-r--r--src/login/pam_systemd.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index b8da266e27..4d391ffaff 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -967,16 +967,14 @@ _public_ PAM_EXTERN int pam_sm_open_session(
class = getenv_harder(handle, "XDG_SESSION_CLASS", class_pam);
desktop = getenv_harder(handle, "XDG_SESSION_DESKTOP", desktop_pam);
- tty = strempty(tty);
-
- if (strchr(tty, ':')) {
+ if (tty && strchr(tty, ':')) {
/* A tty with a colon is usually an X11 display, placed there to show up in utmp. We rearrange things
* and don't pretend that an X display was a tty. */
if (isempty(display))
display = tty;
tty = NULL;
- } else if (streq(tty, "cron")) {
+ } else if (streq_ptr(tty, "cron")) {
/* cron is setting PAM_TTY to "cron" for some reason (the commit carries no information why, but
* probably because it wants to set it to something as pam_time/pam_access/… require PAM_TTY to be set
* (as they otherwise even try to update it!) — but cron doesn't actually allocate a TTY for its forked
@@ -985,10 +983,10 @@ _public_ PAM_EXTERN int pam_sm_open_session(
class = "background";
tty = NULL;
- } else if (streq(tty, "ssh")) {
+ } else if (streq_ptr(tty, "ssh")) {
/* ssh has been setting PAM_TTY to "ssh" (for the same reason as cron does this, see above. For further
* details look for "PAM_TTY_KLUDGE" in the openssh sources). */
- type ="tty";
+ type = "tty";
class = "user";
tty = NULL; /* This one is particularly sad, as this means that ssh sessions — even though usually
* associated with a pty — won't be tracked by their tty in logind. This is because ssh
@@ -996,7 +994,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
* much later (this is because it doesn't know yet if it needs one at all, as whether to
* register a pty or not is negotiated much later in the protocol). */
- } else
+ } else if (tty)
/* Chop off leading /dev prefix that some clients specify, but others do not. */
tty = skip_dev_prefix(tty);