diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-17 12:53:50 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-17 12:53:50 +0000 |
commit | 648370956683f65c8d60ba71ca158bf68d27db9a (patch) | |
tree | 2786e35006a14c91c3164c458cf6e63ca07a8778 /srUtils.c | |
parent | 73e4c2a0c637a16b19a54a04b04625e94b3ee4eb (diff) | |
download | rsyslog-648370956683f65c8d60ba71ca158bf68d27db9a.tar.gz rsyslog-648370956683f65c8d60ba71ca158bf68d27db9a.tar.xz rsyslog-648370956683f65c8d60ba71ca158bf68d27db9a.zip |
added config directives: $FileOwner, $FileGroup, $DirOwner, $DirGroup
Diffstat (limited to 'srUtils.c')
-rwxr-xr-x | srUtils.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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: + */ |