/*@modifies fsm @*/
{
rpmts ts = fsmGetTs(fsm);
- rpmfi fi = fsmGetFi(fsm);
struct stat * st = &fsm->sb;
/*
* Find file security context (if not disabled).
*/
fsm->fcontext = NULL;
- if (ts != NULL && rpmtsSELinuxEnabled(ts) == 1 &&
- !(rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS))
- {
- rpmsx sx = rpmtsREContext(ts);
-
- if (sx != NULL) {
- /* Get file security context from patterns. */
- fsm->fcontext = rpmsxFContext(sx, fsm->path, st->st_mode);
- sx = rpmsxFree(sx);
- } else {
- int i = fsm->ix;
+ if (ts != NULL && !(rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS)) {
+ security_context_t scon = NULL;
- /* Get file security context from package. */
- if (fi && i >= 0 && i < fi->fc)
- fsm->fcontext = (fi->fcontexts ? fi->fcontexts[i] : NULL);
+ if (matchpathcon(fsm->path, st->st_mode, &scon) == 0 && scon != NULL) {
+ fsm->fcontext = scon;
}
}
return 0;
/*@-compdef@*/
rpmts ts = fsmGetTs(fsm);
/*@=compdef@*/
- rpmsx sx = rpmtsREContext(ts);
+ security_context_t scon = NULL;
fsm->path = NULL;
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 (! rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS) {
+ if (matchpathcon(fsm->path, st->st_mode, &scon) == 0 &&
+ scon != NULL) {
+ fsm->fcontext = scon;
+ rc = fsmNext(fsm, FSM_LSETFCON);
+ }
}
+
if (fsm->fcontext == NULL)
rpmMessage(RPMMESS_DEBUG,
_("%s directory created with perms %04o, no context.\n"),
}
/*@=boundswrite@*/
dnli = dnlFreeIterator(dnli);
- sx = rpmsxFree(sx);
/*@=observertrans =dependenttrans@*/
fsm->path = path;
}
if (!rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS) {
- rpmsx sx = rpmtsREContext(ts);
- if (sx == NULL) {
- const char *fn = rpmGetPath("%{?_install_file_context_path}", NULL);
- if (fn != NULL && *fn != '\0') {
- sx = rpmsxNew(fn);
- (void) rpmtsSetREContext(ts, sx);
- }
- fn = _free(fn);
- }
- sx = rpmsxFree(sx);
+ const char *fn = rpmGetPath("%{?_install_file_context_path}", NULL);
+ if (matchpathcon_init(fn) == -1) {
+ rpmtsSetFlags(ts, (rpmtsFlags(ts) | RPMTRANS_FLAG_NOCONTEXTS));
+ }
+ _free(fn);
}
ts->probs = rpmpsFree(ts->probs);