]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
http: add http_username() and use it in webui, fixes #5214, fixes #5215
authorJaroslav Kysela <perex@perex.cz>
Thu, 20 Sep 2018 14:49:05 +0000 (16:49 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 20 Sep 2018 14:49:05 +0000 (16:49 +0200)
src/http.c
src/http.h
src/satip/rtsp.c
src/webui/webui.c

index 7407111f1e1e96005ea88d2098ff9a4aa96255c5..1a9df5069e64e5a762bf630f64609ef2eb589971 100644 (file)
@@ -1145,6 +1145,17 @@ http_access_verify_channel(http_connection_t *hc, int mask,
   return res;
 }
 
+/**
+ *
+ */
+const char *
+http_username(http_connection_t *hc)
+{
+  if (strempty(hc->hc_username) && hc->hc_access)
+      return hc->hc_access->aa_username;
+  return hc->hc_username;
+}
+
 /**
  *
  */
index c2a44a927ac89a2e394af71cadfe2531498daaa4..18c97c40ebb5dc6cf568ad43c4185e0a6ff8e0a2 100644 (file)
@@ -215,6 +215,8 @@ static inline int http_args_empty(const http_arg_list_t *list) { return TAILQ_EM
 
 int http_tokenize(char *buf, char **vec, int vecsize, int delimiter);
 
+const char * http_username(http_connection_t *hc);
+
 void http_alive(http_connection_t *hc);
 
 void http_error(http_connection_t *hc, int error);
index cbde6f6519ba3430e4ec8e7807e5e2ac68ec1b4a..d0af82c8b373bd04ecffea41e37604e6241b6ca5 100644 (file)
@@ -686,7 +686,7 @@ rtsp_start
                                    "SAT>IP",
                                    rs->prch.prch_flags |
                                    SUBSCRIPTION_STREAMING,
-                                   addrbuf, hc->hc_username,
+                                   addrbuf, http_username(hc),
                                    http_arg_get(&hc->hc_args, "User-Agent"),
                                    NULL);
     if (!rs->subs)
@@ -1664,6 +1664,7 @@ rtsp_stream_status ( void *opaque, htsmsg_t *m )
 {
   http_connection_t *hc = opaque;
   char buf[128];
+  const char *username;
   struct session *rs = NULL;
   htsmsg_t *c, *tcp = NULL, *udp = NULL;
   int udpport, s32;
@@ -1673,8 +1674,9 @@ rtsp_stream_status ( void *opaque, htsmsg_t *m )
     tcp_get_str_from_ip(hc->hc_proxy_ip, buf, sizeof(buf));
     htsmsg_add_str(m, "proxy", buf);
   }
-  if (hc->hc_username)
-    htsmsg_add_str(m, "user", hc->hc_username);
+  username = http_username(hc);
+  if (username)
+    htsmsg_add_str(m, "user", username);
 
   TAILQ_FOREACH(rs, &rtsp_sessions, link) {
     if (hc->hc_session &&
index 2ae59a49dc984a8af2f31874d0dd55eb8bed04d5..f1b2fa0c3d2182e2e7ad3a6f8e664feae8f143f6 100644 (file)
@@ -292,14 +292,16 @@ http_stream_status ( void *opaque, htsmsg_t *m )
 {
   http_connection_t *hc = opaque;
   char buf[128];
+  const char *username;
 
   htsmsg_add_str(m, "type", "HTTP");
   if (hc->hc_proxy_ip) {
     tcp_get_str_from_ip(hc->hc_proxy_ip, buf, sizeof(buf));
     htsmsg_add_str(m, "proxy", buf);
   }
-  if (hc->hc_username)
-    htsmsg_add_str(m, "user", hc->hc_username);
+  username = http_username(hc);
+  if (username)
+    htsmsg_add_str(m, "user", username);
 }
 
 static inline void *
@@ -1070,7 +1072,7 @@ http_stream_service(http_connection_t *hc, service_t *service, int weight)
                                          prch.prch_flags | SUBSCRIPTION_STREAMING |
                                            eflags,
                                          hc->hc_peer_ipstr,
-                                        hc->hc_username,
+                                        http_username(hc),
                                         http_arg_get(&hc->hc_args, "User-Agent"),
                                         NULL);
     if(s) {
@@ -1147,7 +1149,7 @@ http_stream_mux(http_connection_t *hc, mpegts_mux_t *mm, int weight)
     s = subscription_create_from_mux(&prch, NULL, weight ?: 10, "HTTP",
                                      prch.prch_flags |
                                      SUBSCRIPTION_STREAMING,
-                                     hc->hc_peer_ipstr, hc->hc_username,
+                                     hc->hc_peer_ipstr, http_username(hc),
                                      http_arg_get(&hc->hc_args, "User-Agent"),
                                      NULL);
     if (s) {
@@ -1211,7 +1213,7 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
     s = subscription_create_from_channel(&prch,
                  NULL, weight, "HTTP",
                  prch.prch_flags | SUBSCRIPTION_STREAMING,
-                 hc->hc_peer_ipstr, hc->hc_username,
+                 hc->hc_peer_ipstr, http_username(hc),
                  http_arg_get(&hc->hc_args, "User-Agent"),
                  NULL);
 
@@ -1620,7 +1622,7 @@ page_dvrfile_preop(http_connection_t *hc, off_t file_start,
   if (priv->tcp_id && !hc->hc_no_output && content_len > 64*1024) {
     priv->sub = subscription_create_from_file("HTTP", priv->charset,
                                               priv->fname, hc->hc_peer_ipstr,
-                                              hc->hc_username,
+                                              http_username(hc),
                                               http_arg_get(&hc->hc_args, "User-Agent"));
     if (priv->sub == NULL) {
       http_stream_postop(priv->tcp_id);