Add upstream patch to fix test error:

nbd_connect_unix: getlogin: No such device or address
This commit is contained in:
Richard W.M. Jones 2019-08-21 10:00:58 +01:00
parent f0a39ef385
commit d14f6f788e
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,50 @@
From e0b30bceab1cf61d8129b874d0122bc2cccec0e9 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
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

View File

@ -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 <rjones@redhat.com> - 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 <rjones@redhat.com> - 0.9.8-3
- Bump and rebuild to fix releng brokenness.