[BB#74] Create log and pid files after we drop privs
This commit is contained in:
		
							parent
							
								
									56257d3da3
								
							
						
					
					
						commit
						691415a8f9
					
				
							
								
								
									
										26
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/main.c
									
									
									
									
									
								
							@ -394,10 +394,6 @@ main (int argc, char **argv)
 | 
				
			|||||||
                exit (EX_SOFTWARE);
 | 
					                exit (EX_SOFTWARE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (setup_logging ()) {
 | 
					 | 
				
			||||||
                exit (EX_SOFTWARE);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        init_stats ();
 | 
					        init_stats ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* If ANONYMOUS is turned on, make sure that Content-Length is
 | 
					        /* If ANONYMOUS is turned on, make sure that Content-Length is
 | 
				
			||||||
@ -412,14 +408,6 @@ main (int argc, char **argv)
 | 
				
			|||||||
        if (config.godaemon == TRUE)
 | 
					        if (config.godaemon == TRUE)
 | 
				
			||||||
                makedaemon ();
 | 
					                makedaemon ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (config.pidpath) {
 | 
					 | 
				
			||||||
                if (pidfile_create (config.pidpath) < 0) {
 | 
					 | 
				
			||||||
                        fprintf (stderr, "%s: Could not create PID file.\n",
 | 
					 | 
				
			||||||
                                 argv[0]);
 | 
					 | 
				
			||||||
                        exit (EX_OSERR);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (set_signal_handler (SIGPIPE, SIG_IGN) == SIG_ERR) {
 | 
					        if (set_signal_handler (SIGPIPE, SIG_IGN) == SIG_ERR) {
 | 
				
			||||||
                fprintf (stderr, "%s: Could not set the \"SIGPIPE\" signal.\n",
 | 
					                fprintf (stderr, "%s: Could not set the \"SIGPIPE\" signal.\n",
 | 
				
			||||||
                         argv[0]);
 | 
					                         argv[0]);
 | 
				
			||||||
@ -445,6 +433,20 @@ main (int argc, char **argv)
 | 
				
			|||||||
                log_message (LOG_WARNING,
 | 
					                log_message (LOG_WARNING,
 | 
				
			||||||
                             "Not running as root, so not changing UID/GID.");
 | 
					                             "Not running as root, so not changing UID/GID.");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* Create log file after we drop privileges */
 | 
				
			||||||
 | 
					        if (setup_logging ()) {
 | 
				
			||||||
 | 
					                exit (EX_SOFTWARE);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        /* Create pid file after we drop privileges */
 | 
				
			||||||
 | 
					        if (config.pidpath) {
 | 
				
			||||||
 | 
					                if (pidfile_create (config.pidpath) < 0) {
 | 
				
			||||||
 | 
					                        fprintf (stderr, "%s: Could not create PID file.\n",
 | 
				
			||||||
 | 
					                                 argv[0]);
 | 
				
			||||||
 | 
					                        exit (EX_OSERR);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (child_pool_create () < 0) {
 | 
					        if (child_pool_create () < 0) {
 | 
				
			||||||
                fprintf (stderr,
 | 
					                fprintf (stderr,
 | 
				
			||||||
                         "%s: Could not create the pool of children.\n",
 | 
					                         "%s: Could not create the pool of children.\n",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user