From 2f03f2fcdd1626228a248286cad975728835863f Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sun, 17 May 2020 23:33:40 +0200 Subject: [PATCH] corrected the code for session connecting --- main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index d29481d..13cdb55 100644 --- a/main.c +++ b/main.c @@ -387,11 +387,7 @@ int getprocinfo( struct connexion * conn ) while ( flag == 0) { r = getpids( conn->pid, child_pid ); - if( level == 0 && r == 2 ) - { - flag = 1; - retval = -1; - }else if ( r != -1 ) + if ( r != -1 ) { level++; strcat(tab," "); @@ -404,7 +400,7 @@ int getprocinfo( struct connexion * conn ) // get the command parameters sprintf( child_path, "/proc/%d/cmdline", conn->pid ); - if ( (fh1= fopen( child_path, "r" )) == NULL) + if ( (fh1 = fopen( child_path, "r" )) == NULL) { if (debug >= 1) perror(child_path); return 2; @@ -413,6 +409,10 @@ int getprocinfo( struct connexion * conn ) null2space( str ); sprintf(conn->cmdline, "%s", str); fclose(fh1); + if ((strstr(conn->cmdline, "pam") || strstr(conn->cmdline, "net")) != 0) + { + retval = -1; + } // get the command name sprintf( child_path, "/proc/%d/comm", conn->pid ); if ( (fh1= fopen(child_path, "r" )) == NULL) @@ -422,6 +422,7 @@ int getprocinfo( struct connexion * conn ) } fscanf( fh1, "%s", conn->cmd ); fclose(fh1); + return retval; }