1
0

corrected the code for session connecting

This commit is contained in:
Daniel Tartavel 2020-05-17 23:33:40 +02:00
parent 32920d49cc
commit 2f03f2fcdd

13
main.c
View File

@ -387,11 +387,7 @@ int getprocinfo( struct connexion * conn )
while ( flag == 0) while ( flag == 0)
{ {
r = getpids( conn->pid, child_pid ); r = getpids( conn->pid, child_pid );
if( level == 0 && r == 2 ) if ( r != -1 )
{
flag = 1;
retval = -1;
}else if ( r != -1 )
{ {
level++; level++;
strcat(tab," "); strcat(tab," ");
@ -404,7 +400,7 @@ int getprocinfo( struct connexion * conn )
// get the command parameters // get the command parameters
sprintf( child_path, "/proc/%d/cmdline", conn->pid ); 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); if (debug >= 1) perror(child_path);
return 2; return 2;
@ -413,6 +409,10 @@ int getprocinfo( struct connexion * conn )
null2space( str ); null2space( str );
sprintf(conn->cmdline, "%s", str); sprintf(conn->cmdline, "%s", str);
fclose(fh1); fclose(fh1);
if ((strstr(conn->cmdline, "pam") || strstr(conn->cmdline, "net")) != 0)
{
retval = -1;
}
// get the command name // get the command name
sprintf( child_path, "/proc/%d/comm", conn->pid ); sprintf( child_path, "/proc/%d/comm", conn->pid );
if ( (fh1= fopen(child_path, "r" )) == NULL) if ( (fh1= fopen(child_path, "r" )) == NULL)
@ -422,6 +422,7 @@ int getprocinfo( struct connexion * conn )
} }
fscanf( fh1, "%s", conn->cmd ); fscanf( fh1, "%s", conn->cmd );
fclose(fh1); fclose(fh1);
return retval; return retval;
} }