some bugs
This commit is contained in:
parent
0bb0c7885e
commit
001a819a59
18
main.c
18
main.c
@ -68,6 +68,7 @@ int printlog(char str[], int level, int errnum)
|
||||
|
||||
if ( level <= loglevel )
|
||||
{
|
||||
time( &now );
|
||||
if (errnum != 0)
|
||||
{
|
||||
sprintf( tmp, "%s: %s %s\n", frtime(now), str, strerror(errnum));
|
||||
@ -309,8 +310,8 @@ void getutmp( struct connexion * conn, time_t * time )
|
||||
char str[6];
|
||||
char strlog[128];
|
||||
|
||||
conn->host_ip[0]='\0';
|
||||
conn->host_ipv6[0]='\0';
|
||||
//conn->host_ip[0]='\0';
|
||||
//conn->host_ipv6[0]='\0';
|
||||
setutent();
|
||||
while ( (utmp = getutent()) != NULL )
|
||||
{
|
||||
@ -320,7 +321,7 @@ void getutmp( struct connexion * conn, time_t * time )
|
||||
printlog(conn->user, DEBUG, 0);
|
||||
sprintf(conn->hostname, "%s", utmp->ut_host); //got ip of origin
|
||||
printlog(conn->hostname, DEBUG, 0);
|
||||
if((utmp->ut_addr_v6[1] || utmp->ut_addr_v6[2] || utmp->ut_addr_v6[3]) == 0)
|
||||
if(utmp->ut_addr_v6[1] == 0)
|
||||
{
|
||||
ipv4 = utmp->ut_addr_v6[0] & 0x00000000000000ff;
|
||||
sprintf( str, "%d.", ipv4);
|
||||
@ -586,7 +587,7 @@ int main()
|
||||
r = isinarray(pid, childrens, n_pid);
|
||||
if( r == 0 )
|
||||
{
|
||||
conn.user[0]='\0';
|
||||
//conn.user[0]='\0';
|
||||
conn.pid=pid;
|
||||
rinfo = getprocinfo( &conn );
|
||||
if( rinfo == 0 )
|
||||
@ -655,15 +656,18 @@ int main()
|
||||
{
|
||||
time( &now );
|
||||
sprintf( date, "%s", frtime(now) );
|
||||
sprintf(strlog, "%s: Session %d de %s terminée\n", date, connexions[i].pid, connexions[i].user );
|
||||
printlog(strlog, INFO, 0);
|
||||
sprintf(strlog, "%s: %s - pid %d - Connexion de %s terminée", connexions[i].date, cfg.hostname, connexions[i].pid, connexions[i].user);
|
||||
sprintf(strlog, "Session %d de %s terminée\n", connexions[i].pid, connexions[i].user );
|
||||
printlog(strlog, INFO, 0);
|
||||
//sprintf(strlog, "%s: %s - pid %d - Connexion de %s terminée", connexions[i].date, cfg.hostname, connexions[i].pid, connexions[i].user);
|
||||
//printlog(strlog, INFO, 0);
|
||||
for( j=i; j<n_pid; j++ )
|
||||
{
|
||||
childrens[j] = childrens[j+1];
|
||||
connexions[j] = connexions[j+1];
|
||||
flag[j] = flag[j+1];
|
||||
}
|
||||
childrens[n_pid] = 0;
|
||||
flag[n_pid] = 0;
|
||||
i--;
|
||||
n_pid--;
|
||||
}else
|
||||
|
Reference in New Issue
Block a user