summaryrefslogtreecommitdiffstats
path: root/src/userlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/userlist.c')
-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 ) {