int reload(struct conf **confs, const char *conffile, bool firsttime) { if(!firsttime) logp("Reloading config\n"); if(confs_init(confs)) return -1; if(conf_load_global_only(conffile, confs)) return -1; umask(get_mode_t(confs[OPT_UMASK])); // This will turn on syslogging which could not be turned on before // conf_load. log_fzp_set(NULL, confs); #ifndef HAVE_WIN32 if(get_e_burp_mode(confs[OPT_BURP_MODE])==BURP_MODE_SERVER) setup_signals(); #endif // Do not try to change user or group after the first time. if(firsttime && chuser_and_or_chgrp( get_string(confs[OPT_USER]), get_string(confs[OPT_GROUP]))) return -1; return 0; }
int reload(struct conf *conf, const char *conffile, bool firsttime, int oldmax_children, int oldmax_status_children, int json) { if(!firsttime) logp("Reloading config\n"); conf_init(conf); if(conf_load(conffile, conf, 1)) return 1; /* change umask */ umask(conf->umask); // Try to make JSON output clean. if(json) conf->log_to_stdout=0; // This will turn on syslogging which could not be turned on before // conf_load. set_logfp(NULL, conf); #ifndef HAVE_WIN32 if(conf->mode==MODE_SERVER) setup_signals(oldmax_children, conf->max_children, oldmax_status_children, conf->max_status_children); #endif // Do not try to change user or group after the first time. if(firsttime && chuser_and_or_chgrp(conf)) return 1; return 0; }
int reload(struct config *conf, const char *configfile, bool firsttime, int oldmax_children, int oldmax_status_children) { if(!firsttime) logp("Reloading config\n"); init_config(conf); if(load_config(configfile, conf, TRUE)) return 1; /* change umask */ umask(conf->umask); // This will turn on syslogging which could not be turned on before // load_config. set_logfp(NULL, conf); #ifndef HAVE_WIN32 if(conf->mode==MODE_SERVER) setup_signals(oldmax_children, conf->max_children, oldmax_status_children, conf->max_status_children); #endif // Do not try to change user or group after the first time. if(firsttime && chuser_and_or_chgrp(conf->user, conf->group)) return 1; return 0; }
int child(struct async *as, int is_status_server, int status_wfd, struct conf **confs, struct conf **cconfs) { int ret=-1; int srestore=0; int timer_ret=0; char *incexc=NULL; const char *confs_user; const char *cconfs_user; const char *confs_group; const char *cconfs_group; const char *s_script_pre; const char *s_script_post; // If we are not a status server, we are a normal child - set up the // parent socket to write status to. if(status_wfd>0) { if(!(wasfd=setup_asfd(as, "child status pipe", &status_wfd))) goto end; wasfd->attempt_reads=0; } /* Has to be before the chuser/chgrp stuff to allow clients to switch to different clients when both clients have different user/group settings. */ if(extra_comms(as, &incexc, &srestore, confs, cconfs)) { log_and_send(as->asfd, "running extra comms failed on server"); goto end; } // Needs to happen after extra_comms, in case extra_comms resets them. confs_user=get_string(confs[OPT_USER]); cconfs_user=get_string(cconfs[OPT_USER]); confs_group=get_string(confs[OPT_GROUP]); cconfs_group=get_string(cconfs[OPT_GROUP]); /* Now that the client conf is loaded, we might want to chuser or chgrp. The main process could have already done this, so we don't want to try doing it again if cconfs has the same values, because it will fail. */ if( (!confs_user || (cconfs_user && strcmp(confs_user, cconfs_user))) ||(!confs_group ||(cconfs_group && strcmp(confs_group,cconfs_group)))) { if(chuser_and_or_chgrp(cconfs_user, cconfs_group)) { log_and_send(as->asfd, "chuser_and_or_chgrp failed on server"); goto end; } } if(as->asfd->read(as->asfd)) goto end; // If this is a status server, run the status server. if(is_status_server) { ret=status_server(as, cconfs); goto end; } ret=0; s_script_pre=get_string(cconfs[OPT_S_SCRIPT_PRE]); s_script_post=get_string(cconfs[OPT_S_SCRIPT_POST]); // FIX THIS: Make the script components part of a struct, and just // pass in the correct struct. Same below. if(s_script_pre) ret=run_server_script(as->asfd, "pre", s_script_pre, get_strlist(cconfs[OPT_S_SCRIPT_PRE_ARG]), get_int(cconfs[OPT_S_SCRIPT_PRE_NOTIFY]), cconfs, ret, timer_ret); if(!ret) ret=run_action_server(as, incexc, srestore, &timer_ret, cconfs); if((!ret || get_int(cconfs[OPT_S_SCRIPT_POST_RUN_ON_FAIL])) && s_script_post) ret=run_server_script(as->asfd, "post", s_script_post, get_strlist(cconfs[OPT_S_SCRIPT_POST_ARG]), get_int(cconfs[OPT_S_SCRIPT_POST_NOTIFY]), cconfs, ret, timer_ret); end: return ret; }