Don't unlink non-temporary file in FSM_UNDO (rhbz#223931)
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Jan 2008 12:48:57 +0000 (14:48 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 7 Jan 2008 12:48:57 +0000 (14:48 +0200)
Ported from rpm5.org work of Jeff Johnson.

lib/fsm.c
lib/rpmts.c

index 4a50464..e5b739a 100644 (file)
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -523,7 +523,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,
 
     memset(fsm->sufbuf, 0, sizeof(fsm->sufbuf));
     if (fsm->goal == FSM_PKGINSTALL) {
-       if (ts && rpmtsGetTid(ts) > 0)
+       if (ts && rpmtsGetTid(ts) != -1)
            sprintf(fsm->sufbuf, ";%08x", (unsigned)rpmtsGetTid(ts));
     }
 
@@ -1700,8 +1700,10 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
        if (fsm->postpone)
            break;
        if (fsm->goal == FSM_PKGINSTALL) {
-           (void) fsmNext(fsm,
-               (S_ISDIR(st->st_mode) ? FSM_RMDIR : FSM_UNLINK));
+           /* XXX only erase if temp fn w suffix is in use */
+           if (fsm->sufbuf[0] != '\0')
+               (void) fsmNext(fsm,
+                   (S_ISDIR(st->st_mode) ? FSM_RMDIR : FSM_UNLINK));
 
 #ifdef NOTYET  /* XXX remove only dirs just created, not all. */
            if (fsm->dnlx)
index 9a0d0ef..876522d 100644 (file)
@@ -1124,7 +1124,7 @@ int rpmtsSetChrootDone(rpmts ts, int chrootDone)
 
 int32_t rpmtsGetTid(rpmts ts)
 {
-    int32_t tid = 0;
+    int32_t tid = -1;  /* XXX -1 is time(2) error return. */
     if (ts != NULL) {
        tid = ts->tid;
     }
@@ -1133,7 +1133,7 @@ int32_t rpmtsGetTid(rpmts ts)
 
 int32_t rpmtsSetTid(rpmts ts, int32_t tid)
 {
-    int32_t otid = 0;
+    int32_t otid = -1; /* XXX -1 is time(2) error return. */
     if (ts != NULL) {
        otid = ts->tid;
        ts->tid = tid;