teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

Blame 0001-Emit-full-paths-for-file-disposition-diagnostics-on-.patch

Florian Festi 6ae193
From c140768202e271b60910644c1e4bf848a50218d3 Mon Sep 17 00:00:00 2001
Florian Festi 6ae193
From: Panu Matilainen <pmatilai@redhat.com>
Florian Festi 6ae193
Date: Mon, 27 Nov 2023 11:52:34 +0200
Florian Festi 6ae193
Subject: [PATCH] Emit full paths for file disposition diagnostics on
Florian Festi 6ae193
 --fsmdebug
Florian Festi 6ae193
Florian Festi 6ae193
The full path is visible in the actual file operations later, but the
Florian Festi 6ae193
pre-flight disposition diagnostics is unreadable without the full path.
Florian Festi 6ae193
This regressed in the switch to relative paths for the *at() API family
Florian Festi 6ae193
for the symlink CVE fixes.
Florian Festi 6ae193
---
Florian Festi 6ae193
 lib/fsm.c | 12 ++++++------
Florian Festi 6ae193
 1 file changed, 6 insertions(+), 6 deletions(-)
Florian Festi 6ae193
Florian Festi 6ae193
diff --git a/lib/fsm.c b/lib/fsm.c
Florian Festi 6ae193
index 091e90554..fcd764648 100644
Florian Festi 6ae193
--- a/lib/fsm.c
Florian Festi 6ae193
+++ b/lib/fsm.c
Florian Festi 6ae193
@@ -482,14 +482,14 @@ static void removeSBITS(int dirfd, const char *path)
Florian Festi 6ae193
     }
Florian Festi 6ae193
 }
Florian Festi 6ae193
 
Florian Festi 6ae193
-static void fsmDebug(const char *fpath, rpmFileAction action,
Florian Festi 6ae193
+static void fsmDebug(const char *dn, const char *fpath, rpmFileAction action,
Florian Festi 6ae193
 		     const struct stat *st)
Florian Festi 6ae193
 {
Florian Festi 6ae193
-    rpmlog(RPMLOG_DEBUG, "%-10s %06o%3d (%4d,%4d)%6d %s\n",
Florian Festi 6ae193
+    rpmlog(RPMLOG_DEBUG, "%-10s %06o%3d (%4d,%4d)%6d %s%s\n",
Florian Festi 6ae193
 	   fileActionString(action), (int)st->st_mode,
Florian Festi 6ae193
 	   (int)st->st_nlink, (int)st->st_uid,
Florian Festi 6ae193
 	   (int)st->st_gid, (int)st->st_size,
Florian Festi 6ae193
-	    (fpath ? fpath : ""));
Florian Festi 6ae193
+	    (dn ? dn : ""), (fpath ? fpath : ""));
Florian Festi 6ae193
 }
Florian Festi 6ae193
 
Florian Festi 6ae193
 static int fsmSymlink(const char *opath, int dirfd, const char *path)
Florian Festi 6ae193
@@ -910,7 +910,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
Florian Festi 6ae193
 		      (fp->sb.st_nlink == 1 || fp->action == FA_TOUCH);
Florian Festi 6ae193
 
Florian Festi 6ae193
 	setFileState(fs, fx);
Florian Festi 6ae193
-	fsmDebug(fp->fpath, fp->action, &fp->sb);
Florian Festi 6ae193
+	fsmDebug(rpmfiDN(fi), fp->fpath, fp->action, &fp->sb);
Florian Festi 6ae193
 
Florian Festi 6ae193
 	fp->stage = FILE_PRE;
Florian Festi 6ae193
     }
Florian Festi 6ae193
@@ -975,7 +975,7 @@ int rpmPackageFilesInstall(rpmts ts, rpmte te, rpmfiles files,
Florian Festi 6ae193
 		rpmlog(RPMLOG_DEBUG, "file %s vanished unexpectedly\n",
Florian Festi 6ae193
 			fp->fpath);
Florian Festi 6ae193
 		fp->action = FA_CREATE;
Florian Festi 6ae193
-		fsmDebug(fp->fpath, fp->action, &fp->sb);
Florian Festi 6ae193
+		fsmDebug(rpmfiDN(fi), fp->fpath, fp->action, &fp->sb);
Florian Festi 6ae193
 	    }
Florian Festi 6ae193
 
Florian Festi 6ae193
 	    /* When touching we don't need any of this... */
Florian Festi 6ae193
@@ -1138,7 +1138,7 @@ int rpmPackageFilesRemove(rpmts ts, rpmte te, rpmfiles files,
Florian Festi 6ae193
 
Florian Festi 6ae193
 	rc = fsmStat(di.dirfd, fp->fpath, 1, &fp->sb);
Florian Festi 6ae193
 
Florian Festi 6ae193
-	fsmDebug(fp->fpath, fp->action, &fp->sb);
Florian Festi 6ae193
+	fsmDebug(rpmfiDN(fi), fp->fpath, fp->action, &fp->sb);
Florian Festi 6ae193
 
Florian Festi 6ae193
 	/* Run fsm file pre hook for all plugins */
Florian Festi 6ae193
 	rc = rpmpluginsCallFsmFilePre(plugins, fi, fp->fpath,
Florian Festi 6ae193
-- 
Florian Festi 6ae193
2.43.0
Florian Festi 6ae193