Environment patch
This commit is contained in:
parent
db29b72ede
commit
d010e16b15
@ -54,6 +54,9 @@ const char *BFERR[] = {
|
|||||||
/* 27 */ "Unused entry"
|
/* 27 */ "Unused entry"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Main environment on startup (copied) for external processes */
|
||||||
|
char ** mainenv;
|
||||||
|
|
||||||
static void deinit_opts(s_bforce_opts *opts);
|
static void deinit_opts(s_bforce_opts *opts);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -253,9 +256,25 @@ int main(int argc, char *argv[], char *envp[])
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
opts.runmode = MODE_UNDEFINED;
|
opts.runmode = MODE_UNDEFINED;
|
||||||
|
int i = 0;
|
||||||
|
int argsz = 0;
|
||||||
|
|
||||||
memset(&opts, '\0', sizeof(s_bforce_opts));
|
memset(&opts, '\0', sizeof(s_bforce_opts));
|
||||||
|
|
||||||
|
// Copying environment
|
||||||
|
argsz = 4096;
|
||||||
|
//argsz = sysconf(_SC_ARG_MAX);
|
||||||
|
DEB((D_CONFIG, "Limits: %d\n",argsz));
|
||||||
|
mainenv = malloc(sizeof(mainenv)*argsz);
|
||||||
|
mainenv[0] = NULL;
|
||||||
|
i=0;
|
||||||
|
while (envp[i]) {
|
||||||
|
mainenv[i] = malloc(strlen(envp[i])+2);
|
||||||
|
strcpy(mainenv[i], envp[i]);
|
||||||
|
mainenv[i++] = NULL;
|
||||||
|
DEB((D_FREE, "Program ENV: %s\n", mainenv[(i-1)]));
|
||||||
|
}
|
||||||
|
|
||||||
// parsing
|
// parsing
|
||||||
|
|
||||||
while( (ch=getopt(argc, argv, "hfI:p:n:l:a:u:oivC:S:dq")) != (int)-1 )
|
while( (ch=getopt(argc, argv, "hfI:p:n:l:a:u:oivC:S:dq")) != (int)-1 )
|
||||||
@ -488,6 +507,15 @@ default:
|
|||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
||||||
|
/* de-init sessenv */
|
||||||
|
i=0;
|
||||||
|
while(mainenv[i]) {
|
||||||
|
DEB((D_FREE, "De-init session ENV: %s\n", mainenv[(i)]));
|
||||||
|
free(mainenv[i]);
|
||||||
|
}
|
||||||
|
free(mainenv);
|
||||||
|
|
||||||
|
|
||||||
deinit_conf();
|
deinit_conf();
|
||||||
deinit_opts(&opts);
|
deinit_opts(&opts);
|
||||||
|
|
||||||
|
@ -73,9 +73,16 @@ int exec_options_parse(char *str)
|
|||||||
|
|
||||||
void exec_options_init(s_exec_options *eopt)
|
void exec_options_init(s_exec_options *eopt)
|
||||||
{
|
{
|
||||||
|
int i = 0;
|
||||||
memset(eopt, '\0', sizeof(s_exec_options));
|
memset(eopt, '\0', sizeof(s_exec_options));
|
||||||
eopt->umask = EXEC_DEFAULT_UMASK;
|
eopt->umask = EXEC_DEFAULT_UMASK;
|
||||||
eopt->envp[0] = NULL;
|
eopt->envp[0] = NULL;
|
||||||
|
while(mainenv[i]) {
|
||||||
|
log("EXEC: Added ENV variable: %s\n", mainenv[i]);
|
||||||
|
eopt->envp[i] = xmalloc(strlen(mainenv[i]) + 2);
|
||||||
|
sprintf(eopt->envp[i], mainenv[i++]);
|
||||||
|
eopt->envp[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exec_options_deinit(s_exec_options *eopt)
|
void exec_options_deinit(s_exec_options *eopt)
|
||||||
|
@ -183,4 +183,6 @@ extern const char *BFERR[];
|
|||||||
|
|
||||||
int daemon_run(const char *confname, const char *incname, bool quit);
|
int daemon_run(const char *confname, const char *incname, bool quit);
|
||||||
|
|
||||||
|
extern char ** mainenv;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user