- fix: set fcontext for "mkdir -p" directories not in packages.
authorjbj <devnull@localhost>
Sun, 15 Feb 2004 22:12:45 +0000 (22:12 +0000)
committerjbj <devnull@localhost>
Sun, 15 Feb 2004 22:12:45 +0000 (22:12 +0000)
CVS patchset: 7091
CVS date: 2004/02/15 22:12:45

CHANGES
lib/fsm.c
rpm.spec.in

diff --git a/CHANGES b/CHANGES
index d16f542..13c57b5 100644 (file)
--- 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.
index e8ee232..dcab166 100644 (file)
--- 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. */
index 4a0e76d..958cd90 100644 (file)
@@ -484,6 +484,7 @@ exit 0
 %changelog
 * Sun Feb 15 2004 Jeff Johnson <jbj@jbj.org> 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 <jbj@redhat.com> 4.3-0.10
 - re-add --enable-posixmutexes to build.