diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/log.c | 24 | ||||
| -rw-r--r-- | src/main.c | 5 | 
2 files changed, 6 insertions, 23 deletions
@@ -33,17 +33,7 @@  int init_log(void)  {  	if (CONFIG(logfile)[0]) { -		int fd; -		 -		fd = open(CONFIG(logfile), O_CREAT | O_RDWR, 0600); -		if (fd == -1) { -			fprintf(stderr, "ERROR: can't open logfile `%s'." -				"Reason: %s\n", CONFIG(logfile),  -						strerror(errno)); -			return -1; -		} - -		STATE(log) = fdopen(fd, "a+"); +		STATE(log) = fopen(CONFIG(logfile), "a+");  		if (STATE(log) == NULL) {  			fprintf(stderr, "ERROR: can't open logfile `%s'."  				"Reason: %s\n", CONFIG(logfile),  @@ -53,17 +43,7 @@ int init_log(void)  	}  	if (CONFIG(stats).logfile[0]) { -		int fd; -		 -		fd = open(CONFIG(stats).logfile, O_CREAT | O_RDWR, 0600); -		if (fd == -1) { -			fprintf(stderr, "ERROR: can't open logfile `%s'." -				"Reason: %s\n", CONFIG(stats).logfile,  -						strerror(errno)); -			return -1; -		} - -		STATE(stats_log) = fdopen(fd, "a+"); +		STATE(stats_log) = fopen(CONFIG(stats).logfile, "a+");  		if (STATE(stats_log) == NULL) {  			fprintf(stderr, "ERROR: can't open logfile `%s'."  				"Reason: %s\n", CONFIG(stats).logfile,  @@ -239,6 +239,8 @@ int main(int argc, char *argv[])  	if (config_set == 0)  		strcpy(config_file, DEFAULT_CONFIGFILE); +	umask(0177); +  	if ((ret = init_config(config_file)) == -1) {  		fprintf(stderr, "can't open config file `%s'\n", config_file);  		exit(EXIT_FAILURE); @@ -262,7 +264,8 @@ int main(int argc, char *argv[])  	/*  	 * lock file  	 */ -	if ((ret = open(CONFIG(lockfile), O_CREAT | O_EXCL | O_TRUNC)) == -1) { +	ret = open(CONFIG(lockfile), O_CREAT | O_EXCL | O_TRUNC, 0600); +	if (ret == -1) {  		fprintf(stderr, "lockfile `%s' exists, perhaps conntrackd "  			        "already running?\n", CONFIG(lockfile));  		exit(EXIT_FAILURE);  | 
