summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-06-01 09:11:18 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-06-01 09:11:18 +0200
commit0f1808aad1a0be91d4cc2cd9ddfc6e2c0cf2590f (patch)
treef01740d300c0d97ee2c721c133d8a74c9223f978 /runtime
parent21307645db3b938982b5d2b7b6f48648f62e77e5 (diff)
downloadrsyslog-0f1808aad1a0be91d4cc2cd9ddfc6e2c0cf2590f.tar.gz
rsyslog-0f1808aad1a0be91d4cc2cd9ddfc6e2c0cf2590f.tar.xz
rsyslog-0f1808aad1a0be91d4cc2cd9ddfc6e2c0cf2590f.zip
cleaned-up umask handling
Diffstat (limited to 'runtime')
-rw-r--r--runtime/rsconf.c31
-rw-r--r--runtime/rsconf.h1
2 files changed, 18 insertions, 14 deletions
diff --git a/runtime/rsconf.c b/runtime/rsconf.c
index ed6e9ee7..cb76e6da 100644
--- a/runtime/rsconf.c
+++ b/runtime/rsconf.c
@@ -101,6 +101,7 @@ BEGINobjConstruct(rsconf) /* be sure to specify the object type also in END macr
pThis->globals.bDebugPrintCfSysLineHandlerList = 1;
pThis->globals.bLogStatusMsgs = DFLT_bLogStatusMsgs;
pThis->globals.bErrMsgToStderr = 1;
+ pThis->globals.umask = -1;
pThis->templates.root = NULL;
pThis->templates.last = NULL;
pThis->templates.lastStatic = NULL;
@@ -475,6 +476,19 @@ finalize_it:
}
+/* set the processes umask (upon configuration request) */
+static inline rsRetVal
+setUmask(int iUmask)
+{
+ if(iUmask != -1) {
+ umask(iUmask);
+ DBGPRINTF("umask set to 0%3.3o.\n", iUmask);
+ }
+
+ return RS_RET_OK;
+}
+
+
/* Activate an already-loaded configuration. The configuration will become
* the new running conf (if successful). Note that in theory this method may
* be called when there already is a running conf. In practice, the current
@@ -495,6 +509,7 @@ activate(rsconf_t *cnf)
generateConfigDAG(ourConf->globals.pszConfDAGFile);
# endif
tellModulesConfigLoadDone();
+ setUmask(cnf->globals.umask);
tellModulesCheckConfig();
/* the output part and the queue is now ready to run. So it is a good time
@@ -547,18 +562,6 @@ doIncludeLine(void *pVal, uchar *pNewVal)
}
-/* set the processes umask (upon configuration request) */
-static rsRetVal
-setUmask(void __attribute__((unused)) *pVal, int iUmask)
-{
-#warning this *really* needs to be done differently!
- umask(iUmask);
- DBGPRINTF("umask set to 0%3.3o.\n", iUmask);
-
- return RS_RET_OK;
-}
-
-
/* set the maximum message size */
static rsRetVal setMaxMsgSize(void __attribute__((unused)) *pVal, long iNewVal)
{
@@ -828,6 +831,8 @@ initLegacyConf(void)
NULL, &loadConf->globals.gidDropPriv, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"generateconfiggraph", 0, eCmdHdlrGetWord,
NULL, &loadConf->globals.pszConfDAGFile, NULL, eConfObjGlobal));
+ CHKiRet(regCfSysLineHdlr((uchar *)"umask", 0, eCmdHdlrFileCreateMode,
+ NULL, &loadConf->globals.umask, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"maxopenfiles", 0, eCmdHdlrInt,
setMaxFiles, NULL, NULL, eConfObjGlobal));
@@ -837,8 +842,6 @@ initLegacyConf(void)
conf.doModLoad, NULL, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"includeconfig", 0, eCmdHdlrCustomHandler,
doIncludeLine, NULL, NULL, eConfObjGlobal));
- CHKiRet(regCfSysLineHdlr((uchar *)"umask", 0, eCmdHdlrFileCreateMode,
- setUmask, NULL, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"maxmessagesize", 0, eCmdHdlrSize,
setMaxMsgSize, NULL, NULL, eConfObjGlobal));
CHKiRet(regCfSysLineHdlr((uchar *)"defaultruleset", 0, eCmdHdlrGetWord,
diff --git a/runtime/rsconf.h b/runtime/rsconf.h
index e26b1df6..8715cf1b 100644
--- a/runtime/rsconf.h
+++ b/runtime/rsconf.h
@@ -69,6 +69,7 @@ struct globals_s {
config) if there was any issue in conf */
int uidDropPriv; /* user-id to which priveleges should be dropped to */
int gidDropPriv; /* group-id to which priveleges should be dropped to */
+ int umask; /* umask to use */
uchar *pszConfDAGFile; /* name of config DAG file, non-NULL means generate one */
// TODO are the following ones defaults?