Andreas Schneider wrote: > Hi, > > this code has been only changed in dspam and not in dspamc. To fix this we > have created a new function which initializes the variables in agent_shared.c > where they are used.
Sorry wrong patch attached. :) -- andreas -- http://www.cynapses.org/ - cybernetic synapses
Index: src/dspamc.c =================================================================== --- src/dspamc.c.orig +++ src/dspamc.c @@ -99,6 +99,7 @@ main (int argc, char *argv[]) int exitcode = EXIT_SUCCESS; buffer *message = NULL; /* input Message */ int agent_init = 0; /* agent is initialized */ + struct passwd *pwent; setbuf (stdout, NULL); /* unbuffered output */ #ifdef DEBUG @@ -113,6 +114,14 @@ main (int argc, char *argv[]) exit(EXIT_FAILURE); #endif + /* Cache my username and uid for trusted user security */ + + if (!init_pwent_cache()) { + LOG(LOG_ERR, ERR_AGENT_RUNTIME_USER); + exitcode = EXIT_FAILURE; + goto BAIL; + } + /* Read dspam.conf into global config structure (ds_config_t) */ agent_config = read_config(NULL); Index: src/agent_shared.c =================================================================== --- src/agent_shared.c.orig +++ src/agent_shared.c @@ -913,3 +913,18 @@ int process_parseto(AGENT_CTX *ATX, cons return 0; } + +int +init_pwent_cache() +{ + struct passwd *pwent; + pwent = getpwuid(getuid()); + if (pwent == NULL) { + return 0; + } + else { + __pw_name = strdup(pwent->pw_name); + __pw_uid = pwent->pw_uid; + } + return 1; +} Index: src/agent_shared.h =================================================================== --- src/agent_shared.h.orig +++ src/agent_shared.h @@ -107,6 +107,8 @@ int initialize_atx (AGENT_CTX *ATX) int process_parseto (AGENT_CTX *ATX, const char *buf); buffer *read_stdin (AGENT_CTX *ATX); +int init_pwent_cache(); + #ifndef MIN # define MAX(a,b) ((a)>(b)?(a):(b)) # define MIN(a,b) ((a)<(b)?(a):(b)) Index: src/dspam.c =================================================================== --- src/dspam.c.orig +++ src/dspam.c @@ -108,7 +108,6 @@ main (int argc, char *argv[]) int exitcode = EXIT_SUCCESS; struct nt_node *node_nt; struct nt_c c_nt; - struct passwd *pwent; srand ((long) time << (long) getpid ()); umask (006); /* rw-rw---- */ @@ -123,14 +122,11 @@ main (int argc, char *argv[]) /* Cache my username and uid for trusted user security */ - pwent = getpwuid(getuid()); - if (pwent == NULL) { + if (!init_pwent_cache()) { LOG(LOG_ERR, ERR_AGENT_RUNTIME_USER); exitcode = EXIT_FAILURE; goto BAIL; } - __pw_name = strdup(pwent->pw_name); - __pw_uid = pwent->pw_uid; /* Read dspam.conf into global config structure (ds_config_t) */
signature.asc
Description: OpenPGP digital signature