summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2023-01-11 11:50:15 +0100
committerSimon Rettberg2023-01-11 11:50:15 +0100
commiteb2ab82ff7ed51eb5b744c3ea21b51f793116809 (patch)
treeb3ff7dd06e02cb4bc6dca21f56570398e7423d06 /src
parentAdd --logout-is-shutdown flag (diff)
downloadidle-daemon-eb2ab82ff7ed51eb5b744c3ea21b51f793116809.tar.gz
idle-daemon-eb2ab82ff7ed51eb5b744c3ea21b51f793116809.tar.xz
idle-daemon-eb2ab82ff7ed51eb5b744c3ea21b51f793116809.zip
Fix session id detection on newer systemd
Diffstat (limited to 'src')
-rw-r--r--src/userlist.c9
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 ) {