search for: connect_command

Displaying 20 results from an estimated 86 matches for "connect_command".

2019 May 25
2
[PATCH libnbd] states: connect_command: Don't set O_NONBLOCK on socket passed to child.
...0644 --- a/generator/states-connect.c +++ b/generator/states-connect.c @@ -27,6 +27,7 @@ #include <stdbool.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> #include <errno.h> #include <signal.h> #include <netdb.h> @@ -183,12 +184,12 @@ CONNECT_COMMAND.START: int sv[2]; pid_t pid; + int flags; assert (!h->sock); assert (h->argv); assert (h->argv[0]); - if (socketpair (AF_UNIX, SOCK_STREAM|SOCK_NONBLOCK|SOCK_CLOEXEC, 0, - sv) == -1) { + if (socketpair (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, sv) == -1) {...
2019 May 25
1
Re: [PATCH libnbd] states: connect_command: Don't set O_NONBLOCK on socket passed to child.
...can deal with portability when someone reports a > problem. For now the patch looks fine. Hmm. Your use of SOCK_CLOEXEC here made me look for other fds that we might inadvertently destroy or leak in a multi-threaded process that does fork/exec (or even if the program linking against libnbd does connect_command() in two separate threads on two different nbd objects). I found: lib/crypto.c: fp = fopen (pskfile, "r"); We need to use either fopen(pskfile, "re") (if libc is new-enough to support "e" for O_CLOEXEC) or raw open(O_CLOEXEC) + fdopen() instead. -- Eric Blake, Prin...
2023 Mar 23
1
[libnbd PATCH v3 14/19] CONNECT_COMMAND.START: plug child process leak on error
...ion for killing the child process and reaping it with waitpid(). However, it would raise some new questions (what signal to send, ensure the child not ignore that signal, hope that whatever process image we execute in the child handle that signal properly, etc). Instead, rearrange the steps in the CONNECT_COMMAND.START handler so that fork() be the last operation in the parent process, on the construction path. If fork() succeeds, let the entire handler succeed. For this, move the fcntl() and nbd_internal_socket_create() calls above fork(). (The hoisting of the fcntl() calls is where we rely on the earlier...
2019 May 25
0
Re: [PATCH libnbd] states: connect_command: Don't set O_NONBLOCK on socket passed to child.
On 5/25/19 1:33 PM, Richard W.M. Jones wrote: > I also made the code a bit more robust about closing the socket along > error paths. > --- > generator/states-connect.c | 21 ++++++++++++++++++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > assert (!h->sock); > assert (h->argv); > assert (h->argv[0]); > - if (socketpair (AF_UNIX,
2020 Mar 17
0
[nbdkit PATCH 4/4] RFC tests: Add test to cover unusual .can_flush return
...AY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +source ./functions.sh +set -x + +requires nbdsh --version + +plugin=.libs/test-flush-plugin.so +requires test -f $plugin + +# Test what happens when a plugin fails .can_flush +nbdsh -c ' +try: + h.connect_command (["nbdkit", "-s", "-v", "'$plugin'", "level=-1"]) +except nbd.Error as ex: + exit (0) +# If we got here, things are broken +exit (1) +' + +# A read-only connection never triggers .can_flush +nbdsh -c ' +h.connect_command (["n...
2023 Mar 23
20
[libnbd PATCH v3 00/19] pass LISTEN_FDNAMES with systemd socket activation
...n: avoid manipulating the sign bit socket activation: check syscalls for errors in the child process socket activation: centralize resource release socket activation: plug AF_UNIX socket address (filesystem) leak on error socket activation: replace execvp() call with fork-safe variant CONNECT_COMMAND.START: fix small comment thinko about socket pair usage CONNECT_COMMAND.START: set the NBD error when fcntl() fails CONNECT_COMMAND.START: use symbolic constants for fd#0 and fd#1 CONNECT_COMMAND.START: sanitize close() calls in the child process CONNECT_COMMAND.START: check syscalls fo...
2019 May 23
2
Re: [PATCH libnbd v2 1/6] api: Synchronous connect waits til all connections are connected.
On 5/22/19 4:50 AM, Richard W.M. Jones wrote: > If not using multi-conn then obviously the synchronous connection > calls ‘nbd_connect_unix’, ‘nbd_connect_tcp’ and ‘nbd_connect_command’ > should only return when the (one) connection object is connected. > > In the multi-conn case it's not very clear what these synchronous > calls should do. Previously I had it so that they would return as > soon as at least one connection was connected. However this is a &gt...
2019 Jul 25
2
[PATCH libnbd] lib: Kill subprocess in nbd_close.
This is a simple patch which stops nbd_close from waiting too long for a server subprocess to shut down. I wanted to send SIGHUP because the server will be able to catch it and do a clean shutdown if that is required. Is another signal better? Is it right to send a signal here? Rich.
2019 May 28
2
[PATCH] api: Add a special type for the flags argument.
This applies on top of patches 1 & 2 here (instead of patch 3): https://www.redhat.com/archives/libguestfs/2019-May/msg00206.html https://www.redhat.com/archives/libguestfs/2019-May/msg00207.html Rich.
2019 May 25
1
Interesting libnbd/nbdkit bug
Try doing: $ nbdsh nbd> h.connect_command (["nbdkit", "-s", "null"]) At this point you may observe your laptop fan starts to spin and nbdkit is consuming 100% of CPU. In all other respects everything works fine, you can send commands etc. Anyway I tracked the issue down. nbdkit sits in a loop continuously...
2019 May 28
1
Re: [PATCH] api: Add a special type for the flags argument.
...t position only" > + name > + ) handle_calls > + And this part is nice (even if I'm having to read up on quite a bit of documentation to understand how it works) > +++ b/python/t/400-pread.py > @@ -20,7 +20,7 @@ import nbd > h = nbd.NBD () > h.connect_command (["nbdkit", "-s", "--exit-with-parent", "-v", > "pattern", "size=512"]) > -buf = h.pread (512, 0, 0) > +buf = h.pread (512, 0) At any rate, you achieved the same goal I had in mind for omitting a 0 flags argu...
2019 Aug 14
0
[PATCH libnbd 3/3] python: Add test for doing asynch copy from one handle to another.
...elif fd == dfd and revents & select.POLLOUT and \ + dst.aio_get_direction () & nbd.AIO_DIRECTION_WRITE: + dst.aio_notify_write () + +src = nbd.NBD () +src.set_handle_name ("src") +dst = nbd.NBD () +dst.set_handle_name ("dst") +src.connect_command (["nbdkit", "-s", "--exit-with-parent", "-r", + "pattern", "size=%d" % disk_size]) +dst.connect_command (["nbdkit", "-s", "--exit-with-parent", + "memory", &...
2019 Aug 10
7
[PATCH libnbd 0/5] WIP: python: Add test for doing asynch copy.
This doesn't yet work. However it does make me more convinced than ever that we really need to sort out persistent buffer lifetimes in the library (similar to what we did for closures). Rich.
2019 Aug 10
1
Re: [PATCH libnbd 2/9] generator: Generalize OFlags.
...buf 0_L (f 42) ~flags:[NBD.cmd_flag_df]; > + let flags = let open NBD.CMD_FLAG in [DF] in > + > + NBD.pread_structured nbd buf 0_L (f 42) ~flags; blank line here... > +++ b/ocaml/tests/test_410_pwrite.ml > @@ -33,7 +33,8 @@ let () = > let nbd = NBD.create () in > NBD.connect_command nbd ["nbdkit"; "-s"; "--exit-with-parent"; "-v"; > "file"; datafile]; > - NBD.pwrite nbd buf1 0_L ~flags:[NBD.cmd_flag_fua]; > + let flags = let open NBD.CMD_FLAG in [FUA] in > + NBD.pwrite nbd buf1 0_L ~fl...
2019 May 28
0
[PATCH] api: Add a special type for the flags argument.
...| Int n -> n | Int64 n -> n | Opaque n -> n diff --git a/python/t/400-pread.py b/python/t/400-pread.py index da4799b..4d64166 100644 --- a/python/t/400-pread.py +++ b/python/t/400-pread.py @@ -20,7 +20,7 @@ import nbd h = nbd.NBD () h.connect_command (["nbdkit", "-s", "--exit-with-parent", "-v", "pattern", "size=512"]) -buf = h.pread (512, 0, 0) +buf = h.pread (512, 0) print ("%r" % buf) diff --git a/python/t/410-pwrite.py b/python/t/410-pwrite.py in...
2020 Mar 17
9
[nbdkit PATCH 0/4] Fix testsuite hang with nbd-stadalone
Either patch 1 or patch 2 in isolation is sufficient to fix the problem that Rich forwarded on from an archlinux tester (name so I can credit them?). But both patches should be applied, as well as backported to appropriate stable branches, to maximize cross-version interoperability of nbdkit vs. plugins. Patch 3 will let us detect future similar bugs much faster. I want patch 4 to ensure that
2019 Nov 23
2
Re: [PATCH nbdkit v2 10/10] tests: Test the Python plugin thoroughly.
...ut this is better. > > > > + cmd = ["nbdkit", "-v", "-s", "--exit-with-parent", > > > + "python", srcdir + "/test-python-plugin.py", > > > + "cfg=" + cfg] > > > + h.connect_command (cmd) > > > + return h > > > + > > > +# Test we can send an empty pickled test configuration and do nothing > > > +# else. This is just to ensure the machinery of the test works. > > > +h = test ({}) > > > > So we have now running nbdkit...
2019 Sep 16
2
[LIBNBD SECURITY PATCH 0/1] NBD Protocol Downgrade Attack in libnbd
..._can_meta_context(h, context) returns true; the most commonly supported context is LIBNBD_CONTEXT_BASE_ALLOCATION. Test if libnbd is vulnerable ---------------------------- Run the following command (tested with nbdkit 1.12 or newer): $ nbdsh -c 'h.set_tls(nbd.TLS_REQUIRE)' \ -c 'h.connect_command(["nbdkit", "-o", "-s", "null"])' \ -c 'print(h.get_size())' If the command succeeds and prints 0, then libnbd is vulnerable. The correct behavior is to fail with an error that the connection was not possible due to the server lacking encryptio...
2019 Sep 26
0
[PATCH libnbd 2/2] api: Implement local command with systemd socket activation.
...generator index 3b63665..d0b4d46 100755 --- a/generator/generator +++ b/generator/generator @@ -95,6 +95,7 @@ type external_event = | CmdConnectUnix (* [nbd_aio_connect_unix] *) | CmdConnectTCP (* [nbd_aio_connect_tcp] *) | CmdConnectCommand (* [nbd_aio_connect_command] *) + | CmdConnectSA (* [nbd_aio_connect_socket_activation] *) | CmdIssue (* issuing an NBD command *) type location = string * int (* source location: file, line number *) @@ -168,13 +169,15 @@ let rec state_machine = [ CmdConnec...
2019 Jul 25
1
Re: [PATCH libnbd] lib: Kill subprocess in nbd_close.
On 7/25/19 12:43 PM, Richard W.M. Jones wrote: > $ time nbdsh -c 'h.connect_command (["nbdkit", "-s", "null", "size=512", "--filter=delay", "delay-read=10"]); b = nbd.aio_buffer(1); h.aio_pread (b, 0); del (h)' > real 0m10.499s > user 0m0.065s > sys 0m0.023s > > With this patch the elapsed time is near...