diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-05-06 10:06:32 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-05-06 10:06:32 +0200 |
commit | ff2bb192f2c566f189a9d104d83d7a70c7888774 (patch) | |
tree | 7737c436f7f3ed611535879654d59e672cfd69c3 /runtime/rsconf.c | |
parent | b056c258d7bab528034ec8c8749cdcf0d0102268 (diff) | |
download | rsyslog-ff2bb192f2c566f189a9d104d83d7a70c7888774.tar.gz rsyslog-ff2bb192f2c566f189a9d104d83d7a70c7888774.tar.xz rsyslog-ff2bb192f2c566f189a9d104d83d7a70c7888774.zip |
step: conf interface now natively supports priv drop
Diffstat (limited to 'runtime/rsconf.c')
-rw-r--r-- | runtime/rsconf.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/runtime/rsconf.c b/runtime/rsconf.c index 92c17b5c..94190d76 100644 --- a/runtime/rsconf.c +++ b/runtime/rsconf.c @@ -296,7 +296,7 @@ dropPrivileges(rsconf_t *cnf) /* Tell input modules that the config parsing stage is over. */ static rsRetVal -tellInputsConfigLoadDone(void) +tellModulesConfigLoadDone(void) { cfgmodules_etry_t *node; @@ -316,7 +316,7 @@ tellInputsConfigLoadDone(void) /* Tell input modules to verify config object */ static rsRetVal -tellInputsCheckConfig(void) +tellModulesCheckConfig(void) { cfgmodules_etry_t *node; rsRetVal localRet; @@ -343,9 +343,40 @@ tellInputsCheckConfig(void) } -/* Tell input modules to activate current running config */ +/* Tell modules to activate current running config (pre privilege drop) */ static rsRetVal -tellInputsActivateConfig(void) +tellModulesActivateConfigPrePrivDrop(void) +{ + cfgmodules_etry_t *node; + rsRetVal localRet; + + BEGINfunc + DBGPRINTF("telling modules to activate config (before dropping privs) %p\n", runConf); + node = module.GetNxtCnfType(runConf, NULL, eMOD_ANY); + while(node != NULL) { + if( node->pMod->beginCnfLoad != NULL + && node->pMod->activateCnfPrePrivDrop != NULL + && node->canActivate) { + DBGPRINTF("activating config %p for module %s\n", + runConf, node->pMod->pszName); + localRet = node->pMod->activateCnfPrePrivDrop(node->modCnf); + if(localRet != RS_RET_OK) { + errmsg.LogError(0, localRet, "activation of module %s failed", + node->pMod->pszName); + node->canActivate = 0; /* in a sense, could not activate... */ + } + } + node = module.GetNxtCnfType(runConf, node, eMOD_IN); + } + + ENDfunc + return RS_RET_OK; /* intentional: we do not care about module errors */ +} + + +/* Tell modules to activate current running config */ +static rsRetVal +tellModulesActivateConfig(void) { cfgmodules_etry_t *node; rsRetVal localRet; @@ -398,7 +429,7 @@ runInputModules(void) } -/* Make the input modules check if they are ready to start. +/* Make the modules check if they are ready to start. */ static rsRetVal startInputModules(void) @@ -463,8 +494,8 @@ activate(rsconf_t *cnf) if(ourConf->globals.pszConfDAGFile != NULL) generateConfigDAG(ourConf->globals.pszConfDAGFile); # endif - tellInputsConfigLoadDone(); - tellInputsCheckConfig(); + tellModulesConfigLoadDone(); + tellModulesCheckConfig(); /* the output part and the queue is now ready to run. So it is a good time * to initialize the inputs. Please note that the net code above should be @@ -474,11 +505,12 @@ activate(rsconf_t *cnf) * Keep in mind. though, that the outputs already run if the queue was * persisted to disk. -- rgerhards */ - tellInputsActivateConfig(); - startInputModules(); + tellModulesActivateConfigPrePrivDrop(); CHKiRet(dropPrivileges(cnf)); + tellModulesActivateConfig(); + startInputModules(); CHKiRet(activateActions()); CHKiRet(activateMainQueue()); /* finally let the inputs run... */ |