diff --git a/main.c b/main.c index 87efc77..16e54a4 100644 --- a/main.c +++ b/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