From c96c32b4f2151d58d3022261788d8c9ca087400e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Tue, 3 Mar 2009 22:08:36 +0000 Subject: [PATCH] Send 'noaccess' = 1 in loginAck if no privs where granted during login. --- htsp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htsp.c b/htsp.c index 24ef3215..82e91e17 100644 --- a/htsp.c +++ b/htsp.c @@ -42,6 +42,8 @@ #define HTSP_PROTO_VERSION 1 +#define HTSP_PRIV_MASK (ACCESS_STREAMING) + extern const char *htsversion; LIST_HEAD(htsp_connection_list, htsp_connection); @@ -247,11 +249,12 @@ htsp_send_message(htsp_connection_t *htsp, htsmsg_t *m, htsp_msg_q_t *hmq) * */ static void -htsp_send_login_ack(htsp_connection_t *htsp, const char *error) +htsp_send_login_ack(htsp_connection_t *htsp, const char *error, int noaccess) { htsmsg_t *m = htsmsg_create_map(); htsmsg_add_str(m, "method", "loginAck"); if(error) htsmsg_add_str(m, "error", error); + if(noaccess) htsmsg_add_u32(m, "noaccess", 1); htsp_send_message(htsp, m, NULL); } @@ -632,7 +635,7 @@ htsp_read_loop(htsp_connection_t *htsp) if(htsp->htsp_version != HTSP_PROTO_VERSION) { tvhlog(LOG_ERR, "htsp", "%s: Login failure, unsupported version %d", htsp->htsp_name, htsp->htsp_version); - htsp_send_login_ack(htsp, "Unsupported protocol version"); + htsp_send_login_ack(htsp, "Unsupported protocol version", 0); return -1; } @@ -649,7 +652,8 @@ htsp_read_loop(htsp_connection_t *htsp) tvhlog(LOG_INFO, "htsp", "%s: Connected as user %s", htsp->htsp_name, htsp->htsp_username ?: ""); - htsp_send_login_ack(htsp, NULL); + htsp_send_login_ack(htsp, NULL, + !(htsp->htsp_granted_access & HTSP_PRIV_MASK)); /* Session main loop */