diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-11-19 16:07:15 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-11-19 16:07:15 +0200 |
commit | 6fd987b7291fb1306297c193f4ab01bf6cd02618 (patch) | |
tree | 59e502d6a9fdc9de175ae14a10eca42d32813851 /lib/fsm.c | |
parent | 3b8ebf377bcab9a796304056a24cd3155fa23938 (diff) | |
download | rpm-6fd987b7291fb1306297c193f4ab01bf6cd02618.tar.gz rpm-6fd987b7291fb1306297c193f4ab01bf6cd02618.tar.bz2 rpm-6fd987b7291fb1306297c193f4ab01bf6cd02618.zip |
Make fsmMapAttrs() use rpmfi methods instead of directly accessing
- Save rpmfi iteration index on entry, restore on exit to avoid clashing
with other users of the given file info set. For now...
- Remove unnecessary re-initialization of uid and gid in case not found
Diffstat (limited to 'lib/fsm.c')
-rw-r--r-- | lib/fsm.c | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -717,29 +717,28 @@ static int fsmMapAttrs(FSM_t fsm) { struct stat * st = &fsm->sb; rpmfi fi = fsmGetFi(fsm); - int i = fsm->ix; - - if (fi && i >= 0 && i < fi->fc) { - mode_t perms = (S_ISDIR(st->st_mode) ? _dirPerms : _filePerms); - mode_t finalMode = (fi->fmodes ? fi->fmodes[i] : perms); - dev_t finalRdev = (fi->frdevs ? fi->frdevs[i] : 0); - rpm_time_t finalMtime = (fi->fmtimes ? fi->fmtimes[i] : 0); + int savefx = rpmfiFX(fi); + + if (rpmfiSetFX(fi, fsm->ix) != -1) { + mode_t finalMode = rpmfiFMode(fi); + dev_t finalRdev = rpmfiFRdev(fi); + time_t finalMtime = rpmfiFMtime(fi); + const char *user = rpmfiFUser(fi); + const char *group = rpmfiFGroup(fi); uid_t uid = 0; gid_t gid = 0; - if (fi->fuser && unameToUid(fi->fuser[i], &uid)) { + if (user && unameToUid(user, &uid)) { if (fsm->goal == FSM_PKGINSTALL) rpmlog(RPMLOG_WARNING, - _("user %s does not exist - using root\n"), fi->fuser[i]); - uid = 0; + _("user %s does not exist - using root\n"), user); finalMode &= ~S_ISUID; /* turn off suid bit */ } - if (fi->fgroup && gnameToGid(fi->fgroup[i], &gid)) { + if (group && gnameToGid(group, &gid)) { if (fsm->goal == FSM_PKGINSTALL) rpmlog(RPMLOG_WARNING, - _("group %s does not exist - using root\n"), fi->fgroup[i]); - gid = 0; + _("group %s does not exist - using root\n"), group); finalMode &= ~S_ISGID; /* turn off sgid bit */ } @@ -764,13 +763,13 @@ static int fsmMapAttrs(FSM_t fsm) * Set file checksum (if not disabled). */ if (ts != NULL && !(rpmtsFlags(ts) & RPMTRANS_FLAG_NOMD5)) { - size_t diglen = rpmDigestLength(fsm->digestalgo); - fsm->digest = (fi->digests ? (fi->digests + (diglen * i)) : NULL); + fsm->digest = rpmfiFDigest(fi, NULL, NULL); } else { fsm->digest = NULL; } } - + /* restore iterator index if we changed it */ + rpmfiSetFX(fi, savefx); } return 0; } |