platform/upstream/nbd.git
10 years agoPrepare for 3.8 nbd-3.8
Wouter Verhelst [Wed, 19 Mar 2014 18:05:34 +0000 (19:05 +0100)]
Prepare for 3.8

10 years agoDon't go out of bounds in an array...
Wouter Verhelst [Wed, 19 Mar 2014 17:55:52 +0000 (18:55 +0100)]
Don't go out of bounds in an array...

10 years agoZero-terminate buffers with data supplied by remote parties
Wouter Verhelst [Wed, 19 Mar 2014 17:39:25 +0000 (18:39 +0100)]
Zero-terminate buffers with data supplied by remote parties

Found by coverity scan

10 years agoClose the directory handle when we no longer need it
Wouter Verhelst [Wed, 19 Mar 2014 17:36:36 +0000 (18:36 +0100)]
Close the directory handle when we no longer need it

Found by coverity scan

10 years agoAdd assertion, to make LLVM static analyzer happy
Wouter Verhelst [Wed, 19 Mar 2014 17:09:16 +0000 (18:09 +0100)]
Add assertion, to make LLVM static analyzer happy

10 years agoRevert "Make this part of the code at least look similar"
Wouter Verhelst [Tue, 28 Jan 2014 07:44:13 +0000 (08:44 +0100)]
Revert "Make this part of the code at least look similar"

This reverts commit 701af5d057f523c714517085469dec556aa76b28.

The test suite apparently expects this to be there... do this properly
later on.

10 years agoSupport systemd initrd kill protection
Wouter Verhelst [Tue, 28 Jan 2014 07:39:41 +0000 (08:39 +0100)]
Support systemd initrd kill protection

systemd wants us to mark our argv[0] when we don't want to be killed.

Since I think that's a bit ugly, add an option so it's only done when
necessary.

10 years agoMake this part of the code at least look similar
Wouter Verhelst [Sun, 26 Jan 2014 20:23:20 +0000 (21:23 +0100)]
Make this part of the code at least look similar

First we assert that s != NULL.

Then we check if a != NULL, and return -1 if it is. That just makes no sense.

Change the check for a to also be an assertion, and make things at least look similar.

10 years agoSilence warning
Wouter Verhelst [Sat, 25 Jan 2014 11:56:00 +0000 (12:56 +0100)]
Silence warning

10 years agoBe less verbose
Wouter Verhelst [Wed, 22 Jan 2014 09:47:33 +0000 (10:47 +0100)]
Be less verbose

If we list each and every request, that means a build log becomes huge
and unwieldy, so reduce the chatter somewhat.

10 years agoAdd build status applet, too
Wouter Verhelst [Wed, 22 Jan 2014 00:44:24 +0000 (01:44 +0100)]
Add build status applet, too

Somewhat ugly, but it works -- and that's what matters most.

10 years agoDisable integrityhuge test
Wouter Verhelst [Tue, 21 Jan 2014 20:57:24 +0000 (21:57 +0100)]
Disable integrityhuge test

nbd-server currently may deadlock on huge reads or writes, especially on
slower machines.

We're fixing this on the io_transaction branch, but meanwhile disable
integrityhuge again.

10 years agoRelease 3.7 nbd-3.7
Wouter Verhelst [Tue, 21 Jan 2014 20:40:04 +0000 (21:40 +0100)]
Release 3.7

10 years agoAdd README.md to Makefile.am
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

10 years agoCreate Coverity model
Wouter Verhelst [Tue, 21 Jan 2014 19:36:18 +0000 (20:36 +0100)]
Create Coverity model

10 years agoFix typo
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.

10 years agoDon't leak resources
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.

10 years agoReformat README to markdown
Wouter Verhelst [Tue, 21 Jan 2014 19:12:35 +0000 (20:12 +0100)]
Reformat README to markdown

10 years agoMake things work again
Wouter Verhelst [Wed, 15 Jan 2014 12:32:09 +0000 (13:32 +0100)]
Make things work again

10 years agoTickle the git repository
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.

10 years agoTest build failure mail thing
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 ;-)

10 years agoMake the implementation of size_autodetect follow the documentation
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.

10 years agoRemove off_t from what will eventually be a public API
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.

10 years agoRemove duplicate ISSERVER definition
Wouter Verhelst [Wed, 15 Jan 2014 09:48:47 +0000 (10:48 +0100)]
Remove duplicate ISSERVER definition

10 years agoReorder LFS includes so it actually works
Wouter Verhelst [Wed, 15 Jan 2014 00:43:54 +0000 (01:43 +0100)]
Reorder LFS includes so it actually works

10 years agoAdd missing lfs.h include
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.

10 years agoFix cleanup in simple_test
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.

10 years agoFully initialize hints
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.

10 years agoFix missing include
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

10 years agoPrepare for 3.6 nbd-3.6
Wouter Verhelst [Fri, 3 Jan 2014 15:44:20 +0000 (16:44 +0100)]
Prepare for 3.6

10 years agoSwitch to xz (and away from bzip2)
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.

10 years agoFix build
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...

10 years agoAdd check for size_autodetect
Wouter Verhelst [Mon, 30 Dec 2013 18:12:28 +0000 (19:12 +0100)]
Add check for size_autodetect

10 years agoMove size_autodetect to library
Wouter Verhelst [Mon, 30 Dec 2013 18:00:12 +0000 (19:00 +0100)]
Move size_autodetect to library

10 years agoAdd check for getmaskbyte(), too
Wouter Verhelst [Sun, 29 Dec 2013 01:05:34 +0000 (02:05 +0100)]
Add check for getmaskbyte(), too

10 years agoDon't forget to distribute this new "macro.h", too
Wouter Verhelst [Mon, 23 Dec 2013 19:24:14 +0000 (20:24 +0100)]
Don't forget to distribute this new "macro.h", too

10 years agoAdd a check for append_serve, too
Wouter Verhelst [Mon, 23 Dec 2013 19:22:02 +0000 (20:22 +0100)]
Add a check for append_serve, too

10 years agoSeparate out a useful macro
Wouter Verhelst [Mon, 23 Dec 2013 19:21:46 +0000 (20:21 +0100)]
Separate out a useful macro

10 years agoUpdate comment to reflect today's realities
Wouter Verhelst [Mon, 23 Dec 2013 19:21:14 +0000 (20:21 +0100)]
Update comment to reflect today's realities

10 years agoMove "append_serve" to library, too.
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.

10 years agoWhitespace fix
Wouter Verhelst [Mon, 23 Dec 2013 19:20:38 +0000 (20:20 +0100)]
Whitespace fix

10 years agoFix Makefile.am's so that "make distcheck" works again
Wouter Verhelst [Sun, 22 Dec 2013 15:50:11 +0000 (16:50 +0100)]
Fix Makefile.am's so that "make distcheck" works again

10 years agoAdd .gitignore with compiled files in this directory.
Wouter Verhelst [Sun, 22 Dec 2013 15:25:30 +0000 (16:25 +0100)]
Add .gitignore with compiled files in this directory.

10 years agoMake it compile (and pass)
Wouter Verhelst [Sun, 22 Dec 2013 15:24:56 +0000 (16:24 +0100)]
Make it compile (and pass)

10 years agoAdd test for dup_serve
Wouter Verhelst [Sun, 22 Dec 2013 15:15:38 +0000 (16:15 +0100)]
Add test for dup_serve

10 years agoMove dup_serve() to library
Wouter Verhelst [Sun, 22 Dec 2013 15:15:16 +0000 (16:15 +0100)]
Move dup_serve() to library

10 years agoEnable maintainer-mode by default
Wouter Verhelst [Sun, 22 Dec 2013 15:13:52 +0000 (16:13 +0100)]
Enable maintainer-mode by default

10 years agoDo a htonl conversion of opt.
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.

10 years agoAdd a "code" test suite
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.

10 years agoMake a start with a library
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.

10 years agoSeparate the test suite out into a separate directory
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

10 years agoBring documentation in sync with code
Wouter Verhelst [Wed, 18 Dec 2013 10:13:19 +0000 (11:13 +0100)]
Bring documentation in sync with code

10 years agoImprove acl file parsing robustness
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.

10 years agoUnbreak virtstyle parameter parsing
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.

10 years agoFix authorized_client implementation a bit more
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.

10 years agoMerge pull request #15 from alexsn/master
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()

10 years agogznbd: fix warning with newer zlib
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>
10 years agogznbd: use PRId64 for printing 64bit types
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>
10 years agoAdd the actual text of the GPLv2, as the license requires us to
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

10 years agoUpdate nbd-client.c
alexsn [Sat, 30 Nov 2013 22:24:39 +0000 (00:24 +0200)]
Update nbd-client.c

Fix potential socket leak in opennet()

10 years agoPrepare for 3.5 nbd-3.5
Wouter Verhelst [Sat, 30 Nov 2013 22:11:45 +0000 (23:11 +0100)]
Prepare for 3.5

10 years agoUse strcmp() rather than strncmp()
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.

10 years agoFix documentation to reflect reality
Wouter Verhelst [Tue, 26 Nov 2013 13:25:26 +0000 (14:25 +0100)]
Fix documentation to reflect reality

11 years ago3.4 was released...
Wouter Verhelst [Fri, 6 Sep 2013 13:34:56 +0000 (15:34 +0200)]
3.4 was released...

11 years agore-enable integrityhuge test nbd-3.4
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.

11 years agoRemove the same ioctl() call in another place
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>
11 years agoRemove obsolete NBD_CLEAR_QUE ioctl.
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>
11 years agonbd-server: const'd function parameter variable
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>
11 years agonbd-server: remove superfluous 2nd parameter from handle_oldstyle_connection()
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>
11 years agonbd-server: refactor out common code
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>
11 years agonbd-server: rename handle_connection() -> handle_oldstyle_connection()
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>
11 years agonbd-server: handle modern-style negotiation in a child process
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>
11 years agoClarify that we're using tests which expect the serial test protocol
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.

11 years agonbd-server: narrow the scope of a function-local variable
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>
11 years agonbd-server: check the right socket variable for an invalid value
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>
11 years agoThis was fixed a while back for 3.3, but I forgot to remove the TODO item.
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.

11 years agoDon't dump core *everywhere*
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.

11 years agoFix my own stupidity
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.

11 years agoIgnore SIGCHLD rather than blocking it
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.

11 years agoBuffer overflow and unterminated string in nbd-client.c
Goswin von Brederlow [Sun, 5 May 2013 10:44:29 +0000 (12:44 +0200)]
Buffer overflow and unterminated string in nbd-client.c

11 years agoFix port spread
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.

11 years agoDistribute these files, too
Wouter Verhelst [Thu, 11 Apr 2013 08:42:58 +0000 (10:42 +0200)]
Distribute these files, too

11 years agoPrepare for 3.3 nbd-3.3
Wouter Verhelst [Wed, 10 Apr 2013 22:35:36 +0000 (00:35 +0200)]
Prepare for 3.3

11 years agoRemove long-outdated conditional code
Wouter Verhelst [Wed, 10 Apr 2013 22:33:48 +0000 (00:33 +0200)]
Remove long-outdated conditional code

11 years agoImprove signal handling
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.

11 years agoFix ordering
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

11 years agoDon't try to check whether invalid sockets are readable
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

11 years agoDon't attempt to free a NULL pointer.
Wouter Verhelst [Sat, 6 Apr 2013 15:34:44 +0000 (15:34 +0000)]
Don't attempt to free a NULL pointer.

11 years agoOpen as many modern sockets as needed
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.

11 years agoHandle portability better.
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.

11 years agoRevert "Be more portable"
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.

11 years agoAdd todo item so we don't forget to fix this later
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

11 years agoMore portability fixes
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

11 years agoClean up in all cases
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.

11 years agoBe more portable
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.

11 years agoUse the correct error handling routine
Wouter Verhelst [Thu, 4 Apr 2013 10:00:24 +0000 (10:00 +0000)]
Use the correct error handling routine

11 years agoUse $TMPDIR rather than hardcoding for /tmp
Wouter Verhelst [Thu, 4 Apr 2013 08:53:42 +0000 (10:53 +0200)]
Use $TMPDIR rather than hardcoding for /tmp

11 years agoAdd a template to mktemp invocation
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.

11 years agoEnsure we don't bring the '-l fucks up nbd-server' bug again, by adding it to the...
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

11 years agonbd-server: prefer assertions over if-then-exits
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>