[Rpm-maint] [PATCH] RFC: Allow for disabling Berkeley DB support

2017-06-22 Thread Darren Hart (VMware)
Introduce a --disable-bdb configuration option which disables the use of
Berkeley DB entirely. Update the various autotools to ensure that at
least one of BDB or NDB is enabled. Existing configuration options
continue as before. Minor updates to dbi.h and dbi.c to handle bdb being
optional. Add a little extra paranoia to dbi.c which will error out of
the build if neither BDB nor NDB are enabled (which should not be
possible to configure).

Signed-off-by: Darren Hart (VMware) 
---
 configure.ac  | 22 --
 lib/Makefile.am   |  7 ++-
 lib/backend/dbi.c | 10 +-
 lib/backend/dbi.h |  2 ++
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index cc657ec..ca51350 100644
--- a/configure.ac
+++ b/configure.ac
@@ -483,7 +483,18 @@ AM_CONDITIONAL(LIBDW,[test "$WITH_LIBDW" = yes])
 AM_CONDITIONAL(HAVE_LIBDW_STRTAB,[test "$HAVE_LIBDW_STRTAB" = yes])
 
 #=
-# Process --with/without-external-db
+# Process --disbale-bdb
+AC_ARG_ENABLE([bdb],
+  [AS_HELP_STRING([--disable-bdb],[build without bdb rpm database format 
support])])
+AS_IF([test "x$enable_bdb" != "xno"],
+  [AC_DEFINE(ENABLE_BDB, 1, [Build with bdb rpm database format support?])],
+  # If BDB is disabled, force enable NDB
+  [enable_ndb=yes])
+AM_CONDITIONAL(BDB,[test "x$enable_bdb" != "xno"])
+
+#=
+# Process --with/without-external-db if bdb is not disabled
+AS_IF([test "x$enable_bdb" != "xno"],[
 AC_ARG_WITH(external_db, [AS_HELP_STRING([--with-external-db],[build against 
an external Berkeley db])],
 [case "$with_external_db" in
 yes|no) ;;
@@ -538,7 +549,7 @@ no|maybe )
   fi
   ;;
 esac
-
+])
 AC_SUBST([WITH_DB_LIB])
 
 #=
@@ -548,9 +559,8 @@ AC_ARG_ENABLE([ndb], [AS_HELP_STRING([--enable-ndb],[enable 
the new rpm database
 yes|no) ;;
 *) AC_MSG_ERROR([invalid argument to --enable-ndb])
   ;;
-esac],
-[enable_ndb=no])
-AS_IF([test "$enable_ndb" = yes],[
+esac])
+AS_IF([test "$enable_ndb" = yes ],[
   AC_DEFINE(ENABLE_NDB, 1, [Enable new rpm database format?])
 ])
 AM_CONDITIONAL([NDB], [test "$enable_ndb" = yes])
@@ -1014,7 +1024,7 @@ if test "$with_external_db" = no; then
 AC_CONFIG_SUBDIRS(db3)
 fi
 
-AM_CONDITIONAL([WITH_INTERNAL_DB],[test "$with_external_db" = no])
+AM_CONDITIONAL([WITH_INTERNAL_DB],[test "$enable-bdb" = yes && 
"$with_external_db" = no])
 AM_CONDITIONAL([DOXYGEN],[test "$DOXYGEN" != no])
 AM_CONDITIONAL([HACKINGDOCS],[test "$with_hackingdocs" = yes])
 
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3bb5af9..1eede2e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -23,7 +23,7 @@ EXTRA_PROGRAMS =
 
 usrlib_LTLIBRARIES = librpm.la
 librpm_la_SOURCES = \
-   backend/db3.c backend/dbi.c backend/dbi.h \
+   backend/dbi.c backend/dbi.h \
backend/dbiset.c backend/dbiset.h \
headerutil.c header.c headerfmt.c header_internal.h \
rpmdb.c rpmdb_internal.h \
@@ -58,11 +58,14 @@ librpm_la_LIBADD += @LUA_LIBS@
 librpm_la_SOURCES += rpmliblua.c rpmliblua.h
 endif
 
+if BDB
+librpm_la_SOURCES += backend/db3.c
 if WITH_INTERNAL_DB
 librpm_la_LIBADD += $(libdb_la)
 else
 librpm_la_LIBADD += @WITH_DB_LIB@
 endif
+endif
 
 if NDB
 librpm_la_SOURCES += \
@@ -81,6 +84,7 @@ tagtbl.C: Makefile.am $(srcdir)/rpmtag.h gentagtbl.sh
 mv -f $@.new $@
 BUILT_SOURCES = tagtbl.C
 
+if BDB
 if WITH_INTERNAL_DB
 # XXX watchout, $(top_builddir)/db3/libdb.la created by this Makefile may 
surprise
 libdb_la = $(top_builddir)/db3/libdb.la
@@ -145,5 +149,6 @@ rpmdb_verify_LDADD = \
$(top_builddir)/db3/util_sig.o \
librpm.la
 endif
+endif
 
 CLEANFILES += $(BUILT_SOURCES)
diff --git a/lib/backend/dbi.c b/lib/backend/dbi.c
index beba49f..7c0c21c 100644
--- a/lib/backend/dbi.c
+++ b/lib/backend/dbi.c
@@ -35,6 +35,7 @@ static void
 dbDetectBackend(rpmdb rdb)
 {
 #ifdef ENABLE_NDB
+#ifdef ENABLE_BDB
 const char *dbhome = rpmdbHome(rdb);
 char *db_backend = rpmExpand("%{?_db_backend}");
 if (!strcmp(db_backend, "ndb")) {
@@ -52,8 +53,15 @@ dbDetectBackend(rpmdb rdb)
 if (access(path, F_OK) == 0)
rdb->db_ops = _dbops;
 free(path);
-#else
+#else /* No BDB backend support */
+rdb->db_ops = _dbops;
+#endif
+#else /* No NDB backend support */
+#ifdef ENABLE_BDB
 rdb->db_ops = _dbops;
+#else /* ERROR: No backend enabled, this should not be a configurable state */
+#error No backend enabled
+#endif
 #endif
 }
 
diff --git a/lib/backend/dbi.h b/lib/backend/dbi.h
index a575d3c..21e3fbf 100644
--- a/lib/backend/dbi.h
+++ b/lib/backend/dbi.h
@@ -249,8 +249,10 @@ struct rpmdbOps_s {
 const void * (*idxdbKey)(dbiIndex dbi, dbiCursor dbc, unsigned int 
*keylen);
 };
 
+#ifdef ENABLE_BDB
 RPM_GNUC_INTERNAL
 extern struct rpmdbOps_s db3_dbops;
+#endif
 
 #ifdef ENABLE_NDB
 RPM_GNUC_INTERNAL
-- 
2.7.4


-- 
Darren Hart
VMware Open Source Technology Center
___
Rpm-maint mailing list

Re: [Rpm-maint] [PATCH] Use a file list to add build-id files to pkgList and explicitly set attrs.

2017-06-22 Thread Mark Wielaard
Hi,

Panu sadi on irc he didn't like the duplication of code that parsed the
spec file lists. So this updated patch extracts the setup and parsing
loop in their own function and just calls them twice. I also reformatted
the patch a little so the whitespace differences are minimal.

Cheers,

Mark

From 739796798ac854f80ae2f0d677f74bca734055f7 Mon Sep 17 00:00:00 2001
From: Mark Wielaard 
Date: Wed, 21 Jun 2017 16:57:13 +0200
Subject: [PATCH] Use a file list to add build-id files to pkgList and
 explicitly set attrs.

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.

Change the generation of build-id files to a file list using ARGV_t.
First go through the current package list and generate a files list.
Then add those files using the defaults mode/attr settings as if they
were part of the original package file list.

https://bugzilla.redhat.com/show_bug.cgi?id=1452893
https://bugzilla.redhat.com/show_bug.cgi?id=1458839

Signed-off-by: Mark Wielaard 
---
 build/files.c | 244 +-
 1 file changed, 138 insertions(+), 106 deletions(-)

diff --git a/build/files.c b/build/files.c
index 4911162d1..a90af3bee 100644
--- a/build/files.c
+++ b/build/files.c
@@ -207,9 +207,9 @@ static char *mkattr(const char *fn)
 {
 char *s = NULL;
 if (fn)
-	rasprintf(, "%s(-,%s,%s) %s", "%attr", UID_0_USER, GID_0_GROUP, fn);
+	rasprintf(, "%s(755,%s,%s) %s", "%attr", UID_0_USER, GID_0_GROUP, fn);
 else
-	rasprintf(, "%s(-,%s,%s)", "%defattr", UID_0_USER, GID_0_GROUP);
+	rasprintf(, "%s(644,%s,%s,755)", "%defattr", UID_0_USER, GID_0_GROUP);
 return s;
 }
 
@@ -1614,6 +1614,15 @@ exit:
 return rc;
 }
 
+/* add a directory to the file list */
+static void argvAddDir(ARGV_t *filesp, const char *dir)
+{
+char *line = NULL;
+rasprintf(, "%%dir %s", dir);
+argvAdd(filesp, line);
+_free(line);
+}
+
 #if HAVE_LIBDW
 /* How build id links are generated.  See macros.in for description.  */
 #define BUILD_IDS_NONE 0
@@ -1621,7 +1630,7 @@ exit:
 #define BUILD_IDS_SEPARATE 2
 #define BUILD_IDS_COMPAT   3
 
-static int addNewIDSymlink(FileList fl,
+static int addNewIDSymlink(ARGV_t *files,
 			   char *targetpath, char *idlinkpath,
 			   int isDbg, int *dups)
 {
@@ -1670,8 +1679,7 @@ static int addNewIDSymlink(FileList fl,
 	rpmlog(RPMLOG_ERR, "%s: %s -> %s: %m\n",
 	   linkerr, linkpath, targetpath);
 } else {
-	fl->cur.isDir = 0;
-	rc = addFile(fl, linkpath, NULL);
+	rc = argvAdd(files, linkpath);
 }
 
 if (nr > 0) {
@@ -1709,7 +1717,7 @@ static int addNewIDSymlink(FileList fl,
 return rc;
 }
 
-static int generateBuildIDs(FileList fl)
+static int generateBuildIDs(FileList fl, ARGV_t *files)
 {
 int rc = 0;
 int i;
@@ -1858,18 +1866,9 @@ static int generateBuildIDs(FileList fl)
 	mainiddir = rpmGetPath(fl->buildRoot, BUILD_ID_DIR, NULL);
 	debugiddir = rpmGetPath(fl->buildRoot, DEBUG_ID_DIR, NULL);
 
-	/* Make sure to reset all file flags to defaults.
-	   Uses parseForAttr to reset ar, arFlags, and specdFlags.
-	   Note that parseForAttr pokes at the attrstr, so we cannot
-	   just pass a static string. */
-	fl->cur.attrFlags = 0;
-	fl->def.attrFlags = 0;
-	fl->def.verifyFlags = RPMVERIFY_ALL;
-	fl->cur.verifyFlags = RPMVERIFY_ALL;
-	fl->def.specdFlags |= SPECD_VERIFY;
-	fl->cur.specdFlags |= SPECD_VERIFY;
+	/* Make sure to reset all file flags to defaults.  */
 	attrstr = mkattr(NULL);
-	parseForAttr(fl->pool, attrstr, 1, >def);
+	argvAdd(files, attrstr);
 	free (attrstr);
 
 	/* Supported, but questionable.  */
@@ -1881,11 +1880,7 @@ static int generateBuildIDs(FileList fl)
 		if ((rc = rpmioMkpath(mainiddir, 0755, -1, -1)) != 0) {
 		rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, mainiddir);
 		} else {
-		attrstr = mkattr(mainiddir);
-		parseForAttr(fl->pool, attrstr, 0, >cur);
-		fl->cur.isDir = 1;
-		rc = addFile(fl, mainiddir, NULL);
-		free (attrstr);
+		argvAddDir(files, mainiddir);
 		}
 	}
 
@@ -1893,11 +1888,7 @@ static int generateBuildIDs(FileList fl)
 		if ((rc = rpmioMkpath(debugiddir, 0755, -1, -1)) != 0) {
 		rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, debugiddir);
 		} else {
-		attrstr = mkattr(debugiddir);
-		parseForAttr(fl->pool, attrstr, 0, >cur);
-		fl->cur.isDir = 1;
-		rc = addFile(fl, debugiddir, NULL);
-		free (attrstr);
+		argvAddDir(files, debugiddir);
 		}
 	}
 	}
@@ -1936,9 +1927,9 @@ static int generateBuildIDs(FileList fl)
 		&& (rc = rpmioMkpath(buildidsubdir, 0755, -1, -1)) != 0) {
 		rpmlog(RPMLOG_ERR, "%s %s: %m\n", errdir, buildidsubdir);
 		} else {
-		fl->cur.isDir = 

Re: [Rpm-maint] [rpm-software-management/rpm] Check signatures in the code (#240)

2017-06-22 Thread Jeff Johnson
Signatures are stored in a tag in a package header. So one retrieves a tag from 
a header, and then parses out the keyid from the OpenPGP format.

The harder issue is that there are up to 4 (or perhaps more) possible tags 
where signatures might be stored, and that even if a signature with a keyid may 
not (or cannot in the case of header+payload signatures) be verified.

You can find the 4 tags that may have to be examined by looking at the 
--queryformat string used by rpm --info (which displays the keyid) stored in 
/usr/lib/rpm. Doing a --queryformat is likely the most efficient extraction of 
a keyid when writing scripts, through bindings, or even  writing C code.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/240#issuecomment-310361245___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint


[Rpm-maint] [rpm-software-management/rpm] Check signatures in the code (#240)

2017-06-22 Thread Victor Polevoy
How can I check in the librpm code whether a package in the transaction has 
signatures at all and if it does, print it's key id?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/240___
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint