From 4b0945bf01b837f840ebc56bf039144fc4ce57e8 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Tue, 11 Oct 2022 23:27:16 +0100 Subject: [PATCH] raop: Use the real URI for digest authentication rather than `*` Yamaha MusicCast (or at least the RX-A880) seems to be stricter about the URI here, as it rejects `*`. Examples, such as those documented by OpenAirplay, use the real URI. --- src/modules/module-raop-sink.c | 10 ++++++---- src/modules/module-raop/rtsp-client.c | 5 +++++ src/modules/module-raop/rtsp-client.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c index b3a71a807..dfff77691 100644 --- a/src/modules/module-raop-sink.c +++ b/src/modules/module-raop-sink.c @@ -1219,7 +1219,7 @@ static int rtsp_do_auth(struct impl *impl, const struct spa_dict *headers) spa_scnprintf(auth, sizeof(auth), "Basic %s", enc); } else if (spa_streq(tokens[0], "Digest")) { - const char *realm, *nonce; + const char *realm, *nonce, *url; char h1[MD5_HASH_LENGTH+1]; char h2[MD5_HASH_LENGTH+1]; char resp[MD5_HASH_LENGTH+1]; @@ -1229,13 +1229,15 @@ static int rtsp_do_auth(struct impl *impl, const struct spa_dict *headers) if (realm == NULL || nonce == NULL) goto error; + url = pw_rtsp_client_get_url(impl->rtsp); + MD5_hash(h1, "%s:%s:%s", DEFAULT_USER_NAME, realm, impl->password); - MD5_hash(h2, "OPTIONS:*"); + MD5_hash(h2, "OPTIONS:%s", url); MD5_hash(resp, "%s:%s:%s", h1, nonce, h2); spa_scnprintf(auth, sizeof(auth), - "username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"*\", response=\"%s\"", - DEFAULT_USER_NAME, realm, nonce, resp); + "username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"", + DEFAULT_USER_NAME, realm, nonce, url, resp); } else goto error; diff --git a/src/modules/module-raop/rtsp-client.c b/src/modules/module-raop/rtsp-client.c index 6e80b17b1..7f8473551 100644 --- a/src/modules/module-raop/rtsp-client.c +++ b/src/modules/module-raop/rtsp-client.c @@ -133,6 +133,11 @@ void *pw_rtsp_client_get_user_data(struct pw_rtsp_client *client) return client->user_data; } +const char *pw_rtsp_client_get_url(struct pw_rtsp_client *client) +{ + return client->url; +} + void pw_rtsp_client_add_listener(struct pw_rtsp_client *client, struct spa_hook *listener, const struct pw_rtsp_client_events *events, void *data) diff --git a/src/modules/module-raop/rtsp-client.h b/src/modules/module-raop/rtsp-client.h index 75b1ce6a1..9dcc9a1d4 100644 --- a/src/modules/module-raop/rtsp-client.h +++ b/src/modules/module-raop/rtsp-client.h @@ -57,6 +57,7 @@ struct pw_rtsp_client * pw_rtsp_client_new(struct pw_loop *main_loop, void pw_rtsp_client_destroy(struct pw_rtsp_client *client); void *pw_rtsp_client_get_user_data(struct pw_rtsp_client *client); +const char *pw_rtsp_client_get_url(struct pw_rtsp_client *client); void pw_rtsp_client_add_listener(struct pw_rtsp_client *client, struct spa_hook *listener,