From 64aca824816ab4019d55c0795332e48247768837 Mon Sep 17 00:00:00 2001 From: jbj Date: Sun, 15 Feb 2004 22:12:45 +0000 Subject: [PATCH] - fix: set fcontext for "mkdir -p" directories not in packages. CVS patchset: 7091 CVS date: 2004/02/15 22:12:45 --- CHANGES | 1 + lib/fsm.c | 21 +++++++++++++++++++-- rpm.spec.in | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index d16f542..13c57b5 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ - python: throw exception on bad arg to labelCompare (#113661). - re-add --enable-posixmutexes to build. - fix: set fcontext from pkg when file_contexts doesn't exist (#114040). + - fix: set fcontext for "mkdir -p" directories not in packages. 4.2.1 -> 4.2.2: - unify signal handling in librpmio, use condvar to deliver signal. diff --git a/lib/fsm.c b/lib/fsm.c index e8ee232..dcab166 100644 --- a/lib/fsm.c +++ b/lib/fsm.c @@ -1274,6 +1274,8 @@ static int fsmMkdirs(/*@special@*/ /*@partial@*/ FSM_t fsm) int dc = dnlCount(dnli); int rc = 0; int i; + rpmts ts = fsmGetTs(fsm); + rpmsx sx = rpmtsREContext(ts); fsm->path = NULL; @@ -1334,15 +1336,30 @@ static int fsmMkdirs(/*@special@*/ /*@partial@*/ FSM_t fsm) *te = '\0'; st->st_mode = S_IFDIR | (fi->dperms & 07777); rc = fsmNext(fsm, FSM_MKDIR); - if (!rc) + if (!rc) { + /* XXX FIXME? only new dir will have context set. */ + /* Get file security context from patterns. */ + if (sx != NULL) { + fsm->fcontext = rpmsxFContext(sx, fsm->path, st->st_mode); + rc = fsmNext(fsm, FSM_LSETFCON); + } + if (fsm->fcontext == NULL) rpmMessage(RPMMESS_DEBUG, - _("%s directory created with perms %04o.\n"), + _("%s directory created with perms %04o, no context.\n"), fsm->path, (unsigned)(st->st_mode & 07777)); + else + rpmMessage(RPMMESS_DEBUG, + _("%s directory created with perms %04o, context %s.\n"), + fsm->path, (unsigned)(st->st_mode & 07777), + fsm->fcontext); + fsm->fcontext = NULL; + } *te = '/'; } if (rc) /*@innerbreak@*/ break; } + sx = rpmsxFree(sx); if (rc) break; /* Save last validated path. */ diff --git a/rpm.spec.in b/rpm.spec.in index 4a0e76d..958cd90 100644 --- a/rpm.spec.in +++ b/rpm.spec.in @@ -484,6 +484,7 @@ exit 0 %changelog * Sun Feb 15 2004 Jeff Johnson 4.3-0.11 - fix: set fcontext from pkg when file_contexts doesn't exist (#114040). +- fix: set fcontext for "mkdir -p" directories not in packages. * Wed Feb 11 2004 Jeff Johnson 4.3-0.10 - re-add --enable-posixmutexes to build. -- 2.7.4