This partially reverts commit 9b45c9f049a7e9b6c1abfa6988b63b760714e169. It changed the default format of socket address from the one SASL requires, but did not adjust all the callers. It also removed the test coverage for it. Revert most of the changes except the virSocketAddrFormatFull support for URI-formatted strings. This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1345743 while reverting the format used by virt-admin's client-info command from the URI one to the SASL one. https://bugzilla.redhat.com/show_bug.cgi?id=1345743 --- daemon/remote.c | 13 ++----------- src/remote/remote_driver.c | 7 ------- src/rpc/virnetclient.c | 10 ---------- src/rpc/virnetclient.h | 2 -- src/rpc/virnetserverclient.c | 13 ------------- src/rpc/virnetserverclient.h | 2 -- src/rpc/virnetsocket.c | 17 ++--------------- src/rpc/virnetsocket.h | 2 -- tests/virnetsockettest.c | 10 +++++----- 9 files changed, 9 insertions(+), 67 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 4e2aff8..ea4753f 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -3016,8 +3016,6 @@ remoteDispatchAuthSaslInit(virNetServerPtr server ATTRIBUTE_UNUSED, virNetSASLSessionPtr sasl = NULL; struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); - char *localAddr = NULL; - char *remoteAddr = NULL; virMutexLock(&priv->lock); @@ -3028,17 +3026,10 @@ remoteDispatchAuthSaslInit(virNetServerPtr server ATTRIBUTE_UNUSED, goto authfail; } - localAddr = virNetServerClientLocalAddrFormatSASL(client); - remoteAddr = virNetServerClientRemoteAddrFormatSASL(client); - sasl = virNetSASLSessionNewServer(saslCtxt, "libvirt", - localAddr, - remoteAddr); - - VIR_FREE(localAddr); - VIR_FREE(remoteAddr); - + virNetServerClientLocalAddrString(client), + virNetServerClientRemoteAddrString(client)); if (!sasl) goto authfail; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 84b6d58..0315c6e 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3809,8 +3809,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv, sasl_callback_t *saslcb = NULL; int ret = -1; const char *mechlist; - char *localAddr = NULL; - char *remoteAddr = NULL; virNetSASLContextPtr saslCtxt; virNetSASLSessionPtr sasl = NULL; struct remoteAuthInteractState state; @@ -3829,9 +3827,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv, saslcb = NULL; } - localAddr = virNetClientLocalAddrFormatSASL(priv->client); - remoteAddr = virNetClientRemoteAddrFormatSASL(priv->client); - /* Setup a handle for being a client */ if (!(sasl = virNetSASLSessionNewClient(saslCtxt, "libvirt", @@ -4019,8 +4014,6 @@ remoteAuthSASL(virConnectPtr conn, struct private_data *priv, cleanup: VIR_FREE(serverin); - VIR_FREE(localAddr); - VIR_FREE(remoteAddr); remoteAuthInteractStateClear(&state, true); VIR_FREE(saslcb); diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 3d59990..9c0d190 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -954,16 +954,6 @@ const char *virNetClientRemoteAddrString(virNetClientPtr client) return virNetSocketRemoteAddrString(client->sock); } -char *virNetClientLocalAddrFormatSASL(virNetClientPtr client) -{ - return virNetSocketLocalAddrFormatSASL(client->sock); -} - -char *virNetClientRemoteAddrFormatSASL(virNetClientPtr client) -{ - return virNetSocketRemoteAddrFormatSASL(client->sock); -} - #if WITH_GNUTLS int virNetClientGetTLSKeySize(virNetClientPtr client) { diff --git a/src/rpc/virnetclient.h b/src/rpc/virnetclient.h index 4b78677..38f929c 100644 --- a/src/rpc/virnetclient.h +++ b/src/rpc/virnetclient.h @@ -123,8 +123,6 @@ bool virNetClientIsOpen(virNetClientPtr client); const char *virNetClientLocalAddrString(virNetClientPtr client); const char *virNetClientRemoteAddrString(virNetClientPtr client); -char *virNetClientLocalAddrFormatSASL(virNetClientPtr client); -char *virNetClientRemoteAddrFormatSASL(virNetClientPtr client); # ifdef WITH_GNUTLS int virNetClientGetTLSKeySize(virNetClientPtr client); diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index ef83507..2bc058c 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -918,19 +918,6 @@ const char *virNetServerClientRemoteAddrString(virNetServerClientPtr client) return virNetSocketRemoteAddrString(client->sock); } -char *virNetServerClientLocalAddrFormatSASL(virNetServerClientPtr client) -{ - if (!client->sock) - return NULL; - return virNetSocketLocalAddrFormatSASL(client->sock); -} - -char *virNetServerClientRemoteAddrFormatSASL(virNetServerClientPtr client) -{ - if (!client->sock) - return NULL; - return virNetSocketRemoteAddrFormatSASL(client->sock); -} void virNetServerClientDispose(void *obj) { diff --git a/src/rpc/virnetserverclient.h b/src/rpc/virnetserverclient.h index 594803b..c8b8dc1 100644 --- a/src/rpc/virnetserverclient.h +++ b/src/rpc/virnetserverclient.h @@ -140,8 +140,6 @@ int virNetServerClientStartKeepAlive(virNetServerClientPtr client); const char *virNetServerClientLocalAddrString(virNetServerClientPtr client); const char *virNetServerClientRemoteAddrString(virNetServerClientPtr client); -char *virNetServerClientLocalAddrFormatSASL(virNetServerClientPtr client); -char *virNetServerClientRemoteAddrFormatSASL(virNetServerClientPtr client); int virNetServerClientSendMessage(virNetServerClientPtr client, virNetMessagePtr msg); diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index a90cc55..d909b94 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -262,11 +262,11 @@ static virNetSocketPtr virNetSocketNew(virSocketAddrPtr localAddr, if (localAddr && - !(sock->localAddrStr = virSocketAddrFormatFull(localAddr, true, NULL))) + !(sock->localAddrStr = virSocketAddrFormatFull(localAddr, true, ";"))) goto error; if (remoteAddr && - !(sock->remoteAddrStr = virSocketAddrFormatFull(remoteAddr, true, NULL))) + !(sock->remoteAddrStr = virSocketAddrFormatFull(remoteAddr, true, ";"))) goto error; sock->client = isClient; @@ -1465,19 +1465,6 @@ const char *virNetSocketRemoteAddrString(virNetSocketPtr sock) return sock->remoteAddrStr; } -/* These helper functions return a SASL-formatted socket addr string, - * caller is responsible for freeing the string. - */ -char *virNetSocketLocalAddrFormatSASL(virNetSocketPtr sock) -{ - return virSocketAddrFormatFull(&sock->localAddr, true, ";"); -} - -char *virNetSocketRemoteAddrFormatSASL(virNetSocketPtr sock) -{ - return virSocketAddrFormatFull(&sock->remoteAddr, true, ";"); -} - #if WITH_GNUTLS static ssize_t virNetSocketTLSSessionWrite(const char *buf, diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h index 4eb7187..5de3d92 100644 --- a/src/rpc/virnetsocket.h +++ b/src/rpc/virnetsocket.h @@ -150,8 +150,6 @@ bool virNetSocketHasPendingData(virNetSocketPtr sock); const char *virNetSocketLocalAddrString(virNetSocketPtr sock); const char *virNetSocketRemoteAddrString(virNetSocketPtr sock); -char *virNetSocketLocalAddrFormatSASL(virNetSocketPtr sock); -char *virNetSocketRemoteAddrFormatSASL(virNetSocketPtr sock); int virNetSocketListen(virNetSocketPtr sock, int backlog); int virNetSocketAccept(virNetSocketPtr sock, diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index bbecb3c..9df90a9 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -249,7 +249,7 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) if (virNetSocketNewListenUNIX(path, 0700, -1, getegid(), &lsock) < 0) goto cleanup; - if (STRNEQ(virNetSocketLocalAddrString(lsock), "127.0.0.1:0")) { + if (STRNEQ(virNetSocketLocalAddrString(lsock), "127.0.0.1;0")) { VIR_DEBUG("Unexpected local address"); goto cleanup; } @@ -265,12 +265,12 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) if (virNetSocketNewConnectUNIX(path, false, NULL, &csock) < 0) goto cleanup; - if (STRNEQ(virNetSocketLocalAddrString(csock), "127.0.0.1:0")) { + if (STRNEQ(virNetSocketLocalAddrString(csock), "127.0.0.1;0")) { VIR_DEBUG("Unexpected local address"); goto cleanup; } - if (STRNEQ(virNetSocketRemoteAddrString(csock), "127.0.0.1:0")) { + if (STRNEQ(virNetSocketRemoteAddrString(csock), "127.0.0.1;0")) { VIR_DEBUG("Unexpected local address"); goto cleanup; } @@ -282,12 +282,12 @@ static int testSocketUNIXAddrs(const void *data ATTRIBUTE_UNUSED) } - if (STRNEQ(virNetSocketLocalAddrString(ssock), "127.0.0.1:0")) { + if (STRNEQ(virNetSocketLocalAddrString(ssock), "127.0.0.1;0")) { VIR_DEBUG("Unexpected local address"); goto cleanup; } - if (STRNEQ(virNetSocketRemoteAddrString(ssock), "127.0.0.1:0")) { + if (STRNEQ(virNetSocketRemoteAddrString(ssock), "127.0.0.1;0")) { VIR_DEBUG("Unexpected local address"); goto cleanup; } -- 2.7.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list