Wouter Verhelst [Tue, 21 Jan 2014 19:52:06 +0000 (20:52 +0100)]
Add README.md to Makefile.am
README files are distributed automatically, but README.md files are not;
so add it explicitly
Wouter Verhelst [Tue, 21 Jan 2014 19:36:18 +0000 (20:36 +0100)]
Create Coverity model
Wouter Verhelst [Tue, 21 Jan 2014 19:16:56 +0000 (20:16 +0100)]
Fix typo
the "dir" parameter contains the name of the directory, while the "dirh"
variable is an opendir() handle that'll only be NULL in case of error.
By complete accident, this compiled, but it wouldn't actually ever do
anything useful.
Wouter Verhelst [Tue, 21 Jan 2014 19:14:06 +0000 (20:14 +0100)]
Don't leak resources
Close the authorized file in _all_ cases, not just when authorized.
Found by coverity scan.
Wouter Verhelst [Tue, 21 Jan 2014 19:12:35 +0000 (20:12 +0100)]
Reformat README to markdown
Wouter Verhelst [Wed, 15 Jan 2014 12:32:09 +0000 (13:32 +0100)]
Make things work again
Wouter Verhelst [Wed, 15 Jan 2014 12:16:33 +0000 (13:16 +0100)]
Tickle the git repository
Did something wrong, hopefully it will work now.
Wouter Verhelst [Wed, 15 Jan 2014 12:13:22 +0000 (13:13 +0100)]
Test build failure mail thing
buildbot has a "send mail upon build failure" option. This should test that.
We'll revert the break once everything seems to work ;-)
Wouter Verhelst [Wed, 15 Jan 2014 09:54:28 +0000 (10:54 +0100)]
Make the implementation of size_autodetect follow the documentation
The documentation claimed that size_autodetect could return UINT64_MAX
if size autodetection would fail. In fact, however, it would call err(),
which is for fatal errors.
Additionally, the final test (to use lseek SEEK_END) would never be
called, since it was preceded by an if structure which would call return
in one of its branches and err() in the other.
Wouter Verhelst [Wed, 15 Jan 2014 09:49:13 +0000 (10:49 +0100)]
Remove off_t from what will eventually be a public API
Since the size of off_t may vary depending on whether the LFS defines
have been set, it is not a good idea to expose that, as the recently
fixed bug has shown. As long as we use nbdsrv.h internally only this
doesn't matter, but since the long-term goal is to make libnbdsrv a
public library, we'd better avoid such an issue.
We'll still use off_t internally, but that won't be exposed anymore.
Wouter Verhelst [Wed, 15 Jan 2014 09:48:47 +0000 (10:48 +0100)]
Remove duplicate ISSERVER definition
Wouter Verhelst [Wed, 15 Jan 2014 00:43:54 +0000 (01:43 +0100)]
Reorder LFS includes so it actually works
Wouter Verhelst [Wed, 15 Jan 2014 00:03:22 +0000 (01:03 +0100)]
Add missing lfs.h include
lfs.h has an influence on sizeof(off_t), which has an influence on the
offsets of the SERVER data type, which makes things fail on 32 bit...
whoops.
Wouter Verhelst [Mon, 13 Jan 2014 19:42:40 +0000 (20:42 +0100)]
Fix cleanup in simple_test
If nbd-server dies during the test for some reason or other, then the
kill call in the cleanup subroutine would fail, causing (due to 'set
-e') the script to abort immediately. As a result, the "rm -rf" of the
tempdir wouldn't happen, which would leave cruft in /tmp.
Fix.
Wouter Verhelst [Mon, 13 Jan 2014 19:21:34 +0000 (20:21 +0100)]
Fully initialize hints
POSIX 1003.1 says:
In this hints structure every member other than ai_flags, ai_family,
ai_socktype, and ai_protocol shall be set to zero or a null pointer.
which Linux doesn't enforce, but FreeBSD does.
Wouter Verhelst [Mon, 13 Jan 2014 18:58:29 +0000 (19:58 +0100)]
Fix missing include
Linux automatically includes <netinet/in.h> as a dependency of one of
the other include files, but this is not required by POSIX, and FreeBSD
doesn't do so.
Since we directly use some of the structs from that file,
add the include
Wouter Verhelst [Fri, 3 Jan 2014 15:44:20 +0000 (16:44 +0100)]
Prepare for 3.6
Wouter Verhelst [Mon, 30 Dec 2013 19:09:07 +0000 (20:09 +0100)]
Switch to xz (and away from bzip2)
Might change back, depending on discussion on mailinglist.
Wouter Verhelst [Mon, 30 Dec 2013 19:08:20 +0000 (20:08 +0100)]
Fix build
If we introduce a new file, we need to make sure to add it to the
Makefile, too, otherwise it won't be distributed...
Wouter Verhelst [Mon, 30 Dec 2013 18:12:28 +0000 (19:12 +0100)]
Add check for size_autodetect
Wouter Verhelst [Mon, 30 Dec 2013 18:00:12 +0000 (19:00 +0100)]
Move size_autodetect to library
Wouter Verhelst [Sun, 29 Dec 2013 01:05:34 +0000 (02:05 +0100)]
Add check for getmaskbyte(), too
Wouter Verhelst [Mon, 23 Dec 2013 19:24:14 +0000 (20:24 +0100)]
Don't forget to distribute this new "macro.h", too
Wouter Verhelst [Mon, 23 Dec 2013 19:22:02 +0000 (20:22 +0100)]
Add a check for append_serve, too
Wouter Verhelst [Mon, 23 Dec 2013 19:21:46 +0000 (20:21 +0100)]
Separate out a useful macro
Wouter Verhelst [Mon, 23 Dec 2013 19:21:14 +0000 (20:21 +0100)]
Update comment to reflect today's realities
Wouter Verhelst [Mon, 23 Dec 2013 19:20:55 +0000 (20:20 +0100)]
Move "append_serve" to library, too.
That completes what can be moved without rewriting anything.
Wouter Verhelst [Mon, 23 Dec 2013 19:20:38 +0000 (20:20 +0100)]
Whitespace fix
Wouter Verhelst [Sun, 22 Dec 2013 15:50:11 +0000 (16:50 +0100)]
Fix Makefile.am's so that "make distcheck" works again
Wouter Verhelst [Sun, 22 Dec 2013 15:25:30 +0000 (16:25 +0100)]
Add .gitignore with compiled files in this directory.
Wouter Verhelst [Sun, 22 Dec 2013 15:24:56 +0000 (16:24 +0100)]
Make it compile (and pass)
Wouter Verhelst [Sun, 22 Dec 2013 15:15:38 +0000 (16:15 +0100)]
Add test for dup_serve
Wouter Verhelst [Sun, 22 Dec 2013 15:15:16 +0000 (16:15 +0100)]
Move dup_serve() to library
Wouter Verhelst [Sun, 22 Dec 2013 15:13:52 +0000 (16:13 +0100)]
Enable maintainer-mode by default
Wouter Verhelst [Wed, 18 Dec 2013 11:24:37 +0000 (12:24 +0100)]
Do a htonl conversion of opt.
Closes github issue #6, but breaks backwards compatibility on
little-endian systems.
I've decided not to care anymore about that. Cross-endian same-version
compatibility matters more than backwards compatibility.
So there.
Wouter Verhelst [Wed, 18 Dec 2013 11:19:10 +0000 (12:19 +0100)]
Add a "code" test suite
This test suite will test functions in libnbdsrv.la. For now, only test
that the authorized_client function does what it's supposed to do.
Wouter Verhelst [Wed, 18 Dec 2013 11:16:48 +0000 (12:16 +0100)]
Make a start with a library
The library does not contain much useful stuff yet, so make it a
noinst_LTLIBRARY for now, rather than a lib_LTLIBRARY.
As we move code to the library, we'll modify it so that it becomes
selfsufficient, and clean it up as we go.
For now, only move the freshly rewritten authorized_client() function
there.
This adds libtool to the list of stuff needed when compiling from git,
but that's not much of an issue.
Wouter Verhelst [Wed, 18 Dec 2013 11:11:50 +0000 (12:11 +0100)]
Separate the test suite out into a separate directory
... in preparation of also adding a "code" test suite which tests
functions in the code, not runtime behaviour of nbd-server
Wouter Verhelst [Wed, 18 Dec 2013 10:13:19 +0000 (11:13 +0100)]
Bring documentation in sync with code
Wouter Verhelst [Wed, 18 Dec 2013 10:04:13 +0000 (11:04 +0100)]
Improve acl file parsing robustness
We now support comments, empty lines, and leading whitespace (which all get
skipped)
Lines with junk will _probably_ get skipped too, depending on how bad
the junk really is.
Wouter Verhelst [Tue, 17 Dec 2013 13:20:27 +0000 (14:20 +0100)]
Unbreak virtstyle parameter parsing
There have been issues with the "cidrhash" option of the "virtstyle"
parameter since a long time, in that the way things were being parsed
wasn't very endian-independent.
Fix it the same way we just fixed the authorized_client function.
Wouter Verhelst [Tue, 17 Dec 2013 13:17:41 +0000 (14:17 +0100)]
Fix authorized_client implementation a bit more
We previously added a fix for CVE-2013-6410, but that one accidentally
broke checks for non-netmasked entries entirely, rather than limiting it
to what it was actually supposed to allow. '\n' is also a character...
This fixes it properly, by not relying on string functions anymore, but
instead parsing all IP addresses to their binary representation, and
comparing that.
As an added bonus, we now also support IPv6 addresses in the ACL file.
Wouter Verhelst [Sat, 7 Dec 2013 01:01:58 +0000 (17:01 -0800)]
Merge pull request #15 from alexsn/master
Fix potential socket leak in opennet()
Mike Frysinger [Mon, 2 Dec 2013 05:26:32 +0000 (00:26 -0500)]
gznbd: fix warning with newer zlib
When you build against newer zlib, you get a lot of warnings like so:
gznbd.c: In function 'main':
gznbd.c:87:5: warning: assignment from incompatible pointer type [enabled by default]
gznbd.c:109:5: warning: passing argument 1 of 'gzread' from incompatible pointer type [enabled by default]
In file included from gznbd.c:37:0:
/usr/include/zlib.h:1313:21: note: expected 'gzFile' but argument is of type 'struct gzFile_s **'
gznbd.c:118:9: warning: passing argument 1 of 'gzerror' from incompatible pointer type [enabled by default]
This is because the zlib API uses just gzFile everywhere, not a pointer
to a gzFile.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Wouter Verhelst <w@uter.be>
Mike Frysinger [Mon, 2 Dec 2013 05:26:31 +0000 (00:26 -0500)]
gznbd: use PRId64 for printing 64bit types
Gcc complains about printing these 64bit types:
gznbd.c:199:1: warning: format '%Ld' expects argument of type 'long long int',
but argument 5 has type 'u64' [-Wformat]
Use the standard defines from inttypes.h to avoid this issue.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Wouter Verhelst <w@uter.be>
Wouter Verhelst [Mon, 2 Dec 2013 09:22:37 +0000 (10:22 +0100)]
Add the actual text of the GPLv2, as the license requires us to
alexsn [Sat, 30 Nov 2013 22:24:39 +0000 (00:24 +0200)]
Update nbd-client.c
Fix potential socket leak in opennet()
Wouter Verhelst [Sat, 30 Nov 2013 22:11:45 +0000 (23:11 +0100)]
Prepare for 3.5
Wouter Verhelst [Tue, 26 Nov 2013 13:32:31 +0000 (14:32 +0100)]
Use strcmp() rather than strncmp()
This results in some false positives. If the authfile contains:
192.168.0.12
and the client is
192.168.0.1
then access will be granted, because the strcmp was limiting to
"192.168.0.1" for no particularly good reason.
We should also canonicalize our names and work on that, rather than
doing a simple strcmp(), but that's for later.
Wouter Verhelst [Tue, 26 Nov 2013 13:25:26 +0000 (14:25 +0100)]
Fix documentation to reflect reality
Wouter Verhelst [Fri, 6 Sep 2013 13:34:56 +0000 (15:34 +0200)]
3.4 was released...
Wouter Verhelst [Wed, 26 Jun 2013 12:08:37 +0000 (14:08 +0200)]
re-enable integrityhuge test
We disabled it at the time because it would deadlock in some cases
(though not on my machine).
Since then, some deadlock fixes have accumulated. I don't know whether
the culprit has been found and remedied, but it doesn't hurt to try. If
it turns out to still be a problem, we can always disable them again
afterwards.
While here, remove generated files ("missing") from git.
Wouter Verhelst [Tue, 18 Jun 2013 06:58:58 +0000 (08:58 +0200)]
Remove the same ioctl() call in another place
Not sure why we do this twice anymore, but hey.
Signed-off-by: Wouter Verhelst <w@uter.be>
Wouter Verhelst [Mon, 17 Jun 2013 20:39:56 +0000 (22:39 +0200)]
Remove obsolete NBD_CLEAR_QUE ioctl.
Signed-off-by: Wouter Verhelst <w@uter.be>
Tuomas Räsänen [Tue, 11 Jun 2013 15:49:58 +0000 (18:49 +0300)]
nbd-server: const'd function parameter variable
Making the parameter variable const revealed a smelly assignment
statement which was deemed unnecessary and hence removed.
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Signed-off-by: Wouter Verhelst <w@uter.be>
Tuomas Räsänen [Tue, 11 Jun 2013 15:49:49 +0000 (18:49 +0300)]
nbd-server: remove superfluous 2nd parameter from handle_oldstyle_connection()
A pointer to the server struct is passed anyways, the socket can be
accessed via that pointer.
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Signed-off-by: Wouter Verhelst <w@uter.be>
Tuomas Räsänen [Wed, 12 Jun 2013 09:58:37 +0000 (11:58 +0200)]
nbd-server: refactor out common code
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Signed-off-by: Wouter Verhelst <w@uter.be>
Tuomas Räsänen [Wed, 5 Jun 2013 17:42:42 +0000 (20:42 +0300)]
nbd-server: rename handle_connection() -> handle_oldstyle_connection()
The new name describes better the actual usage.
Remove also the fourth parameter, CLIENT*, which was always NULL.
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Tuomas Räsänen [Wed, 5 Jun 2013 17:42:31 +0000 (20:42 +0300)]
nbd-server: handle modern-style negotiation in a child process
Previously, the modern style negotiation was carried out in the root
server (listener) process before forking the actual client handler. This
made it possible for a malfunctioning or evil client to terminate the
root process simply by querying a non-existent export or aborting in the
middle of the negotation process (caused SIGPIPE in the server).
This commit moves the negotiation process to the child to keep the root
process up and running no matter what happens during the negotiation.
See http://sourceforge.net/mailarchive/message.php?msg_id=
30410146
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Wouter Verhelst [Sun, 9 Jun 2013 17:13:01 +0000 (19:13 +0200)]
Clarify that we're using tests which expect the serial test protocol
Automake changed its defaults from using the serial protocol to using
the parallel protocol sometime between 1.11 and 1.13.
Our test suite makes a few assumptions which are valid for the serial
protocol, but not for the parallel protocol, which makes the test suite
fail with 1.13. As such, explicitly state that we want the serial
protocol so that things don't break with recent versions of automake.
A proper fix would be to make the test suite work with the parallel
protocol, but that's a lot more work than we have time for right now.
Tuomas Räsänen [Sat, 1 Jun 2013 18:20:51 +0000 (21:20 +0300)]
nbd-server: narrow the scope of a function-local variable
It's better to keep variables strictly inside their usage scope than in
more wider scope to avoid unintentional variable shadowing and leaking.
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Tuomas Räsänen [Sat, 1 Jun 2013 18:19:50 +0000 (21:19 +0300)]
nbd-server: check the right socket variable for an invalid value
The previous check referred to a variable which was used only for
initializing the fd set and wasn't meaningful in the context of the
invalidity check.
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Wouter Verhelst [Wed, 29 May 2013 19:25:02 +0000 (21:25 +0200)]
This was fixed a while back for 3.3, but I forgot to remove the TODO item.
Wouter Verhelst [Sat, 18 May 2013 09:25:57 +0000 (11:25 +0200)]
Don't dump core *everywhere*
It may make sense to dump core if I'm doing some debugging, but that
doesn't mean we should have anyone anywhere do that.
Wouter Verhelst [Sat, 18 May 2013 08:20:52 +0000 (10:20 +0200)]
Fix my own stupidity
Michal's patch didn't apply cleanly, so I "applied" it manually, and
didn't think to compile-test.
Obviously next time I should just reject patches that don't apply. Oh
well.
Michal Belczyk [Sat, 18 May 2013 07:53:47 +0000 (09:53 +0200)]
Ignore SIGCHLD rather than blocking it
Since commit
3927df64, we're blocking most signals. Blocking a signal
implies it remains pending until we unblock the signal, at which point
it will be handled.
While that is the right choice for some signals, we're really not
interested in SIGCHLD, so ignore that instead. This makes our zombies go
away.
Goswin von Brederlow [Sun, 5 May 2013 10:44:29 +0000 (12:44 +0200)]
Buffer overflow and unterminated string in nbd-client.c
Wouter Verhelst [Thu, 11 Apr 2013 08:45:05 +0000 (10:45 +0200)]
Fix port spread
We were attempting to make sure no test used the same port twice, but
still reused the same number once. This fixes that.
Wouter Verhelst [Thu, 11 Apr 2013 08:42:58 +0000 (10:42 +0200)]
Distribute these files, too
Wouter Verhelst [Wed, 10 Apr 2013 22:35:36 +0000 (00:35 +0200)]
Prepare for 3.3
Wouter Verhelst [Wed, 10 Apr 2013 22:33:48 +0000 (00:33 +0200)]
Remove long-outdated conditional code
Wouter Verhelst [Wed, 10 Apr 2013 22:31:32 +0000 (00:31 +0200)]
Improve signal handling
Setting SIGCHLD to SIG_DFL doesn't cut it; we need to ctually ignore
them with sigprocmask. In addition, we need to deal with more than
SIGCHLD.
Initial patch by Paul Clements.
Wouter Verhelst [Sat, 6 Apr 2013 16:17:39 +0000 (16:17 +0000)]
Fix ordering
FreeBSD wants non-option arguments to appear after option arguments
Wouter Verhelst [Sat, 6 Apr 2013 16:17:07 +0000 (16:17 +0000)]
Don't try to check whether invalid sockets are readable
this caused SIGBUS on FreeBSD
Wouter Verhelst [Sat, 6 Apr 2013 15:34:44 +0000 (15:34 +0000)]
Don't attempt to free a NULL pointer.
Wouter Verhelst [Sat, 6 Apr 2013 15:26:15 +0000 (17:26 +0200)]
Open as many modern sockets as needed
Some systems need us to have a socket per address family (e.g.,
FreeBSD); others need us to have just one (e.g., Linux). Handle both
cases.
Wouter Verhelst [Sat, 6 Apr 2013 14:53:15 +0000 (16:53 +0200)]
Handle portability better.
Yesterday's attempt was somewhat shortsighted. This one should actually
work.
We avoid the ugliness of having to do the same thing twice somewhat by
putting it in a separate function -- this is still ugly to some extent,
but at least it doesn't copy code around more than just for the function
name.
Wouter Verhelst [Sat, 6 Apr 2013 14:11:22 +0000 (16:11 +0200)]
Revert "Be more portable"
This reverts commit
77ee0f392eaf292f2c0d350fa5c640253d2132d7.
It doesn't work on FreeBSD, and it doesn't work on Linux. Oops.
Wouter Verhelst [Thu, 4 Apr 2013 11:32:38 +0000 (11:32 +0000)]
Add todo item so we don't forget to fix this later
Wouter Verhelst [Thu, 4 Apr 2013 11:30:42 +0000 (11:30 +0000)]
More portability fixes
It still doesn't work on FreeBSD, but I just ran out of time
Wouter Verhelst [Thu, 4 Apr 2013 10:31:13 +0000 (10:31 +0000)]
Clean up in all cases
Since we use 'set -e', there are plenty of cases where the cleanup code isn't called.
Use 'trap' to ensure that it does.
Wouter Verhelst [Thu, 4 Apr 2013 10:30:27 +0000 (10:30 +0000)]
Be more portable
Using the leading - is a GNU extension (but not documented as such), which
doesn't work on FreeBSD. Use the more portable way to do the same thing.
Wouter Verhelst [Thu, 4 Apr 2013 10:00:24 +0000 (10:00 +0000)]
Use the correct error handling routine
Wouter Verhelst [Thu, 4 Apr 2013 08:53:42 +0000 (10:53 +0200)]
Use $TMPDIR rather than hardcoding for /tmp
Wouter Verhelst [Thu, 4 Apr 2013 08:47:44 +0000 (10:47 +0200)]
Add a template to mktemp invocation
Not all mktemp implementations (e.g., the FreeBSD one) have an implicit
template. Add one explicitly so things will work properly again.
Wouter Verhelst [Thu, 28 Mar 2013 21:03:46 +0000 (22:03 +0100)]
Ensure we don't bring the '-l fucks up nbd-server' bug again, by adding it to the test suite
Tuomas Räsänen [Mon, 11 Mar 2013 13:58:05 +0000 (15:58 +0200)]
nbd-server: prefer assertions over if-then-exits
Assertions imply programming invariants which must be fulfilled,
otherwise there is a programming error.
Regarding this commit, it's a programming error to pass NULL to
append_serve(). And now it's explicitly stated with the assert(3)
statement.
If-then-exit -constructs could be interpreted as a valid and
semantically meaningful code: "it's a feature of append_serve() to
exit the process if NULL is passed", which does not make any sense. On
the other hand, assert(s != NULL) makes it very clear that NULL must
not be passed, or the contract will be terminated along with the
process.
This commit is part of the desensitization treatment for author's
assertion allergy.
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Signed-off-by: Wouter Verhelst <w@uter.be>
Tuomas Räsänen [Sun, 10 Mar 2013 20:01:45 +0000 (22:01 +0200)]
nbd-server: read conf on SIGHUP and add new exports
This patch makes the root server process re-read its configuration files
and add new exports dynamically when SIGHUP is sent. The rehash feature
is non-destructive: it does not modify any existing exports, it only
lets the root server process to add new exports. However, it might be a
good idea to implement destructive counterparts (export deletion and
modification) too at some point.
Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
[change usage of __attribute__((unused)) into G_GNUC_UNUSED]
Signed-off-by: Wouter Verhelst <w@uter.be>
Wouter Verhelst [Wed, 6 Mar 2013 11:53:24 +0000 (12:53 +0100)]
Merge these two tests
Testing for "larger than the max value" is impossible and silly, but is
what the next test actually tests. Remove the erroneous one.
Wouter Verhelst [Wed, 6 Mar 2013 11:52:31 +0000 (12:52 +0100)]
Remove erroneous cast
Don't remember why it's there, it's probably a thinko.
Pointed out by Goswin von Brederlow <goswin-v-b@web.de>
folkert [Tue, 5 Mar 2013 09:23:31 +0000 (10:23 +0100)]
BUG: oversized 64b offset wrap not detected when offset + len > 64bit and thus wraps
if:
offset = 64bit - 2KB
len = 4KB
then the server will allow the read/write because the check
if (((ssize_t)((off_t)request.from + len) > client->exportsize))
will never trigger as client->exportsize will be compared with... offset
2KB!
folkert [Tue, 5 Mar 2013 09:19:39 +0000 (10:19 +0100)]
BUG: debug output uses signed integer for length field
Replaced %d by %u.
folkert [Mon, 4 Mar 2013 15:29:23 +0000 (16:29 +0100)]
BUG: read-command with data size 0 does not return a response header
NBD-server v3.2 has a problem: if a client does a read-request of 0
bytes in length, then the nbd-server does not return a response header.
This is not in line with a write request which always returns a response
header.
This patch solves that behaviour.
Wouter Verhelst [Wed, 6 Mar 2013 11:35:00 +0000 (12:35 +0100)]
More manpage updates
Wouter Verhelst [Wed, 6 Mar 2013 11:02:51 +0000 (12:02 +0100)]
Remove cryptic error
We already made it slightly less cryptic when you tried to connect to a
newstyle server without a name for the export. Do the same for the
reverse, too.
Wouter Verhelst [Wed, 6 Mar 2013 10:50:16 +0000 (11:50 +0100)]
Clarify error handling.
While working with nbd-server, I tried to allow the clients to
fetch a list of exports. After including the following in the
generic section of /etc/nbd-server/config:
[generic]
# other lines ...
allowlist
nbd-server refused to start, complaining there were no configured
exports, even though there were:
nass0:root ~ 17 # nbd-server -d
** Message: No configured exports; quitting.
Obviously, the line should read 'allowlist = 1', but It would be
helpful if nbd-server detected the error, and complained about
that instead of (apparently) ignoring the rest of the config file,
and issuing the confusing complaint about no configured exports.
I also tried 'allowlist = yes'. In that case it gives a
descriptive message, although it still confusingly and incorrectly
complains that there are no exports:
nass0:root ~ 14 # nbd-server -d
** (process:3482): WARNING **: Could not parse config file: Could not parse allowlist in group
generic: Key file contains key 'allowlist' which has a value that cannot be interpreted.
** Message: No configured exports; quitting.
The cause seems to be that g_key_file_load_from_file fails not only
if the file cannot be found or read, but also if it contains syntax
errors.
Original patch by Rogier <rogier777@gmail.com>, but reworked enough by
$SELF that it isn't the same thing anymore.
Wouter Verhelst [Wed, 6 Mar 2013 10:41:11 +0000 (11:41 +0100)]
Update manpage to reflect reality
Originally, it wasn't allowed to specify both a port and a name. It is
now, so update the manpage.
Rogier [Wed, 30 Jan 2013 18:38:19 +0000 (19:38 +0100)]
nbd-server reports 'negotiation failed' after 'nbd-client -l', and fails on next connection
When a client requests an export list from the server,
the latter issues the message 'Error: negotiation failed'.
This is rather confusing, as the only 'problem' is (AFAICT)
that the negotiation phase did everything.
On a subsequent attempt to connect a block device, the server
fails altogether:
Client output:
--------------------
nasc0:root ~ 216 # /tmp/nbd-client.master -l nass0
Negotiation: ..
nasc0-nbd0
nasc0:root ~ 217 # /tmp/nbd-client.master nass0 -N nasc0-nbd0 /dev/nbd0
Negotiation: ..size = 856941734MBError: Exported device is too big for me. Get 64-bit machine :-(
Exiting.
--------------------
Server output:
--------------------
nass0:root ~ 135 # /tmp/nbd-server.master -d -C /etc/nbd-server/config
Error: negotiation failed
Exiting.
Error: Read failed: Connection reset by peer
Exiting.
--------------------
From a tcpdump, it can be observed that the syslog messages end up
on the client socket, which makes the client choke, naturally.
I tested this for the latest git version, and the same problem
occurs. I have traced the problem to the fact that negotiate(),
in two locations, closes the socket, and returns NULL , after which
serveloop also closes it, actually closing the syslog socket instead.
The next accept() returns that same filedescriptor, which syslog()
still thinks it owns.
Note: I added the message 'Session terminated by client', because
the 'ABORT' might also be intended to be used as an irregular
end-of-session (in the future?), besides indicating a regular
end-of-session after a LIST.
--------------------------------------------
Wouter Verhelst [Wed, 13 Feb 2013 23:58:39 +0000 (00:58 +0100)]
Add missing closing bracket (whoops).
Spotted by: Michal Belczyk <belczyk@bsd.krakow.pl>
Wouter Verhelst [Mon, 11 Feb 2013 23:18:51 +0000 (00:18 +0100)]
Document that people should really use newstyle when possible.