From 070b65040eab0f221c5f79796358986e698cd2ef Mon Sep 17 00:00:00 2001 From: Alexey Tourbin Date: Mon, 9 Jun 2008 00:29:18 +0400 Subject: [PATCH] psm.[ch]: skip fuser and fgroup test/set for src.rpm Previous change in loadFi() triggers the code which depends on fi->fuser and fi->fgroup being NULL for source rpms. Now I add explicit check for source rpms. Update: also turn off suid/sgid bits for src.rpm. --- lib/psm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/psm.c b/lib/psm.c index b08e7e8..b9e6f8e 100644 --- a/lib/psm.c +++ b/lib/psm.c @@ -1676,17 +1676,22 @@ assert(psm->mi == NULL); if (psm->goal == PSM_PKGINSTALL) { struct availablePackage * alp = fi->ap; int i; + int isSource; if (fi->fc <= 0) break; if (ts->transFlags & RPMTRANS_FLAG_JUSTDB) break; + isSource = !headerIsEntry(fi->h, RPMTAG_SOURCERPM); + for (i = 0; i < fi->fc; i++) { uid_t uid; gid_t gid; uid = fi->uid; gid = fi->gid; - if (fi->fuser && unameToUid(fi->fuser[i], &uid)) { + if (isSource) + fi->fmodes[i] &= ~S_ISUID; + else if (fi->fuser && unameToUid(fi->fuser[i], &uid)) { rpmMessage(RPMMESS_WARNING, _("user %s does not exist - using root\n"), fi->fuser[i]); @@ -1695,7 +1700,9 @@ assert(psm->mi == NULL); fi->fmodes[i] &= ~S_ISUID; /* turn off the suid bit */ } - if (fi->fgroup && gnameToGid(fi->fgroup[i], &gid)) { + if (isSource) + fi->fmodes[i] &= ~S_ISGID; + else if (fi->fgroup && gnameToGid(fi->fgroup[i], &gid)) { rpmMessage(RPMMESS_WARNING, _("group %s does not exist - using root\n"), fi->fgroup[i]);