Your message dated Sat, 18 May 2013 11:44:21 +0200
with message-id <[email protected]>
and subject line Both these are fixed
has caused the Debian Bug report #699373,
regarding nbd-client gives cryptic error message with new-style server
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
699373: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699373
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: nbd-client
Version: 1:3.2-2
Severity: normal
Tags: patch

Dear Maintainer,

When trying to connect to a new-style nbd server without
specfying an export name (which is required), the client issues
a cryptic message, and quits:
        nasc0:root ~ 134 # nbd-client nass0 10809 /dev/nbd0
        Negotiation: .Error: Not enough cliserv_magic
        Exiting.

The problem is, that, given an export name, nbd-client assumes
it is connecting to a new-style server. Without an export name,
it assumes it has an old-style server. In both cases, the magic
number does not match if the assumption was incorrect, resulting
in a cryptic error message.

I am attaching a patch relative to
902c07e75f12459c55d79f450a0fb9c1e7da02e5 that fixes the problem.

The patch reverses the checks: first the magic is checked to
determine the kind of server, then either the availability of
an export name is checked for new-style servers (and the client
complains if there is none), or nothing special is done for
old-style servers.

For old-style servers, this patch assumes a 'compatibility mode',
accepting the export name, but not using it. An alternative would
be for nbd-client to fail, complaining that an old-style server
does not support named exports. E.g.:

+               if (name) {
+                       fprintf(stderr, "\nE: Export names not supported by 
server\n");
+                       exit(EXIT_FAILURE);
+               }

Kind regards,

Rogier

----------------------------------------
diff --git a/nbd-client.c b/nbd-client.c
index 1445621..0ac0587 100644
--- a/nbd-client.c
+++ b/nbd-client.c
@@ -235,12 +235,15 @@ void negotiate(int sock, u64 *rsize64, u32 *flags, char* 
name, uint32_t needed_f
        if (read(sock, &magic, sizeof(magic)) < 0)
                err("Failed/2: %m");
        magic = ntohll(magic);
-       if(name) {
+       if(magic == opts_magic) {
                uint32_t opt;
                uint32_t namesize;
 
-               if (magic != opts_magic)
-                       err("Not enough opts_magic");
+               if (!name) {
+                       fprintf(stderr, "\nE: Server uses named exports - 
export name is required\n");
+                       exit(EXIT_FAILURE);
+               }
+
                printf(".");
                if(read(sock, &tmp, sizeof(uint16_t)) < 0) {
                        err("Failed reading flags: %m");
@@ -277,10 +280,10 @@ void negotiate(int sock, u64 *rsize64, u32 *flags, char* 
name, uint32_t needed_f
                        err("Failed/2.4: %m");
                if (write(sock, name, strlen(name)) < 0)
                        err("Failed/2.4: %m");
-       } else {
-               if (magic != cliserv_magic)
-                       err("Not enough cliserv_magic");
+       } else if (magic == cliserv_magic) {
                printf(".");
+       } else {
+               err("No opts_magic or cliserv_magic");
        }
 
        if (read(sock, &size64, sizeof(size64)) <= 0) {
----------------------------------------

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages nbd-client depends on:
ii  debconf [debconf-2.0]  1.5.46
ii  initscripts            2.88dsf-34
ii  libc6                  2.13-37

nbd-client recommends no packages.

nbd-client suggests no packages.

-- debconf information excluded

--- End Message ---
--- Begin Message ---
Version: 1:3.3-2

I forgot to mention this in the changelog, but both these bugs were
closed with the 3.3 upload.

-- 
This end should point toward the ground if you want to go to space.

If it starts pointing toward space you are having a bad problem and you
will not go to space today.

  -- http://xkcd.com/1133/

--- End Message ---

Reply via email to