summaryrefslogtreecommitdiffstats
path: root/srUtils.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-17 12:53:50 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-17 12:53:50 +0000
commit648370956683f65c8d60ba71ca158bf68d27db9a (patch)
tree2786e35006a14c91c3164c458cf6e63ca07a8778 /srUtils.c
parent73e4c2a0c637a16b19a54a04b04625e94b3ee4eb (diff)
downloadrsyslog-648370956683f65c8d60ba71ca158bf68d27db9a.tar.gz
rsyslog-648370956683f65c8d60ba71ca158bf68d27db9a.tar.xz
rsyslog-648370956683f65c8d60ba71ca158bf68d27db9a.zip
added config directives: $FileOwner, $FileGroup, $DirOwner, $DirGroup
Diffstat (limited to 'srUtils.c')
-rwxr-xr-xsrUtils.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/srUtils.c b/srUtils.c
index 686346cd..2b819ca5 100755
--- a/srUtils.c
+++ b/srUtils.c
@@ -111,11 +111,13 @@ uchar *srUtilStrDup(uchar *pOld, size_t len)
* Param "mode" holds the mode that all non-existing directories
* are to be created with.
*/
-int makeFileParentDirs(uchar *szFile, size_t lenFile, mode_t mode)
+int makeFileParentDirs(uchar *szFile, size_t lenFile, mode_t mode,
+ uid_t uid, gid_t gid)
{
uchar *p;
uchar *pszWork;
size_t len;
+ int bErr = 0;
assert(szFile != NULL);
assert(len > 0);
@@ -128,14 +130,26 @@ int makeFileParentDirs(uchar *szFile, size_t lenFile, mode_t mode)
if(*p == '/') {
/* temporarily terminate string, create dir and go on */
*p = '\0';
- if(access(pszWork, F_OK))
- if(mkdir(pszWork, mode) != 0) {
+ if(access(pszWork, F_OK)) {
+ if(mkdir(pszWork, mode) == 0) {
+ if(uid != -1 || gid != -1) {
+ /* we need to set owner/group */
+ if(chown(pszWork, uid, gid) != 0)
+ bErr = 1;
+ }
+ } else
+ bErr = 1;
+ if(bErr) {
int eSave = errno;
free(pszWork);
errno = eSave;
return -1;
}
+ }
*p = '/';
}
free(pszWork);
}
+/*
+ * vi:set ai:
+ */