From a0202ec99ad56e58c58f44ab9464a76ae4e7a91d Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sat, 9 May 2020 14:24:55 +0200 Subject: [PATCH] debug --- main.c | 20 ++++++++++++++++++-- sshdetect.service | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 sshdetect.service diff --git a/main.c b/main.c index ffa9115..21fcc8d 100644 --- a/main.c +++ b/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #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