|
|
|
@ -20,6 +20,8 @@
|
|
|
|
|
#include "nodelist.h"
|
|
|
|
|
#include "session.h"
|
|
|
|
|
|
|
|
|
|
char ** sessenv;
|
|
|
|
|
|
|
|
|
|
/* PID of our child process (if use fork) */
|
|
|
|
|
pid_t child_pid = 0;
|
|
|
|
|
|
|
|
|
@ -254,6 +256,10 @@ int main(int argc, char *argv[], char *envp[])
|
|
|
|
|
int ch = 0;
|
|
|
|
|
opts.runmode = MODE_UNDEFINED;
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
int argsz = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(&opts, '\0', sizeof(s_bforce_opts));
|
|
|
|
|
|
|
|
|
|
// parsing
|
|
|
|
@ -453,7 +459,7 @@ int main(int argc, char *argv[], char *envp[])
|
|
|
|
|
/* Reopen log file if it was defined in config */
|
|
|
|
|
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
|
|
|
|
|
{
|
|
|
|
|
log("can't continue without logging");
|
|
|
|
|
DEB((D_CONFIG, "can't continue without logging"));
|
|
|
|
|
gotoexit(BFERR_FATALERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -461,6 +467,21 @@ int main(int argc, char *argv[], char *envp[])
|
|
|
|
|
//snprintf(runmode_str, 20, "Run mode: %d", opts.runmode);
|
|
|
|
|
//log(runmode_str);
|
|
|
|
|
|
|
|
|
|
/* Init environment table for childs */
|
|
|
|
|
argsz = 4096;
|
|
|
|
|
//argsz = sysconf(_SC_ARG_MAX);
|
|
|
|
|
DEB((D_CONFIG, "Limits: %d\n",argsz));
|
|
|
|
|
sessenv = malloc(sizeof(sessenv)*argsz);
|
|
|
|
|
sessenv[0] = NULL;
|
|
|
|
|
i=0;
|
|
|
|
|
while (envp[i]) {
|
|
|
|
|
sessenv[i] = malloc(strlen(envp[i])+2);
|
|
|
|
|
strcpy(sessenv[i], envp[i]);
|
|
|
|
|
sessenv[i++] = NULL;
|
|
|
|
|
DEB((D_FREE, "session ENV: %s\n", sessenv[(i-1)]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch( opts.runmode )
|
|
|
|
|
{
|
|
|
|
|
case MODE_DAEMON:
|
|
|
|
@ -488,6 +509,14 @@ default:
|
|
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
|
|
|
|
|
/* de-init sessenv */
|
|
|
|
|
i=0;
|
|
|
|
|
while(sessenv[i]) {
|
|
|
|
|
DEB((D_FREE, "De-init session ENV: %s\n", sessenv[(i)]));
|
|
|
|
|
free(sessenv[i]);
|
|
|
|
|
}
|
|
|
|
|
free(sessenv);
|
|
|
|
|
|
|
|
|
|
deinit_conf();
|
|
|
|
|
deinit_opts(&opts);
|
|
|
|
|
|
|
|
|
|