Browse Source

debug of systemd service and logfile search

Daniel Tartavel 11 months ago
parent
commit
104539f763
2 changed files with 6 additions and 5 deletions
  1. 5 1
      main.c
  2. 1 4
      sshdetect.service

+ 5 - 1
main.c

@@ -140,6 +140,7 @@ int readconfig( struct config * cfg )
140 140
 			strcpy(cfg->logfile, "/dev/null");
141 141
 			retval += 2;
142 142
 		}
143
+		printf("logfile not found, defaulting to %s\n", cfg->logfile);
143 144
 	}
144 145
 	if (cfg->hostname[0] == 0 )
145 146
 	{
@@ -151,16 +152,18 @@ int readconfig( struct config * cfg )
151 152
 		{
152 153
 			strcpy(cfg->hostname, HOSTNAME);
153 154
 		}
155
+		printf("hostname not found, defaulting to %s\n", cfg->hostname);
154 156
 	}
155 157
 	if (cfg->commande[0] == 0)
156 158
 	{
157
-		if (debug >=1) printf("command not found in config file: no command will be executed\n");
159
+		printf("command not found in config file: no command will be executed\n");
158 160
 		retval += 4;
159 161
 	}
160 162
 	return retval;
161 163
 }
162 164
 
163 165
 //test if pid is in list of known sshd processus
166
+// return number of pid
164 167
 int isinarray( int pid, int array[], int n )
165 168
 {
166 169
 	int x;
@@ -174,6 +177,7 @@ int isinarray( int pid, int array[], int n )
174 177
 	return 0;
175 178
 }
176 179
 
180
+// return date in localized format
177 181
 char* frtime(const time_t timet)
178 182
 {
179 183
 	struct tm *date_tm;

+ 1 - 4
sshdetect.service

@@ -4,10 +4,7 @@ After=sshd.service
4 4
 
5 5
 [Service]
6 6
 Type=simple
7
-
8
-User=daemon
9
-Group=daemon
10
-
7
+WorkingDirectory=/root
11 8
 ExecStart=/usr/bin/sshdetect
12 9
 
13 10
 Restart=always