Package: release.debian.org
Severity: normal
User: release.debian....@packages.debian.org
Usertags: unblock
X-Debbugs-Cc: car...@debian.org,ben...@debian.org

Hi Release team

[Disclaimer, not the maintainer requesting the unblock, but I'm CC'ing
Hilko to confirm].

Please unblock package libnbd

[ Reason ]
The new upstream version uploaded libnbd/1.6.2-1 contains as fix for
CVE-2021-20286. I was announced as
https://listman.redhat.com/archives/libguestfs/2021-March/msg00092.html
. An isolated fix was
https://gitlab.com/nbdkit/libnbd/-/commit/2216190ecbbd853648df6a3280c17b345b0907a0
. The request is done to have bullseye without this CVE open.

[ Impact ]
Denial of service.

[ Tests ]
I have not performed tests specific to the version update 1.6.1 to
1.6.2.

[ Risks ]
Arguably there is a new upstream version, but the attached debdiff
collects all the changes additionally done.

Again, Hilko is CC'ed to confirm if this is safe for bullseye.

[ Checklist ]
  [ ] all changes are documented in the d/changelog
  [ ] I reviewed all changes and I approve them
  [x] attach debdiff against the package in testing

[ Other info ]
It should propably have an explicit acknowledgment for the unblock
from Hilko.

unblock libnbd/1.6.2-1

Regards,
Salvatore
diff -Nru libnbd-1.6.1/Makefile.in libnbd-1.6.2/Makefile.in
--- libnbd-1.6.1/Makefile.in    2021-01-20 14:12:55.000000000 +0100
+++ libnbd-1.6.2/Makefile.in    2021-03-02 22:35:29.000000000 +0100
@@ -204,7 +204,8 @@
        $(srcdir)/podwrapper.pl.in $(srcdir)/run.in \
        $(top_srcdir)/common-rules.mk \
        $(top_srcdir)/lib/local/libnbd.pc.in COPYING.LIB README TODO \
-       compile config.guess config.sub install-sh ltmain.sh missing
+       compile config.guess config.sub depcomp install-sh ltmain.sh \
+       missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -412,6 +413,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/bash/Makefile.in libnbd-1.6.2/bash/Makefile.in
--- libnbd-1.6.1/bash/Makefile.in       2021-01-20 14:12:55.000000000 +0100
+++ libnbd-1.6.2/bash/Makefile.in       2021-03-02 22:35:29.000000000 +0100
@@ -380,6 +380,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/common/include/Makefile.in 
libnbd-1.6.2/common/include/Makefile.in
--- libnbd-1.6.1/common/include/Makefile.in     2021-01-20 14:12:55.000000000 
+0100
+++ libnbd-1.6.2/common/include/Makefile.in     2021-03-02 22:35:29.000000000 
+0100
@@ -346,6 +346,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/common/utils/Makefile.in 
libnbd-1.6.2/common/utils/Makefile.in
--- libnbd-1.6.1/common/utils/Makefile.in       2021-01-20 14:12:55.000000000 
+0100
+++ libnbd-1.6.2/common/utils/Makefile.in       2021-03-02 22:35:29.000000000 
+0100
@@ -397,6 +397,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/configure libnbd-1.6.2/configure
--- libnbd-1.6.1/configure      2021-01-20 14:12:55.000000000 +0100
+++ libnbd-1.6.2/configure      2021-03-02 22:35:29.000000000 +0100
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libnbd 1.6.1.
+# Generated by GNU Autoconf 2.69 for libnbd 1.6.2.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@
 # Identity of this package.
 PACKAGE_NAME='libnbd'
 PACKAGE_TARNAME='libnbd'
-PACKAGE_VERSION='1.6.1'
-PACKAGE_STRING='libnbd 1.6.1'
+PACKAGE_VERSION='1.6.2'
+PACKAGE_STRING='libnbd 1.6.2'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -821,6 +821,7 @@
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -934,6 +935,7 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1186,6 +1188,15 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1323,7 +1334,7 @@
 for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
                datadir sysconfdir sharedstatedir localstatedir includedir \
                oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-               libdir localedir mandir
+               libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1436,7 +1447,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libnbd 1.6.1 to adapt to many kinds of systems.
+\`configure' configures libnbd 1.6.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1476,6 +1487,7 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1506,7 +1518,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libnbd 1.6.1:";;
+     short | recursive ) echo "Configuration of libnbd 1.6.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1657,7 +1669,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libnbd configure 1.6.1
+libnbd configure 1.6.2
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2189,7 +2201,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libnbd $as_me 1.6.1, which was
+It was created by libnbd $as_me 1.6.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4626,7 +4638,7 @@
 
 # Define the identity of the package.
  PACKAGE='libnbd'
- VERSION='1.6.1'
+ VERSION='1.6.2'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -20813,7 +20825,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libnbd $as_me 1.6.1, which was
+This file was extended by libnbd $as_me 1.6.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20879,7 +20891,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libnbd config.status 1.6.1
+libnbd config.status 1.6.2
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -Nru libnbd-1.6.1/configure.ac libnbd-1.6.2/configure.ac
--- libnbd-1.6.1/configure.ac   2021-01-20 14:12:43.000000000 +0100
+++ libnbd-1.6.2/configure.ac   2021-03-02 22:35:15.000000000 +0100
@@ -15,7 +15,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
-AC_INIT([libnbd],[1.6.1])
+AC_INIT([libnbd],[1.6.2])
 
 AC_CONFIG_MACRO_DIR([m4])
 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],[],
diff -Nru libnbd-1.6.1/copy/Makefile.in libnbd-1.6.2/copy/Makefile.in
--- libnbd-1.6.1/copy/Makefile.in       2021-01-20 14:12:55.000000000 +0100
+++ libnbd-1.6.2/copy/Makefile.in       2021-03-02 22:35:29.000000000 +0100
@@ -663,6 +663,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/copy/main.c libnbd-1.6.2/copy/main.c
--- libnbd-1.6.1/copy/main.c    2020-12-05 17:32:32.000000000 +0100
+++ libnbd-1.6.2/copy/main.c    2021-03-02 22:32:34.000000000 +0100
@@ -392,12 +392,18 @@
       !nbd_can_meta_context (src.u.nbd.handles.ptr[0], "base:allocation"))
     extents = false;
 
+  /* Always set the progress bar to 0% at the start of the copy. */
+  progress_bar (0, 1);
+
   /* Start copying. */
   if (synchronous)
     synch_copying ();
   else
     multi_thread_copying ();
 
+  /* Always set the progress bar to 100% at the end of the copy. */
+  progress_bar (1, 1);
+
   /* Shut down the source side. */
   src.ops->close (&src);
 
diff -Nru libnbd-1.6.1/copy/multi-thread-copying.c 
libnbd-1.6.2/copy/multi-thread-copying.c
--- libnbd-1.6.1/copy/multi-thread-copying.c    2021-01-20 14:12:05.000000000 
+0100
+++ libnbd-1.6.2/copy/multi-thread-copying.c    2021-03-02 22:33:05.000000000 
+0100
@@ -122,9 +122,6 @@
     }
   }
 
-  /* Set the progress bar to 100/100 to indicate we're done. */
-  progress_bar (1, 1);
-
   free (workers);
 }
 
diff -Nru libnbd-1.6.1/copy/nbd-ops.c libnbd-1.6.2/copy/nbd-ops.c
--- libnbd-1.6.1/copy/nbd-ops.c 2020-12-05 17:32:32.000000000 +0100
+++ libnbd-1.6.2/copy/nbd-ops.c 2021-03-02 22:33:31.000000000 +0100
@@ -268,6 +268,7 @@
   ret->size = 0;
 
   while (count > 0) {
+    const uint64_t old_offset = offset;
     size_t i;
 
     exts.size = 0;
@@ -283,28 +284,11 @@
       exit (EXIT_FAILURE);
     }
 
-    /* The server should always make progress. */
-    if (exts.size == 0) {
-      fprintf (stderr, "%s: NBD server is broken: it is not returning extent 
information.\nTry nbdcopy --no-extents as a workaround.\n",
-               rw->name);
-      exit (EXIT_FAILURE);
-    }
-
-    /* Copy the extents returned into the final list (ret).  This is
-     * complicated because the extents returned by the server may
-     * begin earlier and begin or end later than the requested size.
-     */
+    /* Copy the extents returned into the final list (ret). */
     for (i = 0; i < exts.size; ++i) {
       uint64_t d;
 
-      if (exts.ptr[i].offset + exts.ptr[i].length <= offset)
-        continue;
-      if (exts.ptr[i].offset < offset) {
-        d = offset - exts.ptr[i].offset;
-        exts.ptr[i].offset += d;
-        exts.ptr[i].length -= d;
-        assert (exts.ptr[i].offset == offset);
-      }
+      assert (exts.ptr[i].offset == offset);
       if (exts.ptr[i].offset + exts.ptr[i].length > offset + count) {
         d = exts.ptr[i].offset + exts.ptr[i].length - offset - count;
         exts.ptr[i].length -= d;
@@ -320,6 +304,13 @@
       offset += exts.ptr[i].length;
       count -= exts.ptr[i].length;
     }
+
+    /* The server should always make progress. */
+    if (offset == old_offset) {
+      fprintf (stderr, "%s: NBD server is broken: it is not returning extent 
information.\nTry nbdcopy --no-extents as a workaround.\n",
+               rw->name);
+      exit (EXIT_FAILURE);
+    }
   }
 
   free (exts.ptr);
diff -Nru libnbd-1.6.1/copy/nbdcopy.pod libnbd-1.6.2/copy/nbdcopy.pod
--- libnbd-1.6.1/copy/nbdcopy.pod       2021-01-20 14:12:18.000000000 +0100
+++ libnbd-1.6.2/copy/nbdcopy.pod       2021-03-02 22:33:24.000000000 +0100
@@ -83,7 +83,7 @@
 
 Normally nbdcopy tries to create sparse output (with holes) if the
 destination supports that.  It does this in two ways: either using
-extent informtation from the source to copy holes (see
+extent information from the source to copy holes (see
 I<--no-extents>), or by detecting runs of zeroes (see I<-S>).  If you
 use I<--allocated> then nbdcopy creates a fully allocated, non-sparse
 output on the destination.
diff -Nru libnbd-1.6.1/copy/progress.c libnbd-1.6.2/copy/progress.c
--- libnbd-1.6.1/copy/progress.c        2020-12-05 16:26:34.000000000 +0100
+++ libnbd-1.6.2/copy/progress.c        2021-03-02 22:30:57.000000000 +0100
@@ -35,8 +35,15 @@
 static void
 do_progress_bar (off_t pos, int64_t size)
 {
-  static const char *spinner[] = { "◐", "◓", "◑", "◒" };
   static int tty = -1;
+
+  /* Note the spinner is covered with the cursor which usually makes
+   * it appear inverse video.
+   */
+  static const char *spinner[] = { "▝", "▐", "▗", "▃", "▖", "▍", "▘", "▀" };
+  static const char *spinner_100 = "█";
+  static int spinpos = 0;
+
   double frac = (double) pos / size;
   char msg[80];
   size_t n, i;
@@ -50,14 +57,18 @@
   if (frac < 0) frac = 0; else if (frac > 1) frac = 1;
 
   if (frac == 1) {
-    snprintf (msg, sizeof msg, "● 100%% 
[****************************************]\n");
+    snprintf (msg, sizeof msg,
+              "%s 100%% [****************************************]\n",
+              spinner_100);
     progress = false; /* Don't print any more progress bar messages. */
   } else {
-    snprintf (msg, sizeof msg, "%s %3d%% 
[----------------------------------------]\r",
-              spinner[(int)(4*frac)], (int)(100*frac));
+    snprintf (msg, sizeof msg,
+              "%s %3d%% [----------------------------------------]\r",
+              spinner[spinpos], (int)(100*frac));
     n = strcspn (msg, "-");
     for (i = 0; i < 40*frac; ++i)
       msg[n+i] = '*';
+    spinpos = (spinpos+1) % (sizeof spinner / sizeof spinner[0]);
   }
 
 #pragma GCC diagnostic push
diff -Nru libnbd-1.6.1/copy/synch-copying.c libnbd-1.6.2/copy/synch-copying.c
--- libnbd-1.6.1/copy/synch-copying.c   2020-12-05 16:26:34.000000000 +0100
+++ libnbd-1.6.2/copy/synch-copying.c   2021-03-02 22:33:05.000000000 +0100
@@ -99,7 +99,4 @@
       free (exts.ptr);
     } /* while */
   }
-
-  /* Always set the progress bar to 100% at the end of the copy. */
-  progress_bar (1, 1);
 }
diff -Nru libnbd-1.6.1/debian/changelog libnbd-1.6.2/debian/changelog
--- libnbd-1.6.1/debian/changelog       2021-02-10 00:20:57.000000000 +0100
+++ libnbd-1.6.2/debian/changelog       2021-03-03 09:36:41.000000000 +0100
@@ -1,3 +1,9 @@
+libnbd (1.6.2-1) unstable; urgency=medium
+
+  * New upstream version 1.6.2
+
+ -- Hilko Bengen <ben...@debian.org>  Wed, 03 Mar 2021 09:36:41 +0100
+
 libnbd (1.6.1-1) unstable; urgency=medium
 
   * New upstream version 1.6.1
diff -Nru libnbd-1.6.1/docs/Makefile.in libnbd-1.6.2/docs/Makefile.in
--- libnbd-1.6.1/docs/Makefile.in       2021-01-20 14:12:55.000000000 +0100
+++ libnbd-1.6.2/docs/Makefile.in       2021-03-02 22:35:29.000000000 +0100
@@ -388,6 +388,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/docs/libnbd.pod libnbd-1.6.2/docs/libnbd.pod
--- libnbd-1.6.1/docs/libnbd.pod        2020-12-12 23:21:56.000000000 +0100
+++ libnbd-1.6.2/docs/libnbd.pod        2021-03-02 22:31:24.000000000 +0100
@@ -402,8 +402,7 @@
 
 libnbd supports the
 L<NBD URI 
specification|https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.md>.
-The URIs that libnbd currently supports is documented in
-L<nbd_connect_uri(3)>.
+The format of URIs is documented in L<nbd_connect_uri(3)>.
 
 You can connect to a URI as in these examples (using the high level
 API):
@@ -869,6 +868,11 @@
 
  cc prog.c -o prog `pkg-config libnbd --cflags --libs`
 
+To compile an external project against a built copy of the libnbd
+source tree which hasn't been installed, see the F<./run> script.
+
+=head2 Autoconf projects
+
 External projects which use autoconf and need to check if libnbd is
 installed should use the C<PKG_CHECK_MODULES> macro in F<configure.ac>
 like this:
@@ -878,6 +882,8 @@
 This will define C<@LIBNBD_CFLAGS@> and C<@LIBNBD_LIBS@> which you
 will need to add to your F<Makefile.am>.
 
+=head2 CMake projects
+
 For CMake projects use:
 
  find_package(PkgConfig REQUIRED)
@@ -886,8 +892,12 @@
  target_include_directories(prog PUBLIC ${LIBNBD_INCLUDE_DIRS})
  target_compile_options(prog PUBLIC ${LIBNBD_CFLAGS_OTHER})
 
-To compile an external project against a built copy of the libnbd
-source tree which hasn't been installed, see the F<./run> script.
+=head2 Meson projects
+
+For meson projects use:
+
+ nbd_dep = dependency('libnbd')
+ executable('prog', 'prog.c', dependencies : [nbd_dep])
 
 =head1 ENVIRONMENT VARIABLES
 
diff -Nru libnbd-1.6.1/examples/Makefile.in libnbd-1.6.2/examples/Makefile.in
--- libnbd-1.6.1/examples/Makefile.in   2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/examples/Makefile.in   2021-03-02 22:35:29.000000000 +0100
@@ -555,6 +555,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/fuse/Makefile.in libnbd-1.6.2/fuse/Makefile.in
--- libnbd-1.6.1/fuse/Makefile.in       2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/fuse/Makefile.in       2021-03-02 22:35:29.000000000 +0100
@@ -629,6 +629,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/fuzzing/Makefile.in libnbd-1.6.2/fuzzing/Makefile.in
--- libnbd-1.6.1/fuzzing/Makefile.in    2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/fuzzing/Makefile.in    2021-03-02 22:35:29.000000000 +0100
@@ -416,6 +416,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/generator/Makefile.in libnbd-1.6.2/generator/Makefile.in
--- libnbd-1.6.1/generator/Makefile.in  2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/generator/Makefile.in  2021-03-02 22:35:29.000000000 +0100
@@ -346,6 +346,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/generator/states-connect.c 
libnbd-1.6.2/generator/states-connect.c
--- libnbd-1.6.1/generator/states-connect.c     2020-11-28 21:25:58.000000000 
+0100
+++ libnbd-1.6.2/generator/states-connect.c     2021-03-02 22:31:33.000000000 
+0100
@@ -47,11 +47,12 @@
 
 STATE_MACHINE {
  CONNECT.START:
-  int fd;
+  sa_family_t family;
+  int fd, r;
 
   assert (!h->sock);
-  fd = socket (h->connaddr.ss_family,
-               SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
+  family = h->connaddr.ss_family;
+  fd = socket (family, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
   if (fd == -1) {
     SET_NEXT_STATE (%.DEAD);
     set_error (errno, "socket");
@@ -65,14 +66,28 @@
 
   disable_nagle (fd);
 
-  if (connect (fd, (struct sockaddr *) &h->connaddr,
-               h->connaddrlen) == -1) {
-    if (errno != EINPROGRESS) {
-      SET_NEXT_STATE (%.DEAD);
-      set_error (errno, "connect");
-      return 0;
-    }
+  r = connect (fd, (struct sockaddr *) &h->connaddr, h->connaddrlen);
+  if (r == 0 || (r == -1 && errno == EINPROGRESS))
+    return 0;
+  assert (r == -1);
+#ifdef __linux__
+  if (errno == EAGAIN && family == AF_UNIX) {
+    /* This can happen on Linux when connecting to a Unix domain
+     * socket, if the server's backlog is full.  Unfortunately there
+     * is nothing good we can do on the client side when this happens
+     * since any solution would involve sleeping or busy-waiting.  The
+     * only solution is on the server side, increasing the backlog.
+     * But at least improve the error message.
+     * https://bugzilla.redhat.com/1925045
+     */
+    SET_NEXT_STATE (%.DEAD);
+    set_error (errno, "connect: server backlog overflowed, "
+               "see https://bugzilla.redhat.com/1925045";);
+    return 0;
   }
+#endif
+  SET_NEXT_STATE (%.DEAD);
+  set_error (errno, "connect");
   return 0;
 
  CONNECT.CONNECTING:
diff -Nru libnbd-1.6.1/golang/Makefile.in libnbd-1.6.2/golang/Makefile.in
--- libnbd-1.6.1/golang/Makefile.in     2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/golang/Makefile.in     2021-03-02 22:35:29.000000000 +0100
@@ -558,6 +558,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/golang/examples/Makefile.in 
libnbd-1.6.2/golang/examples/Makefile.in
--- libnbd-1.6.1/golang/examples/Makefile.in    2021-01-20 14:12:56.000000000 
+0100
+++ libnbd-1.6.2/golang/examples/Makefile.in    2021-03-02 22:35:29.000000000 
+0100
@@ -348,6 +348,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/include/Makefile.in libnbd-1.6.2/include/Makefile.in
--- libnbd-1.6.1/include/Makefile.in    2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/include/Makefile.in    2021-03-02 22:35:29.000000000 +0100
@@ -395,6 +395,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/info/Makefile.in libnbd-1.6.2/info/Makefile.in
--- libnbd-1.6.1/info/Makefile.in       2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/info/Makefile.in       2021-03-02 22:35:29.000000000 +0100
@@ -633,6 +633,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/info/nbdinfo.c libnbd-1.6.2/info/nbdinfo.c
--- libnbd-1.6.1/info/nbdinfo.c 2020-11-28 21:25:58.000000000 +0100
+++ libnbd-1.6.2/info/nbdinfo.c 2021-03-02 22:34:33.000000000 +0100
@@ -1,5 +1,5 @@
 /* NBD client library in userspace
- * Copyright (C) 2020 Red Hat Inc.
+ * Copyright (C) 2020-2021 Red Hat Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -416,13 +416,16 @@
 
   /* Collect the metadata we are going to display. If opt_info works,
    * great; if not (such as for legacy newstyle), we have to go all
-   * the way with opt_go.
+   * the way with opt_go.  If we fail to connect (such as a server
+   * advertising something it later refuses to serve), return rather
+   * than exit, to allow output on the rest of the list.
    */
   if (nbd_aio_is_negotiating (nbd) &&
       nbd_opt_info (nbd) == -1 &&
       nbd_opt_go (nbd) == -1) {
-    fprintf (stderr, "%s: %s\n", progname, nbd_get_error ());
-    exit (EXIT_FAILURE);
+    fprintf (stderr, "%s: %s: %s\n", progname, nbd_get_export_name (nbd),
+             nbd_get_error ());
+    return;
   }
   size = nbd_get_size (nbd);
   if (size == -1) {
diff -Nru libnbd-1.6.1/interop/Makefile.in libnbd-1.6.2/interop/Makefile.in
--- libnbd-1.6.1/interop/Makefile.in    2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/interop/Makefile.in    2021-03-02 22:35:29.000000000 +0100
@@ -928,6 +928,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/lib/Makefile.in libnbd-1.6.2/lib/Makefile.in
--- libnbd-1.6.1/lib/Makefile.in        2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/lib/Makefile.in        2021-03-02 22:35:29.000000000 +0100
@@ -456,6 +456,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/lib/opt.c libnbd-1.6.2/lib/opt.c
--- libnbd-1.6.1/lib/opt.c      2020-11-28 21:25:58.000000000 +0100
+++ libnbd-1.6.2/lib/opt.c      2021-03-02 22:34:45.000000000 +0100
@@ -1,5 +1,5 @@
 /* NBD client library in userspace
- * Copyright (C) 2020 Red Hat Inc.
+ * Copyright (C) 2020-2021 Red Hat Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -83,7 +83,8 @@
 
   r = wait_for_option (h);
   if (r == 0 && err) {
-    assert (nbd_internal_is_state_negotiating (get_next_state (h)));
+    assert (nbd_internal_is_state_negotiating (get_next_state (h)) ||
+            nbd_internal_is_state_dead (get_next_state (h)));
     set_error (err, "server replied with error to opt_go request");
     return -1;
   }
@@ -105,7 +106,8 @@
 
   r = wait_for_option (h);
   if (r == 0 && err) {
-    assert (nbd_internal_is_state_negotiating (get_next_state (h)));
+    assert (nbd_internal_is_state_negotiating (get_next_state (h)) ||
+            nbd_internal_is_state_dead (get_next_state (h)));
     set_error (err, "server replied with error to opt_info request");
     return -1;
   }
diff -Nru libnbd-1.6.1/lib/states.c libnbd-1.6.2/lib/states.c
--- libnbd-1.6.1/lib/states.c   2021-01-20 14:13:27.000000000 +0100
+++ libnbd-1.6.2/lib/states.c   2021-03-02 22:36:05.000000000 +0100
@@ -799,11 +799,12 @@
 {
 #line 49 "generator/states-connect.c"
 
-  int fd;
+  sa_family_t family;
+  int fd, r;
 
   assert (!h->sock);
-  fd = socket (h->connaddr.ss_family,
-               SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
+  family = h->connaddr.ss_family;
+  fd = socket (family, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
   if (fd == -1) {
     SET_NEXT_STATE (STATE_DEAD);
     set_error (errno, "socket");
@@ -817,14 +818,28 @@
 
   disable_nagle (fd);
 
-  if (connect (fd, (struct sockaddr *) &h->connaddr,
-               h->connaddrlen) == -1) {
-    if (errno != EINPROGRESS) {
-      SET_NEXT_STATE (STATE_DEAD);
-      set_error (errno, "connect");
-      return 0;
-    }
+  r = connect (fd, (struct sockaddr *) &h->connaddr, h->connaddrlen);
+  if (r == 0 || (r == -1 && errno == EINPROGRESS))
+    return 0;
+  assert (r == -1);
+#ifdef __linux__
+  if (errno == EAGAIN && family == AF_UNIX) {
+    /* This can happen on Linux when connecting to a Unix domain
+     * socket, if the server's backlog is full.  Unfortunately there
+     * is nothing good we can do on the client side when this happens
+     * since any solution would involve sleeping or busy-waiting.  The
+     * only solution is on the server side, increasing the backlog.
+     * But at least improve the error message.
+     * https://bugzilla.redhat.com/1925045
+     */
+    SET_NEXT_STATE (STATE_DEAD);
+    set_error (errno, "connect: server backlog overflowed, "
+               "see https://bugzilla.redhat.com/1925045";);
+    return 0;
   }
+#endif
+  SET_NEXT_STATE (STATE_DEAD);
+  set_error (errno, "connect");
   return 0;
 
 }
@@ -851,7 +866,7 @@
              enum state *next_state,
              bool *blocked)
 {
-#line 78 "generator/states-connect.c"
+#line 93 "generator/states-connect.c"
 
   int status;
   socklen_t len = sizeof status;
@@ -897,7 +912,7 @@
              enum state *next_state,
              bool *blocked)
 {
-#line 99 "generator/states-connect.c"
+#line 114 "generator/states-connect.c"
 
   int r;
 
@@ -957,7 +972,7 @@
              enum state *next_state,
              bool *blocked)
 {
-#line 134 "generator/states-connect.c"
+#line 149 "generator/states-connect.c"
 
   int fd;
 
@@ -1025,7 +1040,7 @@
              enum state *next_state,
              bool *blocked)
 {
-#line 177 "generator/states-connect.c"
+#line 192 "generator/states-connect.c"
 
   int status;
   socklen_t len = sizeof status;
@@ -1070,7 +1085,7 @@
              enum state *next_state,
              bool *blocked)
 {
-#line 197 "generator/states-connect.c"
+#line 212 "generator/states-connect.c"
 
   if (h->sock) {
     h->sock->ops->close (h->sock);
@@ -1105,7 +1120,7 @@
              enum state *next_state,
              bool *blocked)
 {
-#line 207 "generator/states-connect.c"
+#line 222 "generator/states-connect.c"
 
   int sv[2];
   pid_t pid;
diff -Nru libnbd-1.6.1/ocaml/Makefile.in libnbd-1.6.2/ocaml/Makefile.in
--- libnbd-1.6.1/ocaml/Makefile.in      2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/ocaml/Makefile.in      2021-03-02 22:35:29.000000000 +0100
@@ -469,6 +469,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/ocaml/examples/Makefile.in 
libnbd-1.6.2/ocaml/examples/Makefile.in
--- libnbd-1.6.1/ocaml/examples/Makefile.in     2021-01-20 14:12:56.000000000 
+0100
+++ libnbd-1.6.2/ocaml/examples/Makefile.in     2021-03-02 22:35:29.000000000 
+0100
@@ -349,6 +349,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/ocaml/tests/Makefile.in 
libnbd-1.6.2/ocaml/tests/Makefile.in
--- libnbd-1.6.1/ocaml/tests/Makefile.in        2021-01-20 14:12:56.000000000 
+0100
+++ libnbd-1.6.2/ocaml/tests/Makefile.in        2021-03-02 22:35:29.000000000 
+0100
@@ -598,6 +598,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/python/Makefile.in libnbd-1.6.2/python/Makefile.in
--- libnbd-1.6.1/python/Makefile.in     2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/python/Makefile.in     2021-03-02 22:35:29.000000000 +0100
@@ -622,6 +622,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/sh/Makefile.in libnbd-1.6.2/sh/Makefile.in
--- libnbd-1.6.1/sh/Makefile.in 2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/sh/Makefile.in 2021-03-02 22:35:29.000000000 +0100
@@ -571,6 +571,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/tests/Makefile.in libnbd-1.6.2/tests/Makefile.in
--- libnbd-1.6.1/tests/Makefile.in      2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/tests/Makefile.in      2021-03-02 22:35:29.000000000 +0100
@@ -1474,6 +1474,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@
diff -Nru libnbd-1.6.1/valgrind/Makefile.in libnbd-1.6.2/valgrind/Makefile.in
--- libnbd-1.6.1/valgrind/Makefile.in   2021-01-20 14:12:56.000000000 +0100
+++ libnbd-1.6.2/valgrind/Makefile.in   2021-03-02 22:35:29.000000000 +0100
@@ -348,6 +348,7 @@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
 psdir = @psdir@
+runstatedir = @runstatedir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 srcdir = @srcdir@

Reply via email to