rpm/0053-Change-mkattr-to-always-create-a-defattr-with-explic.patch

83 lines
2.9 KiB
Diff
Raw Normal View History

From 13369a562f5cba34779e238b2d6ae0b683ff3b1e Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 29 Jun 2017 13:26:26 +0200
Subject: [PATCH] Change mkattr to always create a %defattr with explicitly set
modes.
mkattr used "-" as default mode which would pick up the mode for files
as they were on disk. This could cause files generated by rpmbuild to
use a "non-standard" mode if umask was set by the user. Explitictly
use 755 for directories and 644 for files to make builds independent
of any umask settings.
This works as is for both files and directories, so no file argument
is necessary anymore.
https://bugzilla.redhat.com/show_bug.cgi?id=1452893
https://bugzilla.redhat.com/show_bug.cgi?id=1458839
Signed-off-by: Mark Wielaard <mark@klomp.org>
(cherry picked from commit 261ba91172ca1536eaa1d76e9cde58643b66c8f3)
---
build/files.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/build/files.c b/build/files.c
index e88a5d24d..29274926c 100644
--- a/build/files.c
+++ b/build/files.c
@@ -193,13 +193,12 @@ static void dupAttrRec(const AttrRec oar, AttrRec nar)
*nar = *oar; /* struct assignment */
}
-static char *mkattr(const char *fn)
+/* Creates a default $defattr string. Can be used with argvAdd().
+ Caller owns the new string which needs to be freed when done. */
+static char *mkattr(void)
{
char *s = NULL;
- if (fn)
- rasprintf(&s, "%s(-,%s,%s) %s", "%attr", "root", "root", fn);
- else
- rasprintf(&s, "%s(-,%s,%s)", "%defattr", "root", "root");
+ rasprintf(&s, "%s(644,%s,%s,755)", "%defattr", "root", "root");
return s;
}
@@ -1829,7 +1828,7 @@ static int generateBuildIDs(FileList fl, ARGV_t *files)
debugiddir = rpmGetPath(fl->buildRoot, DEBUG_ID_DIR, NULL);
/* Make sure to reset all file flags to defaults. */
- attrstr = mkattr(NULL);
+ attrstr = mkattr();
argvAdd(files, attrstr);
free (attrstr);
@@ -2783,7 +2782,7 @@ static void filterDebuginfoPackage(rpmSpec spec, Package pkg,
if (access(path, F_OK) == 0) {
/* Append the file list preamble */
if (!files) {
- char *attr = mkattr(NULL);
+ char *attr = mkattr();
argvAdd(&files, attr);
argvAddDir(&files, DEBUG_LIB_DIR);
free(attr);
@@ -2843,7 +2842,7 @@ static int addDebugDwz(Package pkg, char *buildroot)
rasprintf(&path, "%s%s", buildroot, DEBUG_DWZ_DIR);
if (lstat(path, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)) {
if (!pkg->fileList) {
- char *attr = mkattr(NULL);
+ char *attr = mkattr();
argvAdd(&pkg->fileList, attr);
argvAddDir(&pkg->fileList, DEBUG_LIB_DIR);
free(attr);
@@ -2877,7 +2876,7 @@ static int addDebugSrc(Package pkg, char *buildroot)
continue;
rasprintf(&path, "%s/%s", DEBUG_SRC_DIR, de->d_name);
if (!pkg->fileList) {
- char *attr = mkattr(NULL);
+ char *attr = mkattr();
argvAdd(&pkg->fileList, attr);
free(attr);
}