Thomas Eriksson [Mon, 13 Oct 2014 12:07:45 +0000 (14:07 +0200)]
Adding capability for the client to connect to a unix socket.
Wouter Verhelst [Fri, 10 Oct 2014 15:24:21 +0000 (17:24 +0200)]
Avoid sending 124 zeroes of useless
Wouter Verhelst [Fri, 10 Oct 2014 13:49:04 +0000 (15:49 +0200)]
Handle absense of (struct dirent).d_type
*BSD and Linux implement this, but it's not required by POSIX and, e.g.,
Solaris/IllumOS don't support it.
Since we already have to deal with DT_UNKNOWN and call the stat stuff in
that case anyway, just do some autoconf and preprocessor magic to hide
the differences.
Should fix github.com issue#22.
Wouter Verhelst [Fri, 10 Oct 2014 13:34:00 +0000 (15:34 +0200)]
Clarify that gznbd is slightly outdated
Wouter Verhelst [Fri, 10 Oct 2014 13:32:47 +0000 (15:32 +0200)]
Merge https://github.com/ahippo/nbd
Wouter Verhelst [Wed, 8 Oct 2014 21:53:52 +0000 (23:53 +0200)]
Don't use XFAIL_TESTS, instead make nbd-tester-client exit with appropriate error state
Wouter Verhelst [Wed, 8 Oct 2014 21:13:12 +0000 (23:13 +0200)]
Test that trying to write to a read-only export fails
Wouter Verhelst [Wed, 8 Oct 2014 21:12:59 +0000 (23:12 +0200)]
Document a way for a default export
Andrey Mazo [Thu, 21 Aug 2014 09:28:42 +0000 (13:28 +0400)]
gznbd: use atoll() to convert size argument
gznbd works incorrectly with large size argument which overflows 32-bit integer.
For example:
gznbd /dev/nbd0 /root/test.gz
1000204886016
gznbd:
1000204886016 does not appear to be a valid size
The size is stored in u64, but is converted from a string using atol().
Simply replace atol() with atoll().
gznbd is compiled with -std=gnu99 (as the whole nbd), so atoll() is available.
Links to the original patch:
[1] https://sourceforge.net/p/nbd/mailman/nbd-general/thread/
560411311771602%40web126.yandex.ru/#msg27860052
[2] http://marc.info/?l=nbd-general&m=
131177162001072&w=2
Andrey Mazo [Thu, 2 Oct 2014 00:37:58 +0000 (04:37 +0400)]
Wire gznbd into general configure.ac/Makefile.am
Add --enable-gznbd configure option (disabled by default).
Avoid multiple recompilations of cliserv.c by factoring it into a static
library.
This fixes gznbd compilation broken after
43b96ec0d22c0a42c20104cb66aa2d2236da3e77:
gznbd.c:(.text.startup+0x420): undefined reference to `ntohll'
Wouter Verhelst [Wed, 1 Oct 2014 20:47:21 +0000 (22:47 +0200)]
Make short version of -V actually work
Wouter Verhelst [Wed, 1 Oct 2014 20:47:14 +0000 (22:47 +0200)]
Document -V option
Wouter Verhelst [Wed, 1 Oct 2014 20:42:18 +0000 (22:42 +0200)]
Fix various warnings that pop up by default with gcc 4.9
Wouter Verhelst [Wed, 1 Oct 2014 20:35:44 +0000 (22:35 +0200)]
Replace return by break statement
Both are extraneous, really, but keep the break there for consistency (and to
avoid "eep, forgot... ah, no" kind of things)
Using return instead (without argument) makes clang choke, which is useless.
txt.file [Wed, 1 Oct 2014 14:07:20 +0000 (16:07 +0200)]
Update nbd-server.c
Added a parameter to output a version string.
Wouter Verhelst [Thu, 18 Sep 2014 08:32:46 +0000 (10:32 +0200)]
Revert "Enable automatic coverity coverage"
This reverts commit
eb6365af2c4c8eecf62317940c06f2bc58810a98.
The travis stuff isn't supposed to work that way; also, we're doing
weekly coverity builds with buildbot now, so it's less relevant.
Wouter Verhelst [Mon, 15 Sep 2014 19:02:17 +0000 (21:02 +0200)]
Implement new config file option "cowdir"
Allows to specify a location where copy-on-write files should be
written.
delmasce [Sun, 14 Sep 2014 22:30:51 +0000 (00:30 +0200)]
Update clientacl.c
Update test code with new prototype of address_matches()
delmasce [Sun, 14 Sep 2014 21:53:51 +0000 (23:53 +0200)]
Pass whole struct sockaddr to function address_matches() and use it to
compare against the masks defined in auth file.
Wouter Verhelst [Sun, 14 Sep 2014 21:27:20 +0000 (23:27 +0200)]
Fix obi-wan (whoops)
Christian Hesse [Fri, 9 May 2014 07:06:06 +0000 (09:06 +0200)]
add missing include syslog.h
Wouter Verhelst [Sun, 14 Sep 2014 18:42:58 +0000 (20:42 +0200)]
Clear ai on return, also in case of error
Coverity CID#1238644
Wouter Verhelst [Sun, 14 Sep 2014 09:58:47 +0000 (11:58 +0200)]
Ensure pidftemplate is always 0-terminated
Coverity CID#1238650
Wouter Verhelst [Sun, 14 Sep 2014 09:54:55 +0000 (11:54 +0200)]
Ensure the "errstr" buffer is always 0-terminated
Coverity CID#1238651 (and many others)
Wouter Verhelst [Fri, 25 Jul 2014 07:46:19 +0000 (09:46 +0200)]
Don't try to be smarter than the compiler about inlining
When we specify "inline int foo()" (as opposed to "static inline", I
guess), compilation may fail when compiling with -O0, as I sometimes do
to simplify debugging.
The compiler is way smarter about deciding when things are best inlined,
anyway. So stop trying to tell it what to do.
Wouter Verhelst [Fri, 25 Jul 2014 07:45:52 +0000 (09:45 +0200)]
Don't warn about oldstyle exports if oldstyle is set to true.
Bug reported through Ubuntu Launchpad
Wouter Verhelst [Fri, 25 Jul 2014 07:44:24 +0000 (09:44 +0200)]
Fix up parse_cfile signature
parse_cfile repurposed the genconf parameter as a boolean flag (in
addition to its storing of generic configuration) to signal the
expectation (or absense thereof) of a [generic] section in the
configuration file.
Not only is this confusing, it also makes it impossible to reliably
detect whether we want an oldstyle export. Fix for that in the next
commit.
Christian Hesse [Thu, 8 May 2014 09:10:59 +0000 (11:10 +0200)]
fix typo
Christian Hesse [Thu, 8 May 2014 09:10:58 +0000 (11:10 +0200)]
do not try to open authorization file without filename
Wouter Verhelst [Thu, 20 Mar 2014 07:34:12 +0000 (08:34 +0100)]
Guard against errors
Wouter Verhelst [Thu, 20 Mar 2014 07:16:37 +0000 (08:16 +0100)]
Enable automatic coverity coverage
Wouter Verhelst [Thu, 20 Mar 2014 07:08:26 +0000 (08:08 +0100)]
Make the travis stuff work (after some testing on a separate branch)
Wouter Verhelst [Thu, 20 Mar 2014 07:06:18 +0000 (08:06 +0100)]
Clean up cliserv.h
Previously, cliserv.h also contained some functions, which would then be
defined twice if we hadn't inlined them.
That is a fairly ugly way of doing things, so instead move the few
functions in cliserv.h to a new cliserv.c, and compile and link that in.
This should also make more recent versions of clang not be unhappy about
"missing" functions
Wouter Verhelst [Wed, 19 Mar 2014 23:19:05 +0000 (00:19 +0100)]
Install a more recent version of automake through apt pinning. I hope.
Wouter Verhelst [Wed, 19 Mar 2014 22:53:27 +0000 (23:53 +0100)]
Figure out which versions of automake we have to work with
Wouter Verhelst [Wed, 19 Mar 2014 22:41:27 +0000 (23:41 +0100)]
autotools need to be regenerated
Wouter Verhelst [Wed, 19 Mar 2014 22:30:28 +0000 (23:30 +0100)]
Add travis config file
Wouter Verhelst [Wed, 19 Mar 2014 18:05:34 +0000 (19:05 +0100)]
Prepare for 3.8
Wouter Verhelst [Wed, 19 Mar 2014 17:55:52 +0000 (18:55 +0100)]
Don't go out of bounds in an array...
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
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
Wouter Verhelst [Wed, 19 Mar 2014 17:09:16 +0000 (18:09 +0100)]
Add assertion, to make LLVM static analyzer happy
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.
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.
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.
Wouter Verhelst [Sat, 25 Jan 2014 11:56:00 +0000 (12:56 +0100)]
Silence warning
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.
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.
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.
Wouter Verhelst [Tue, 21 Jan 2014 20:40:04 +0000 (21:40 +0100)]
Release 3.7
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