File tree Expand file tree Collapse file tree 5 files changed +22
-23
lines changed Expand file tree Collapse file tree 5 files changed +22
-23
lines changed Original file line number Diff line number Diff line change @@ -165,15 +165,15 @@ parse_commandline(int argc, char **argv)
165
165
exit (1 );
166
166
}
167
167
break ;
168
- case 'p' :
169
- if (optarg ) {
170
- config -> save_pid = 1 ;
171
- strncpy ( config -> pidfile , optarg , sizeof ( config -> pidfile ) );
172
- } else {
173
- fprintf (stdout , "The expected PID file path to the wifidog was not supplied!\n" );
174
- exit (1 );
175
- }
176
- break ;
168
+ case 'p' :
169
+ if (optarg ) {
170
+ free ( config -> pidfile ) ;
171
+ config -> pidfile = safe_strdup ( optarg );
172
+ } else {
173
+ fprintf (stdout , "The expected PID file path to the wifidog was not supplied!\n" );
174
+ exit (1 );
175
+ }
176
+ break ;
177
177
default :
178
178
usage ();
179
179
exit (1 );
Original file line number Diff line number Diff line change @@ -162,8 +162,7 @@ typedef struct {
162
162
char * internal_sock ; /**< @brief internal path to socket */
163
163
int deltatraffic ; /**< @brief reset each user's traffic (Outgoing and Incoming) value after each Auth operation. */
164
164
int daemon ; /**< @brief if daemon > 0, use daemon mode */
165
- int save_pid ; /**< @brief if save_pid == 1, save the pid in file */
166
- char pidfile [255 ]; /**< @brief pid file path of wifidog */
165
+ char * pidfile ; /**< @brief pid file path of wifidog */
167
166
char * external_interface ; /**< @brief External network interface name for
168
167
firewall rules */
169
168
char * gw_id ; /**< @brief ID of the Gateway, sent to central
Original file line number Diff line number Diff line change @@ -367,8 +367,8 @@ main_loop(void)
367
367
}
368
368
369
369
/* save the pid file if needed */
370
- if (config -> save_pid )
371
- save_pid_file (config -> pidfile );
370
+ if ((! config ) && (! config -> pidfile ) )
371
+ save_pid_file (config -> pidfile );
372
372
373
373
/* If we don't have the Gateway IP address, get it. Can't fail. */
374
374
if (!config -> gw_address ) {
Original file line number Diff line number Diff line change @@ -397,13 +397,13 @@ rand16(void)
397
397
void
398
398
save_pid_file (const char * pf )
399
399
{
400
- if (pf ) {
401
- FILE * f = fopen (pf , "w" );
402
- if (f ) {
403
- fprintf (f , "%lu \n" , getpid ());
404
- fclose (f );
405
- }
406
- }
407
-
408
- return ;
400
+ if (pf ) {
401
+ FILE * f = fopen (pf , "w" );
402
+ if (f ) {
403
+ fprintf (f , "%zu \n" , getpid ());
404
+ fclose (f );
405
+ }
406
+ }
407
+
408
+ return ;
409
409
}
Original file line number Diff line number Diff line change @@ -59,6 +59,6 @@ void close_icmp_socket(void);
59
59
void icmp_ping (const char * );
60
60
61
61
/** @brief Save pid of this wifidog in pid file */
62
- void save_pid_file (const char * pf );
62
+ void save_pid_file (const char * );
63
63
64
64
#endif /* _UTIL_H_ */
You can’t perform that action at this time.
0 commit comments