debug
This commit is contained in:
parent
1b27bccac5
commit
a0202ec99a
20
main.c
20
main.c
@ -7,6 +7,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <utmp.h>
|
||||
#include <locale.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#define HOSTNAME "lalis"
|
||||
|
||||
@ -152,7 +153,8 @@ int getpids(int pid, int exploded[])
|
||||
{
|
||||
exploded[x++] = atoi( pch );
|
||||
pch = strtok( NULL , separator );
|
||||
}// char path[1024];
|
||||
printf("%s\n", pch);
|
||||
}
|
||||
|
||||
fclose(fh);
|
||||
return x;
|
||||
@ -262,6 +264,20 @@ int main()
|
||||
struct connexion conn;
|
||||
struct connexion connexions[n_ssh];
|
||||
//char * ptr;
|
||||
|
||||
if ( (fh = fopen(logfile, "a")) == NULL)
|
||||
{
|
||||
perror(logfile);
|
||||
buff = basename(logfile);
|
||||
sprintf( logfile, "%s%s", "~/.local/share/", buff);
|
||||
if( (fh = fopen(logfile, "a")))
|
||||
{
|
||||
perror(logfile);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
buff = getenv("HOSTNAME");
|
||||
if ( buff != NULL)
|
||||
{
|
||||
@ -393,7 +409,7 @@ int main()
|
||||
perror(logfile);
|
||||
return 7;
|
||||
}
|
||||
fprintf(fh1, "%s: Connexion de %s terminée le %", hostname, connexions[i].date);
|
||||
fprintf(fh1, "%s: pid %d -Connexion de %s terminée le %s\n", hostname, connexions[i].pid, connexions[i].user, connexions[i].date);
|
||||
for( j=i; j<x; j++ )
|
||||
{
|
||||
childrens[j] = childrens[j+1];
|
||||
|
19
sshdetect.service
Normal file
19
sshdetect.service
Normal file
@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=ssh connexion detect Daemon
|
||||
After=sshd.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
User=daemon
|
||||
Group=daemon
|
||||
|
||||
ExecStart=/usr/bin/sshdetect
|
||||
|
||||
Restart=always
|
||||
|
||||
# Configures the time to wait before service is stopped forcefully.
|
||||
TimeoutStopSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in New Issue
Block a user