search for: connect_unix

Displaying 20 results from an estimated 48 matches for "connect_unix".

2023 Aug 20
1
[libnbd PATCH v8 04/10] rust: Make it possible to run examples with a URI
...or is the partition table. @@ -21,11 +24,15 @@ fn main() -> anyhow::Result<()> { if args.len() != 2 { anyhow::bail!("Usage: {:?} socket", args[0]); } - let socket = &args[1]; - // Connect to the NBD server over a - // Unix domain socket. - nbd.connect_unix(socket)?; + // Check if the user provided a URI or a unix socket. + let socket_or_uri = args[1].to_str().unwrap(); + if socket_or_uri.contains("://") { + nbd.connect_uri(socket_or_uri)?; + } else { + // Connect to the NBD server over a Unix domain socket. +...
2019 Sep 28
0
[PATCH nbdkit v2 4/4] info: Add tests for time, uptime and conntime modes.
...uires nbdsh --version + +sock=`mktemp -u` +files="info-conntime.out info-conntime.pid $sock" +rm -f $files +cleanup_fn rm -f $files + +# Run nbdkit. +start_nbdkit -P info-conntime.pid -U $sock info mode=conntime + +export sock +nbdsh -c - <<'EOF' +import os +import time + +h.connect_unix (os.environ["sock"]) + +size = h.get_size () +assert size == 12 + +buf = h.pread (size, 0) +secs = int.from_bytes (buf[0:8], byteorder='big') +usecs = int.from_bytes (buf[8:12], byteorder='big') +print ("%d, %d" % (secs, usecs)) + +assert abs (secs) <= 60 +EOF...
2020 Mar 04
0
[PATCH nbdkit v2] New filter: limit: Limit number of clients that can connect.
...bdkit -P limit.pid -U $sock --filter=limit memory size=1M limit=2 + +export sock + +nbdsh -c - <<'EOF' +import os +import sys +import time + +sock = os.environ["sock"] + +# It should be possible to connect two clients. +# Note that nbdsh creates the ‘h’ handle implicitly. +h.connect_unix (sock) +h2 = nbd.NBD () +h2.connect_unix (sock) + +# A third connection is expected to fail. +try: + h3 = nbd.NBD () + h3.connect_unix (sock) + # This should not happen. + sys.exit (1) +except nbd.Error: + pass + +# Close one of the existing connections. +del h2 + +# There's a po...
2019 May 28
1
[libnbd PATCH] connect: Better handling of long socket names
...t. --- generator/states-connect.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/generator/states-connect.c b/generator/states-connect.c index a410e34..014f6bb 100644 --- a/generator/states-connect.c +++ b/generator/states-connect.c @@ -86,15 +86,20 @@ } CONNECT_UNIX.START: - struct sockaddr_un sun; + struct sockaddr_un sun = { .sun_family = AF_UNIX }; socklen_t len; + size_t socklen; assert (h->unixsocket != NULL); - sun.sun_family = AF_UNIX; - memset (sun.sun_path, 0, sizeof (sun.sun_path)); - strncpy (sun.sun_path, h->unixsocket, sizeof (...
2020 Aug 08
1
Re: [nbdkit PATCH 3/3] tlsdummy: New filter
...+ echo insecure; exit 0 + fi + echo $3 ;; + get_size) echo 6 ;; + pread) echo "$2" | dd skip=$4 count=$3 iflag=skip_bytes,count_bytes ;; + *) exit 2; +esac +EOF + +# Plaintext client sees only dummy volume +nbdsh -c ' +import os +h.set_export_name ("hello") +h.connect_unix (os.environ["sock"]) +assert h.get_size () == 512 +assert h.pread (5, 0) == b"dummy" +' + +# Encrypted client sees desired volumes +nbdsh -c ' +import os +h.set_export_name ("hello") +h.set_tls (nbd.TLS_REQUIRE) +h.set_tls_psk_file ("keys.psk") +h.set...
2019 Sep 12
3
Re: [PATCH nbdkit v2 3/3] tests: Add a simple test of nbdkit_export_name.
.../" "//" " " \ > + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" > +do > + export e sock > + nbdsh -c ' > +import os > + > +e = os.environ["e"] > +h.set_export_name (e) > +h.connect_unix (os.environ["sock"]) Could be done with nbdsh --connect "nbd+unix://$e?socket=$sock". But what you did here works as well (--uri would work too once you could rely on nbdsh 1.2, but for now sticking to --connect is more portable) > + > +size = h.get_size () > +print...
2020 May 20
0
[PATCH nbdkit] tests/test-truncate4.sh: Rewrite to use nbdsh.
..._file(): + # Original test data, 1024 bytes of "TEST" repeated. + with open (data, "w") as file: + file.write ("TEST"*256) + +restore_file () + +print ("Connection A.", flush=True) +connA = nbd.NBD () +connA.set_handle_name ("A") +connA.connect_unix (sock) +print ("Check the size.", flush=True) +assert connA.get_size () == 1024 + +print ("Truncate %s to 512 bytes." % data, flush=True) +os.truncate (data, 512) + +print ("Connection B.", flush=True) +connB = nbd.NBD () +connB.set_handle_name ("B") +connB.c...
2020 Mar 04
2
[PATCH nbdkit v2] New filter: limit: Limit number of clients that can connect.
This is a second version of the limit filter. v1 was posted here: https://www.redhat.com/archives/libguestfs/2020-March/msg00015.html I didn't bother to repost the other three patches because they are the same. The difference is this version of the filter takes security more seriously. It shouldn't be possible for malicious clients to connect more than limit=N times to the plugin now,
2019 Jun 29
0
[libnbd PATCH 2/6] generator: Allow DEAD state actions to run
...d up nbd_close into the python bindings; until that happens, there is no way in nbdsh to wipe out an existing failed connection and replace it with another attempt where we set the correct export name, short of completely exiting nbdsh: $ qemu-nbd -k /tmp/a -f raw -x a file $ ./run nbdsh nbd> h.connect_unix('/tmp/a') Traceback (most recent call last): File "/usr/lib64/python3.7/code.py", line 90, in runcode exec(code, self.locals) File "<console>", line 1, in <module> File "/home/eblake/libnbd/python/nbd.py", line 340, in connect_unix ret...
2020 May 20
2
[PATCH nbdkit] tests/test-truncate4.sh: Rewrite to use nbdsh.
This commit works for me, but TBH I'm not clear on what the actual purpose of this test is supposed to be. Rich.
2020 Sep 21
0
[nbdkit PATCH v3 06/14] api: Add .export_description
...start_nbdkit -P export-info.pid -U $sock \ sh - <<'EOF' case "$1" in @@ -59,36 +58,34 @@ EOF nbdsh -c ' import os +def must_fail(f, *args, **kwds): + try: + f(*args, **kwds) + assert False + except nbd.Error: + pass + h.set_opt_mode(True) h.connect_unix(os.environ["sock"]) h.set_export_name("a") h.opt_info() -try: - h.get_canonical_export_name() - assert False -except nbd.Error as ex: - pass +must_fail(h.get_canonical_export_name) +must_fail(h.get_export_description) h.set_export_name("") h.opt_info() -try: -...
2020 Sep 21
0
[nbdkit PATCH v3 03/14] server: Respond to NBD_INFO_NAME request
..."$1" in + default_export) echo hello ;; + open) echo "$3" ;; + export_description) echo "$2 world" ;; + get_size) echo 0 ;; + *) exit 2 ;; +esac +EOF + +# Without client request, nothing is advertised +nbdsh -c ' +import os + +h.set_opt_mode(True) +h.connect_unix(os.environ["sock"]) + +h.set_export_name("a") +h.opt_info() +try: + h.get_canonical_export_name() + assert False +except nbd.Error as ex: + pass + +h.set_export_name("") +h.opt_info() +try: + h.get_canonical_export_name() + assert False +except nbd.Error as ex: +...
2019 Oct 18
0
[PATCH libnbd 2/2] api: Add support for AF_VSOCK.
...INT[/FILENAME] --vsock CID PORT + =head1 DESCRIPTION nbdfuse presents a Network Block Device as a local file inside a FUSE @@ -230,6 +232,11 @@ unencrypted TCP socket. See also L<nbd_connect_tcp(3)>. Select Unix mode. Connect to an NBD server on a Unix domain socket. See also L<nbd_connect_unix(3)>. +=item B<--vsock> CID PORT + +Select vsock mode. Connect to an NBD server on a C<AF_VSOCK> socket. +See also L<nbd_connect_vsock(3)>. + =back =head1 NOTES @@ -294,6 +301,7 @@ L<nbd_connect_socket(3)>, L<nbd_connect_systemd_socket_activation(3)>, L<n...
2019 Sep 11
1
Re: [PATCH nbdkit] tests: Convert some tests to use nbdsh instead of qemu-io.
...nbd4: nbd_create: opening handle libnbd: debug: nbd4: nbd_close: closing handle libnbd: debug: nbd5: nbd_create: opening handle libnbd: debug: nbd5: nbd_connect_uri: enter: uri="nbd+unix://?socket=/tmp/tmp.sHet2Luahj" libnbd: debug: nbd5: nbd_connect_uri: event CmdConnectUnix: START -> CONNECT_UNIX.START libnbd: debug: nbd5: nbd_connect_uri: transition: CONNECT_UNIX.START -> CONNECT.START libnbd: debug: nbd5: nbd_connect_uri: poll start: events=4 libnbd: debug: nbd5: nbd_connect_uri: poll end: r=1 revents=4 libnbd: debug: nbd5: nbd_connect_uri: event NotifyWrite: CONNECT.START -> CONNEC...
2019 Sep 15
0
[PATCH nbdkit 1/4] Add reflection plugin.
...xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +do + nbdsh -c ' +import os +import base64 + +e = os.environ["e"] +b = base64.b64encode(e.encode("utf-8")).decode("utf-8") +print ("e = %r, b = %r" % (e,b)) +h.set_export_name (b) +h.connect_unix (os.environ["sock"]) + +size = h.get_size () +assert size == len (e.encode("utf-8")) + +# Zero-sized reads are not defined in the NBD protocol. +if size > 0: + buf = h.pread (size, 0) + assert buf == e.encode("utf-8") +' +done + +# Test that it fails if the...
2019 Jun 05
1
[libnbd PATCH] api: Add nbd_supports_tls
...ction may be called regardless of whether TLS is +supported, but will have no effect unless C<nbd_set_tls> +is also used to request or require TLS."; }; (* Can't implement this because we need a way to return string that @@ -1112,7 +1130,9 @@ C<nbd_connect_tcp> or C<nbd_connect_unix>. This call returns when the connection has been made. This call will fail if libnbd was not compiled with libxml2; you can -test whether this is the case with C<nbd_supports_uri>."; +test whether this is the case with C<nbd_supports_uri>. Support for +URIs that require TLS...
2019 Jun 27
1
[libnbd PATCH] python: Fix bindings for Path parameters
...t: $ ~/qemu/qemu-nbd -r -k /tmp/nbdsock --object \ tls-creds-psk,id=tls0,endpoint=server,dir=/home/eblake/libnbd/tests \ --tls-creds tls0 -f raw -x / tmpfile $ ./run nbdsh nbd> h.set_tls_psk_file('tests/keys.psk') nbd> h.set_tls(2) nbd> h.set_export_name('/') nbd> h.connect_unix('/tmp/nbdsock') instead of getting a segfault. --- generator/generator | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/generator/generator b/generator/generator index c29460c..fa12232 100755 --- a/generator/generator +++ b/generator/generator @@ -3608,7 +...
2019 Sep 11
4
[PATCH nbdkit] tests: Convert some tests to use nbdsh instead of qemu-io.
Very much a work in progress as there are still many tests using qemu-io which are candidates for conversion. You'll notice at the end of test-full.sh that the new test has some duplicated code which looks as if it ought to be refactored into a Python function. When I tried to do that, I got loads of strange Python problems which may indicate bugs in nbdsh itself or problems with my
2019 Sep 26
0
[PATCH libnbd 2/2] api: Implement local command with systemd socket activation.
...strings are truncated. - Strings with non-printable characters are escaped. diff --git a/generator/generator b/generator/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...
2019 Sep 12
0
[PATCH nbdkit v2 3/3] tests: Add a simple test of nbdkit_export_name.
...for e in "" "test" "/" "//" " " \ + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" +do + export e sock + nbdsh -c ' +import os + +e = os.environ["e"] +h.set_export_name (e) +h.connect_unix (os.environ["sock"]) + +size = h.get_size () +print ("size=%r e=%r" % (size, e)) +assert size == len (e) + +# Zero-sized reads are not defined in the NBD protocol. +if size > 0: + buf = h.pread (size, 0) + print ("buf=%r e=%r" % (buf, e)) + assert buf.decod...