diff options
author | Simon Rettberg | 2023-01-11 11:50:15 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-01-11 11:50:15 +0100 |
commit | eb2ab82ff7ed51eb5b744c3ea21b51f793116809 (patch) | |
tree | b3ff7dd06e02cb4bc6dca21f56570398e7423d06 | |
parent | Add --logout-is-shutdown flag (diff) | |
download | idle-daemon-eb2ab82ff7ed51eb5b744c3ea21b51f793116809.tar.gz idle-daemon-eb2ab82ff7ed51eb5b744c3ea21b51f793116809.tar.xz idle-daemon-eb2ab82ff7ed51eb5b744c3ea21b51f793116809.zip |
Fix session id detection on newer systemd
-rw-r--r-- | src/userlist.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/userlist.c b/src/userlist.c index 1f65eb5..7a4a348 100644 --- a/src/userlist.c +++ b/src/userlist.c @@ -183,8 +183,9 @@ static void getSessionData( struct user * user ) char sessionName[40] = ""; while ( fgets( buffer, sizeof(buffer), fh ) != NULL ) { const char *p = strstr( buffer, ":name=systemd:" ); - if ( p == NULL ) - continue; + if ( p == NULL ) { + p = buffer; + } p = strstr( p + 14, "/session-" ); if ( p == NULL ) continue; @@ -192,6 +193,10 @@ static void getSessionData( struct user * user ) break; } fclose( fh ); + if ( sessionName[0] == '\0' ) { + fprintf( stderr, "getSessionData: Cannot get logind session id from %d cgroup file.\n", (int)user->sessionLeader ); + return; + } // Extract session leader pid from loginctl - it's often different from what utmp says int fds[2]; if ( pipe( fds ) == -1 ) { |