[pacman-dev] [PATCH] Fix compilation without gpgme
Two issues have snuck in that prevent the compile from working. Signed-off-by: Dan McGee <dan@archlinux.org> --- This and the rest of the patches available on my 'random-fixes' branch. lib/libalpm/sync.c | 2 +- src/pacman/package.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index e358585..9531fa2 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1225,7 +1225,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) return -1; } -#if HAVE_LIBGPGME +#ifdef HAVE_LIBGPGME /* make sure all required signatures are in keyring */ if(check_keyring(handle)) { return -1; diff --git a/src/pacman/package.c b/src/pacman/package.c index 52219ff..c44696b 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -193,6 +193,10 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) } if(from == ALPM_PKG_FROM_SYNCDB && extra) { + string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg), cols); + string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); + +#ifdef HAVE_LIBGPGME const char *base64_sig = alpm_pkg_get_base64_sig(pkg); alpm_list_t *keys = NULL; if(base64_sig) { @@ -204,10 +208,8 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) } else { keys = alpm_list_add(keys, _("None")); } - - string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg), cols); - string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); list_display(_("Signatures :"), keys, cols); +#endif } else { list_display(_("Validated By :"), validation, cols); } -- 1.8.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/db.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 4bb6ee9..4e35c13 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -32,13 +32,14 @@ /* Database entries */ typedef enum _alpm_dbinfrq_t { - INFRQ_BASE = 1, + INFRQ_BASE = (1 << 0), INFRQ_DESC = (1 << 1), INFRQ_FILES = (1 << 2), INFRQ_SCRIPTLET = (1 << 3), INFRQ_DSIZE = (1 << 4), /* ALL should be info stored in the package or database */ - INFRQ_ALL = 0x1F, + INFRQ_ALL = INFRQ_BASE | INFRQ_DESC | INFRQ_FILES | + INFRQ_SCRIPTLET | INFRQ_DSIZE, INFRQ_ERROR = (1 << 31) } alpm_dbinfrq_t; -- 1.8.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/diskspace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index dcab3b0..cfd0a7a 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -84,6 +84,9 @@ static int mount_point_load_fsinfo(alpm_handle_t *handle, alpm_mountpoint_t *mou _alpm_log(handle, ALPM_LOG_DEBUG, "loading fsinfo for %s\n", mountpoint->mount_dir); mountpoint->read_only = mountpoint->fsp.f_flag & ST_RDONLY; mountpoint->fsinfo_loaded = MOUNT_FSINFO_LOADED; +#else + (void)handle; + (void)mountpoint; #endif return 0; -- 1.8.5.2
On 03/01/14 04:37, Dan McGee wrote:
Signed-off-by: Dan McGee <dan@archlinux.org> ---
I had submitted this a patch flagging the parameters as potentially unused: https://patchwork.archlinux.org/patch/1788/
lib/libalpm/diskspace.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index dcab3b0..cfd0a7a 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -84,6 +84,9 @@ static int mount_point_load_fsinfo(alpm_handle_t *handle, alpm_mountpoint_t *mou _alpm_log(handle, ALPM_LOG_DEBUG, "loading fsinfo for %s\n", mountpoint->mount_dir); mountpoint->read_only = mountpoint->fsp.f_flag & ST_RDONLY; mountpoint->fsinfo_loaded = MOUNT_FSINFO_LOADED; +#else + (void)handle; + (void)mountpoint; #endif
return 0;
On Thu, Jan 2, 2014 at 4:03 PM, Allan McRae <allan@archlinux.org> wrote:
On 03/01/14 04:37, Dan McGee wrote:
Signed-off-by: Dan McGee <dan@archlinux.org> ---
I had submitted this a patch flagging the parameters as potentially unused: https://patchwork.archlinux.org/patch/1788/
I am not a huge fan of flagging things as unused when they are in fact used on certain code paths, but I'm not going to object either way. You're in charge! :)
lib/libalpm/diskspace.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index dcab3b0..cfd0a7a 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -84,6 +84,9 @@ static int mount_point_load_fsinfo(alpm_handle_t *handle, alpm_mountpoint_t *mou _alpm_log(handle, ALPM_LOG_DEBUG, "loading fsinfo for %s\n", mountpoint->mount_dir); mountpoint->read_only = mountpoint->fsp.f_flag & ST_RDONLY; mountpoint->fsinfo_loaded = MOUNT_FSINFO_LOADED; +#else + (void)handle; + (void)mountpoint; #endif
return 0;
On 09/01/14 03:03, Dan McGee wrote:
On Thu, Jan 2, 2014 at 4:03 PM, Allan McRae <allan@archlinux.org> wrote:
On 03/01/14 04:37, Dan McGee wrote:
Signed-off-by: Dan McGee <dan@archlinux.org> ---
I had submitted this a patch flagging the parameters as potentially unused: https://patchwork.archlinux.org/patch/1788/
I am not a huge fan of flagging things as unused when they are in fact used on certain code paths, but I'm not going to object either way. You're in charge! :)
That flag just say "potentially unused", so it is perfect for this situation. Until the variable becomes used in all code paths and it unused flags is not removed... I'll flip a coin to pick a patch in the next merge.
lib/libalpm/diskspace.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index dcab3b0..cfd0a7a 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -84,6 +84,9 @@ static int mount_point_load_fsinfo(alpm_handle_t *handle, alpm_mountpoint_t *mou _alpm_log(handle, ALPM_LOG_DEBUG, "loading fsinfo for %s\n", mountpoint->mount_dir); mountpoint->read_only = mountpoint->fsp.f_flag & ST_RDONLY; mountpoint->fsinfo_loaded = MOUNT_FSINFO_LOADED; +#else + (void)handle; + (void)mountpoint; #endif
return 0;
Noticed using clang and `-Wpadded`. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/dload.h | 4 ++-- lib/libalpm/graph.h | 4 ++-- lib/libalpm/handle.h | 4 +++- src/pacman/conf.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h index 6c9f7a7..964c338 100644 --- a/lib/libalpm/dload.h +++ b/lib/libalpm/dload.h @@ -31,6 +31,8 @@ struct dload_payload { char *destfile_name; char *content_disp_name; char *fileurl; + alpm_list_t *servers; + long respcode; off_t initial_size; off_t max_size; off_t prevprogress; @@ -39,11 +41,9 @@ struct dload_payload { int errors_ok; int unlink_on_fail; int trust_remote_name; - alpm_list_t *servers; #ifdef HAVE_LIBCURL CURLcode curlerr; /* last error produced by curl */ #endif - long respcode; }; void _alpm_dload_payload_reset(struct dload_payload *payload); diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h index bf06047..8db35bf 100644 --- a/lib/libalpm/graph.h +++ b/lib/libalpm/graph.h @@ -24,12 +24,12 @@ #include "alpm_list.h" typedef struct __alpm_graph_t { - char state; /* 0: untouched, -1: entered, other: leaving time */ - off_t weight; /* weight of the node */ void *data; struct __alpm_graph_t *parent; /* where did we come from? */ alpm_list_t *children; alpm_list_t *childptr; /* points to a child in children list */ + off_t weight; /* weight of the node */ + char state; /* 0: untouched, -1: entered, other: leaving time */ } alpm_graph_t; alpm_graph_t *_alpm_graph_new(void); diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index 4126e1a..b6b8e2b 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -55,7 +55,6 @@ struct __alpm_handle_t { alpm_db_t *db_local; /* local db pointer */ alpm_list_t *dbs_sync; /* List of (alpm_db_t *) */ FILE *logstream; /* log file stream pointer */ - int lockfd; /* lock file descriptor */ alpm_trans_t *trans; #ifdef HAVE_LIBCURL @@ -100,6 +99,9 @@ struct __alpm_handle_t { /* error code */ alpm_errno_t pm_errno; + /* lock file descriptor */ + int lockfd; + /* for delta parsing efficiency */ int delta_regex_compiled; regex_t delta_regex; diff --git a/src/pacman/conf.c b/src/pacman/conf.c index cf8a417..258d538 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -746,8 +746,8 @@ struct section_t { int is_options; int parse_options; /* db section option gathering */ - alpm_siglevel_t siglevel; alpm_list_t *servers; + alpm_siglevel_t siglevel; alpm_db_usage_t usage; }; -- 1.8.5.2
On 03/01/14 04:37, Dan McGee wrote:
Noticed using clang and `-Wpadded`.
Should that be added in our --enable-warning-flags option?
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/dload.h | 4 ++-- lib/libalpm/graph.h | 4 ++-- lib/libalpm/handle.h | 4 +++- src/pacman/conf.c | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib/libalpm/dload.h b/lib/libalpm/dload.h index 6c9f7a7..964c338 100644 --- a/lib/libalpm/dload.h +++ b/lib/libalpm/dload.h @@ -31,6 +31,8 @@ struct dload_payload { char *destfile_name; char *content_disp_name; char *fileurl; + alpm_list_t *servers; + long respcode; off_t initial_size; off_t max_size; off_t prevprogress; @@ -39,11 +41,9 @@ struct dload_payload { int errors_ok; int unlink_on_fail; int trust_remote_name; - alpm_list_t *servers; #ifdef HAVE_LIBCURL CURLcode curlerr; /* last error produced by curl */ #endif - long respcode; };
void _alpm_dload_payload_reset(struct dload_payload *payload); diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h index bf06047..8db35bf 100644 --- a/lib/libalpm/graph.h +++ b/lib/libalpm/graph.h @@ -24,12 +24,12 @@ #include "alpm_list.h"
typedef struct __alpm_graph_t { - char state; /* 0: untouched, -1: entered, other: leaving time */ - off_t weight; /* weight of the node */ void *data; struct __alpm_graph_t *parent; /* where did we come from? */ alpm_list_t *children; alpm_list_t *childptr; /* points to a child in children list */ + off_t weight; /* weight of the node */ + char state; /* 0: untouched, -1: entered, other: leaving time */ } alpm_graph_t;
alpm_graph_t *_alpm_graph_new(void); diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h index 4126e1a..b6b8e2b 100644 --- a/lib/libalpm/handle.h +++ b/lib/libalpm/handle.h @@ -55,7 +55,6 @@ struct __alpm_handle_t { alpm_db_t *db_local; /* local db pointer */ alpm_list_t *dbs_sync; /* List of (alpm_db_t *) */ FILE *logstream; /* log file stream pointer */ - int lockfd; /* lock file descriptor */ alpm_trans_t *trans;
#ifdef HAVE_LIBCURL @@ -100,6 +99,9 @@ struct __alpm_handle_t { /* error code */ alpm_errno_t pm_errno;
+ /* lock file descriptor */ + int lockfd; + /* for delta parsing efficiency */ int delta_regex_compiled; regex_t delta_regex; diff --git a/src/pacman/conf.c b/src/pacman/conf.c index cf8a417..258d538 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -746,8 +746,8 @@ struct section_t { int is_options; int parse_options; /* db section option gathering */ - alpm_siglevel_t siglevel; alpm_list_t *servers; + alpm_siglevel_t siglevel; alpm_db_usage_t usage; };
On 03/01/14 04:37, Dan McGee wrote:
Noticed using clang and `-Wpadded`.
Should that be added in our --enable-warning-flags option?
It is very noisy; I added it locally to find these but I wouldn't recommend doing it all the time. It unfortunately nags on both padding within a single struct, as well as padding between individual structs in arrays. One is easily fixable, the other not as much if you truly need all
On Thu, Jan 2, 2014 at 6:13 PM, Allan McRae <allan@archlinux.org> wrote: the fields. -Dan
This was a hack done by me in commit d8e88aa0175fd back in 2007 that is no longer necessary, given a sufficiently smart compiler and one that supports the inline keyword. Signed-off-by: Dan McGee <dan@archlinux.org> --- configure.ac | 2 -- lib/libalpm/Makefile.am | 3 --- m4/acinclude.m4 | 20 -------------------- 3 files changed, 25 deletions(-) diff --git a/configure.ac b/configure.ac index cfcc8d1..8a7e9d4 100644 --- a/configure.ac +++ b/configure.ac @@ -316,8 +316,6 @@ AC_CHECK_MEMBERS([struct statfs.f_flags],,,[[#include <sys/param.h> # Check if we can use symbol visibility support in GCC GCC_VISIBILITY_CC -# Check if we have -fgnu89-inline flag -GCC_GNU89_INLINE_CC # Host-dependant definitions INODECMD="stat -c '%i %n'" diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am index 171bc46..67be2b1 100644 --- a/lib/libalpm/Makefile.am +++ b/lib/libalpm/Makefile.am @@ -18,9 +18,6 @@ else AM_CFLAGS += -fvisibility=internal endif endif -if ENABLE_GNU89_INLINE_CC -AM_CFLAGS += -fgnu89-inline -endif pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libalpm.pc diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 index 294507e..15bb31e 100644 --- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -87,26 +87,6 @@ AC_DEFUN([GCC_VISIBILITY_CC],[ fi ]) -dnl GCC_GNU89_INLINE_CC -dnl checks -fgnu89-inline with the C compiler, if it exists then defines -dnl ENABLE_GNU89_INLINE_CC in both configure script and Makefiles -AC_DEFUN([GCC_GNU89_INLINE_CC],[ - AC_LANG_ASSERT(C) - if test "X$CC" != "X"; then - AC_CACHE_CHECK([for -fgnu89-inline], - gnu89_inline_cv_cc, - [ gnu89_inline_old_cflags="$CFLAGS" - CFLAGS="$CFLAGS -fgnu89-inline" - AC_TRY_COMPILE(,, gnu89_inline_cv_cc=yes, gnu89_inline_cv_cc=no) - CFLAGS="$gnu89_inline_old_cflags" - ]) - if test $gnu89_inline_cv_cc = yes; then - AC_DEFINE([ENABLE_GNU89_INLINE_CC], 1, [Define if gnu89 inlining semantics should be used.]) - fi - AM_CONDITIONAL([ENABLE_GNU89_INLINE_CC], test "x$gnu89_inline_cv_cc" = "xyes") - fi -]) - dnl CFLAGS_ADD(PARAMETER, VARIABLE) dnl Adds parameter to VARIABLE if the compiler supports it. For example, dnl CFLAGS_ADD([-Wall],[WARN_FLAGS]). -- 1.8.5.2
This shrinks down the total size of the package struct by a handful of bytes, saving us some memory and cache pressure when we are loading up the entirety of the sync and local databases. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/package.h | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h index 07b043c..9fb83de 100644 --- a/lib/libalpm/package.h +++ b/lib/libalpm/package.h @@ -102,18 +102,6 @@ struct __alpm_pkg_t { off_t isize; off_t download_size; - int scriptlet; - - alpm_pkgreason_t reason; - alpm_pkgvalidation_t validation; - alpm_dbinfrq_t infolevel; - alpm_pkgfrom_t origin; - /* origin == PKG_FROM_FILE, use pkg->origin_data.file - * origin == PKG_FROM_*DB, use pkg->origin_data.db */ - union { - alpm_db_t *db; - char *file; - } origin_data; alpm_handle_t *handle; alpm_list_t *licenses; @@ -131,6 +119,19 @@ struct __alpm_pkg_t { struct pkg_operations *ops; alpm_filelist_t files; + + /* origin == PKG_FROM_FILE, use pkg->origin_data.file + * origin == PKG_FROM_*DB, use pkg->origin_data.db */ + union { + alpm_db_t *db; + char *file; + } origin_data; + + alpm_dbinfrq_t infolevel; + alpm_pkgvalidation_t validation; + alpm_pkgfrom_t origin; + alpm_pkgreason_t reason; + unsigned int scriptlet; }; alpm_file_t *_alpm_file_copy(alpm_file_t *dest, const alpm_file_t *src); -- 1.8.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/db.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 2069a7b..9f7d669 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -457,7 +457,8 @@ alpm_list_t *_alpm_db_search(alpm_db_t *db, const alpm_list_t *needles) if(matched != NULL) { _alpm_log(db->handle, ALPM_LOG_DEBUG, - "search target '%s' matched '%s'\n", targ, matched); + "search target '%s' matched '%s' on package '%s'\n", + targ, matched, name); ret = alpm_list_add(ret, pkg); } } -- 1.8.5.2
When calling open(), use O_CLOEXEC as much as possible to ensure the file descriptor is closed when and if a process using libalpm forks. For most of these cases, and especially in utility functions, the file descriptor is opened and closed in the same function, so we don't have too much to worry about. However, for things like the log file and database lock file, we should ensure descriptors aren't left hanging around for children to touch. This patch is inspired by the problem in FS#36161, where an open file descriptor to the current working directory prevents chroot() from working on FreeBSD. We don't need this file descriptor in the child process, so open it (and now several others) with O_CLOEXEC. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/add.c | 2 +- lib/libalpm/handle.c | 2 +- lib/libalpm/log.c | 11 +++++++++-- lib/libalpm/util.c | 14 +++++++------- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c index 214e78e..fa8da4d 100644 --- a/lib/libalpm/add.c +++ b/lib/libalpm/add.c @@ -556,7 +556,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg, } /* save the cwd so we can restore it later */ - OPEN(cwdfd, ".", O_RDONLY); + OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC); if(cwdfd < 0) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n")); } diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 1d661a2..f30597d 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -110,7 +110,7 @@ int _alpm_handle_lock(alpm_handle_t *handle) FREE(dir); do { - handle->lockfd = open(handle->lockfile, O_WRONLY | O_CREAT | O_EXCL, 0000); + handle->lockfd = open(handle->lockfile, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0000); } while(handle->lockfd == -1 && errno == EINTR); return (handle->lockfd >= 0 ? 0 : -1); diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c index 271bd00..183ff22 100644 --- a/lib/libalpm/log.c +++ b/lib/libalpm/log.c @@ -49,9 +49,16 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix, /* check if the logstream is open already, opening it if needed */ if(handle->logstream == NULL) { - handle->logstream = fopen(handle->logfile, "a"); + int fd; + do { + fd = open(handle->logfile, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, + 0000); + } while(fd == -1 && errno == EINTR); + if(fd >= 0) { + handle->logstream = fdopen(fd, "a"); + } /* if we couldn't open it, we have an issue */ - if(handle->logstream == NULL) { + if(fd < 0 || handle->logstream == NULL) { if(errno == EACCES) { handle->pm_errno = ALPM_ERR_BADPERMS; } else if(errno == ENOENT) { diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 40a5ebd..7ceabf2 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -153,9 +153,9 @@ int _alpm_copyfile(const char *src, const char *dest) MALLOC(buf, (size_t)ALPM_BUFFER_SIZE, return 1); - OPEN(in, src, O_RDONLY); + OPEN(in, src, O_RDONLY | O_CLOEXEC); do { - out = open(dest, O_WRONLY | O_CREAT, 0000); + out = open(dest, O_WRONLY | O_CREAT | O_BINARY | O_CLOEXEC, 0000); } while(out == -1 && errno == EINTR); if(in < 0 || out < 0) { goto cleanup; @@ -244,7 +244,7 @@ int _alpm_open_archive(alpm_handle_t *handle, const char *path, archive_read_support_format_all(*archive); _alpm_log(handle, ALPM_LOG_DEBUG, "opening archive %s\n", path); - OPEN(fd, path, O_RDONLY); + OPEN(fd, path, O_RDONLY | O_CLOEXEC); if(fd < 0) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not open file %s: %s\n"), path, strerror(errno)); @@ -326,7 +326,7 @@ int _alpm_unpack(alpm_handle_t *handle, const char *path, const char *prefix, oldmask = umask(0022); /* save the cwd so we can restore it later */ - OPEN(cwdfd, ".", O_RDONLY); + OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC); if(cwdfd < 0) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n")); } @@ -502,7 +502,7 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) int retval = 0; /* save the cwd so we can restore it later */ - OPEN(cwdfd, ".", O_RDONLY); + OPEN(cwdfd, ".", O_RDONLY | O_CLOEXEC); if(cwdfd < 0) { _alpm_log(handle, ALPM_LOG_ERROR, _("could not get current working directory\n")); } @@ -778,7 +778,7 @@ static int md5_file(const char *path, unsigned char output[16]) MALLOC(buf, (size_t)ALPM_BUFFER_SIZE, return 1); - OPEN(fd, path, O_RDONLY); + OPEN(fd, path, O_RDONLY | O_CLOEXEC); if(fd < 0) { free(buf); return 1; @@ -820,7 +820,7 @@ static int sha2_file(const char *path, unsigned char output[32], int is224) MALLOC(buf, (size_t)ALPM_BUFFER_SIZE, return 1); - OPEN(fd, path, O_RDONLY); + OPEN(fd, path, O_RDONLY | O_CLOEXEC); if(fd < 0) { free(buf); return 1; -- 1.8.5.2
Signed-off-by: Dan McGee <dan@archlinux.org> --- .gitignore | 2 -- test/.gitignore | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 test/.gitignore diff --git a/.gitignore b/.gitignore index df0f138..09ed787 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,3 @@ pacman-*.tar.gz root stamp-h1 tags -*.log -*.trs diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..7e563b8 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,2 @@ +*.log +*.trs -- 1.8.5.2
On 03/01/14 04:37, Dan McGee wrote:
Two issues have snuck in that prevent the compile from working.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
This and the rest of the patches available on my 'random-fixes' branch.
lib/libalpm/sync.c | 2 +- src/pacman/package.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index e358585..9531fa2 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1225,7 +1225,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) return -1; }
-#if HAVE_LIBGPGME +#ifdef HAVE_LIBGPGME
I not that #if and #ifdef are both used in many places. $ git grep "#if HAVE_" lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/sync.c:#if HAVE_LIBGPGME m4/acinclude.m4:#if HAVE_SYS_UCRED_H Should all these change?
/* make sure all required signatures are in keyring */ if(check_keyring(handle)) { return -1; diff --git a/src/pacman/package.c b/src/pacman/package.c index 52219ff..c44696b 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -193,6 +193,10 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) }
if(from == ALPM_PKG_FROM_SYNCDB && extra) { + string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg), cols); + string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); + +#ifdef HAVE_LIBGPGME
I went for the approach of exposing alpm_decode_signature even if GPGME is unavailable, because it does not require any GPGME functions and it could still be useful for a frontend: https://patchwork.archlinux.org/patch/1790/
const char *base64_sig = alpm_pkg_get_base64_sig(pkg); alpm_list_t *keys = NULL; if(base64_sig) { @@ -204,10 +208,8 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) } else { keys = alpm_list_add(keys, _("None")); } - - string_display(_("MD5 Sum :"), alpm_pkg_get_md5sum(pkg), cols); - string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); list_display(_("Signatures :"), keys, cols); +#endif } else { list_display(_("Validated By :"), validation, cols); }
On Thu, Jan 2, 2014 at 4:07 PM, Allan McRae <allan@archlinux.org> wrote:
On 03/01/14 04:37, Dan McGee wrote:
Two issues have snuck in that prevent the compile from working.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
This and the rest of the patches available on my 'random-fixes' branch.
lib/libalpm/sync.c | 2 +- src/pacman/package.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index e358585..9531fa2 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1225,7 +1225,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) return -1; }
-#if HAVE_LIBGPGME +#ifdef HAVE_LIBGPGME
I not that #if and #ifdef are both used in many places.
I think you want to stick with one of two approaches: * #if defined(HAVE_LIBGPGME) * #ifdef HAVE_LIBGPGME We seem to use both of these; however we don't use the `#if <symbol>` approach anywhere outside of signing.c. I agree that all of them in signing.c should be brought into compliance, not sure why I only changed one.
$ git grep "#if HAVE_" lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/sync.c:#if HAVE_LIBGPGME m4/acinclude.m4:#if HAVE_SYS_UCRED_H
Should all these change?
commit 87ffc648b7bce35d shows that we use #ifdef and not #if in sync.c; are we looking at different codebases?
/* make sure all required signatures are in keyring */ if(check_keyring(handle)) { return -1; diff --git a/src/pacman/package.c b/src/pacman/package.c index 52219ff..c44696b 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -193,6 +193,10 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) }
if(from == ALPM_PKG_FROM_SYNCDB && extra) { + string_display(_("MD5 Sum :"),
alpm_pkg_get_md5sum(pkg), cols);
+ string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); + +#ifdef HAVE_LIBGPGME
I went for the approach of exposing alpm_decode_signature even if GPGME is unavailable, because it does not require any GPGME functions and it could still be useful for a frontend: https://patchwork.archlinux.org/patch/1790/
I like your approach, that makes more sense and means frontend code doesn't have to know how the backend library was built.
const char *base64_sig = alpm_pkg_get_base64_sig(pkg); alpm_list_t *keys = NULL; if(base64_sig) { @@ -204,10 +208,8 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) } else { keys = alpm_list_add(keys, _("None")); } - - string_display(_("MD5 Sum :"),
alpm_pkg_get_md5sum(pkg), cols);
- string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); list_display(_("Signatures :"), keys, cols); +#endif } else { list_display(_("Validated By :"), validation, cols); }
Given the overlap in our changes and thoughts here, do you want me to bother resubmitting this? I can go back and review your patches if that makes more sense, let me know.
-Dan
On 10/01/14 01:55, Dan McGee wrote:
On Thu, Jan 2, 2014 at 4:07 PM, Allan McRae <allan@archlinux.org> wrote:
On 03/01/14 04:37, Dan McGee wrote:
Two issues have snuck in that prevent the compile from working.
Signed-off-by: Dan McGee <dan@archlinux.org> ---
This and the rest of the patches available on my 'random-fixes' branch.
lib/libalpm/sync.c | 2 +- src/pacman/package.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index e358585..9531fa2 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -1225,7 +1225,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) return -1; }
-#if HAVE_LIBGPGME +#ifdef HAVE_LIBGPGME
I not that #if and #ifdef are both used in many places.
I think you want to stick with one of two approaches:
* #if defined(HAVE_LIBGPGME) * #ifdef HAVE_LIBGPGME
We seem to use both of these; however we don't use the `#if <symbol>` approach anywhere outside of signing.c. I agree that all of them in signing.c should be brought into compliance, not sure why I only changed one.
Great. #ifdef it is then.
$ git grep "#if HAVE_" lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/signing.c:#if HAVE_LIBGPGME lib/libalpm/sync.c:#if HAVE_LIBGPGME m4/acinclude.m4:#if HAVE_SYS_UCRED_H
Should all these change?
commit 87ffc648b7bce35d shows that we use #ifdef and not #if in sync.c; are we looking at different codebases?
Probably the codebase with my alternative patch to this issue.
/* make sure all required signatures are in keyring */ if(check_keyring(handle)) { return -1; diff --git a/src/pacman/package.c b/src/pacman/package.c index 52219ff..c44696b 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -193,6 +193,10 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) }
if(from == ALPM_PKG_FROM_SYNCDB && extra) { + string_display(_("MD5 Sum :"),
alpm_pkg_get_md5sum(pkg), cols);
+ string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); + +#ifdef HAVE_LIBGPGME
I went for the approach of exposing alpm_decode_signature even if GPGME is unavailable, because it does not require any GPGME functions and it could still be useful for a frontend: https://patchwork.archlinux.org/patch/1790/
I like your approach, that makes more sense and means frontend code doesn't have to know how the backend library was built.
const char *base64_sig = alpm_pkg_get_base64_sig(pkg); alpm_list_t *keys = NULL; if(base64_sig) { @@ -204,10 +208,8 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) } else { keys = alpm_list_add(keys, _("None")); } - - string_display(_("MD5 Sum :"),
alpm_pkg_get_md5sum(pkg), cols);
- string_display(_("SHA-256 Sum :"), alpm_pkg_get_sha256sum(pkg), cols); list_display(_("Signatures :"), keys, cols); +#endif } else { list_display(_("Validated By :"), validation, cols); }
Given the overlap in our changes and thoughts here, do you want me to bother resubmitting this? I can go back and review your patches if that makes more sense, let me know.
My patch was rather simple, so no need (unless you are bored...). I'll add the extra #if -> #ifdef. Allan
participants (3)
-
Allan McRae
-
Dan McGee
-
Dan McGee