From d14f6f788ede307e4bcff484c84617d73c9a4b47 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 21 Aug 2019 10:00:58 +0100 Subject: [PATCH] Add upstream patch to fix test error: nbd_connect_unix: getlogin: No such device or address --- ...-Try-LOGNAME-before-using-getlogin_r.patch | 50 +++++++++++++++++++ libnbd.spec | 4 ++ 2 files changed, 54 insertions(+) create mode 100644 0001-lib-Try-LOGNAME-before-using-getlogin_r.patch diff --git a/0001-lib-Try-LOGNAME-before-using-getlogin_r.patch b/0001-lib-Try-LOGNAME-before-using-getlogin_r.patch new file mode 100644 index 0000000..31c0965 --- /dev/null +++ b/0001-lib-Try-LOGNAME-before-using-getlogin_r.patch @@ -0,0 +1,50 @@ +From e0b30bceab1cf61d8129b874d0122bc2cccec0e9 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 21 Aug 2019 09:57:54 +0100 +Subject: [PATCH] lib: Try $LOGNAME before using getlogin_r. + +Fixes tests in Koji which failed with +nbd_connect_unix: getlogin: No such device or address +--- + lib/crypto.c | 18 ++++++++++++++++-- + 1 file changed, 16 insertions(+), 2 deletions(-) + +diff --git a/lib/crypto.c b/lib/crypto.c +index 703bc84..2a59943 100644 +--- a/lib/crypto.c ++++ b/lib/crypto.c +@@ -102,7 +102,7 @@ nbd_unlocked_set_tls_username (struct nbd_handle *h, const char *username) + char * + nbd_unlocked_get_tls_username (struct nbd_handle *h) + { +- char *ret; ++ char *s, *ret; + + if (h->tls_username) { + ret = strdup (h->tls_username); +@@ -113,7 +113,21 @@ nbd_unlocked_get_tls_username (struct nbd_handle *h) + return ret; + } + +- /* Otherwise we return the local login name. */ ++ /* Otherwise we return the local login name. Try $LOGNAME first for ++ * two reasons: (1) So the user can override it. (2) Because ++ * getlogin fails with ENXIO if there is no controlling terminal ++ * (which is often the case in test and embedded environments). ++ */ ++ s = getenv ("LOGNAME"); ++ if (s) { ++ ret = strdup (s); ++ if (ret == NULL) { ++ set_error (errno, "strdup"); ++ return NULL; ++ } ++ return ret; ++ } ++ + ret = malloc (L_cuserid); + if (ret == NULL) { + set_error (errno, "malloc"); +-- +2.22.0 + diff --git a/libnbd.spec b/libnbd.spec index c6a1bb8..a52b9a3 100644 --- a/libnbd.spec +++ b/libnbd.spec @@ -22,6 +22,8 @@ Source1: http://libguestfs.org/download/libnbd/%{source_directory}/%{name # https://pgp.key-server.io/pks/lookup?search=rjones%40redhat.com&fingerprint=on&op=vindex Source2: libguestfs.keyring +Patch1: 0001-lib-Try-LOGNAME-before-using-getlogin_r.patch + %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool %endif @@ -218,6 +220,8 @@ make %{?_smp_mflags} check || { * Wed Aug 21 2019 Richard W.M. Jones - 0.9.8-4 - Fix nbdkit dependencies so we're actually running the tests. - Add glib2-devel BR so we build the glib main loop example. +- Add upstream patch to fix test error: + nbd_connect_unix: getlogin: No such device or address * Tue Aug 20 2019 Richard W.M. Jones - 0.9.8-3 - Bump and rebuild to fix releng brokenness.