diff options
author | Stephen Smalley <sds@tycho.nsa.gov> | 2012-02-09 14:13:23 -0500 |
---|---|---|
committer | Stephen Smalley <sds@tycho.nsa.gov> | 2012-03-30 09:32:46 -0400 |
commit | 779701db515d1a0d363d5a8896252f331bc4e22a (patch) | |
tree | 46aacb687e7126a5a64949dd7ade2f284ee57c15 /minzip/DirUtil.c | |
parent | 1a114494950d8bce01bb860cd8a7221fdc9593cc (diff) | |
download | bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.zip bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar.gz bootable_recovery-779701db515d1a0d363d5a8896252f331bc4e22a.tar.bz2 |
Extend recovery and updater to support setting file security contexts.
Extend minzip, recovery, and updater to set the security context on
files based on the file_contexts configuration included in the package.
Change-Id: Ied379f266a16c64f2b4dca15dc39b98fcce16f29
Diffstat (limited to 'minzip/DirUtil.c')
-rw-r--r-- | minzip/DirUtil.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/minzip/DirUtil.c b/minzip/DirUtil.c index 20c89cd..0d49b57 100644 --- a/minzip/DirUtil.c +++ b/minzip/DirUtil.c @@ -54,7 +54,8 @@ getPathDirStatus(const char *path) int dirCreateHierarchy(const char *path, int mode, - const struct utimbuf *timestamp, bool stripFileName) + const struct utimbuf *timestamp, bool stripFileName, + struct selabel_handle *sehnd) { DirStatus ds; @@ -144,7 +145,25 @@ dirCreateHierarchy(const char *path, int mode, } else if (ds == DMISSING) { int err; +#ifdef HAVE_SELINUX + char *secontext = NULL; + + if (sehnd) { + selabel_lookup(sehnd, &secontext, cpath, mode); + setfscreatecon(secontext); + } +#endif + err = mkdir(cpath, mode); + +#ifdef HAVE_SELINUX + + if (secontext) { + freecon(secontext); + setfscreatecon(NULL); + } +#endif + if (err != 0) { free(cpath); return -1; |