]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix non-admin users not receiving any updates in web UI
authorMichael Marley <michael@michaelmarley.com>
Sun, 24 Sep 2023 19:35:33 +0000 (15:35 -0400)
committerFlole998 <Flole998@users.noreply.github.com>
Sun, 1 Oct 2023 00:12:22 +0000 (02:12 +0200)
All the way back in 54e63e3f9af8fdc0d23f61f3cda7fa7b246c1732, there
was a fix to stop non-admin users from receiving log messages with
potentially-sensitive data.  However, this stopped non-admin webui
users from receiving almost any updates over the websocket
interface, which causes a bug where such users don't see newly-
created DVR entries, etc. until refreshing the page.  This patch
allows for more granular control over what non-admin users
receive.  Specifically, messages originating from subscriptions.c,
mpegts_input.c, and api_service.c, along with all log messages, are
still only sent to admins because they may contain sensitive data
and/or they are only relevant to administrative parts of the UI.
Other messages, such as idnode, DVR, and EPG-related messages, are
once again sent to all webui users to keep the UI up-to-date.

src/api/api_service.c
src/dvr/dvr_vfsmgr.c
src/idnode.c
src/input/mpegts/mpegts_input.c
src/notify.c
src/notify.h
src/subscriptions.c
src/webui/comet.c
src/webui/webui.h

index baab39385735de4a351622e968b25437ba67e328..d74ba410eae8f47a2def2dcfd886b047deaa5684 100644 (file)
@@ -66,7 +66,7 @@ api_mapper_status
 void
 api_service_mapper_notify ( void )
 {
-  notify_by_msg("servicemapper", api_mapper_status_msg(), 0);
+  notify_by_msg("servicemapper", api_mapper_status_msg(), 1, 0);
 }
 
 static htsmsg_t *
index 6be735d1c9e1e9c0e7df94a9661018eb32d8c0d3..dc6b5988013fa409cae75ed09d81ebdeaa8a5422 100644 (file)
@@ -420,7 +420,7 @@ dvr_get_disk_space_tcb(void *opaque, int dearmed)
     htsmsg_add_s64(m, "freediskspace", dvr_bfree);
     htsmsg_add_s64(m, "useddiskspace", dvr_bused);
     htsmsg_add_s64(m, "totaldiskspace", dvr_btotal);
-    notify_by_msg("diskspaceUpdate", m, 0);
+    notify_by_msg("diskspaceUpdate", m, 0, 0);
 
     /* check free disk space for each dvr config and start cleanup if needed */
     dvr_disk_space_check();
index 357d05992027ac00ee6a142010879178aa161e7a..457b1917179b8f1cf21e397024a37faca1c672c2 100644 (file)
@@ -1922,7 +1922,7 @@ idnode_notify_title_changed (void *in)
 {
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_uuid(m, "uuid", &((idnode_t *)in)->in_uuid);
-  notify_by_msg("title", m, NOTIFY_REWRITE_TITLE);
+  notify_by_msg("title", m, 0, NOTIFY_REWRITE_TITLE);
   idnode_notify_changed(in);
 }
 
index f1475ff6ea9ac95de54dac82203edd70047205c4..c4856b08c9ed5001790f47d8180865ad42039d6b 100644 (file)
@@ -2045,7 +2045,7 @@ mpegts_input_status_timer ( void *p )
     mpegts_input_stream_status(mmi, &st);
     e = tvh_input_stream_create_msg(&st);
     htsmsg_add_u32(e, "update", 1);
-    notify_by_msg("input_status", e, 0);
+    notify_by_msg("input_status", e, 1, 0);
     subs += st.subs_count;
     tvh_input_stream_destroy(&st);
   }
index 23d02ad1d18be5e5db753fc7b18f452870f4493e..056d5df6a41f6f853195ddcb099d59cf765ddfce 100644 (file)
@@ -33,10 +33,10 @@ static pthread_t              notify_tid;
 static void*                  notify_thread(void* p);
 
 void
-notify_by_msg(const char *class, htsmsg_t *m, int rewrite)
+notify_by_msg(const char *class, htsmsg_t *m, int isrestricted, int rewrite)
 {
   htsmsg_add_str(m, "notificationClass", class);
-  comet_mailbox_add_message(m, 0, rewrite);
+  comet_mailbox_add_message(m, 0, isrestricted, rewrite);
   htsmsg_destroy(m);
 }
 
@@ -46,7 +46,7 @@ notify_reload(const char *class)
 {
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_u32(m, "reload", 1);
-  notify_by_msg(class, m, 0);
+  notify_by_msg(class, m, 0, 0);
 }
 
 void
@@ -103,7 +103,7 @@ notify_thread ( void *p )
     tvh_mutex_lock(&global_lock);
 
     HTSMSG_FOREACH(f, q)
-      notify_by_msg(htsmsg_field_name(f), htsmsg_detach_submsg(f), 0);
+      notify_by_msg(htsmsg_field_name(f), htsmsg_detach_submsg(f), 0, 0);
 
     /* Finished */
     tvh_mutex_unlock(&global_lock);
index 570c93a71561b27a1a33fbfe08f9391e308438c1..e7bf18b5384c49d0bbc7d9f5860e73f0a9a0f6ec 100644 (file)
@@ -24,7 +24,7 @@
 #define NOTIFY_REWRITE_TITLE         1
 #define NOTIFY_REWRITE_SUBSCRIPTIONS 2
 
-void notify_by_msg(const char *class, htsmsg_t *m, int rewrite);
+void notify_by_msg(const char *class, htsmsg_t *m, int isrestricted, int rewrite);
 
 void notify_reload(const char *class);
 
index 60284ed94c7923eb9b48a4987f7aba27450d6657..08f490e1dfff77a663b790fc58dd62a5bf584316 100644 (file)
@@ -1124,7 +1124,7 @@ subscription_status_callback ( void *p )
 
     htsmsg_t *m = subscription_create_msg(s, NULL);
     htsmsg_add_u32(m, "updateEntry", 1);
-    notify_by_msg("subscriptions", m, NOTIFY_REWRITE_SUBSCRIPTIONS);
+    notify_by_msg("subscriptions", m, 1, NOTIFY_REWRITE_SUBSCRIPTIONS);
     count++;
   }
   if (old_count != count) {
index 2e124de152aabcf50e58daa5e56fa8cf74b0cb54..b4c9c8fe552d03eeb22a72e8243ece542c8a7b22 100644 (file)
@@ -552,7 +552,7 @@ comet_mailbox_rewrite_msg(int rewrite, htsmsg_t *m, const char *lang)
  *
  */
 void
-comet_mailbox_add_message(htsmsg_t *m, int isdebug, int rewrite)
+comet_mailbox_add_message(htsmsg_t *m, int isdebug, int isrestricted, int rewrite)
 {
   comet_mailbox_t *cmb;
   htsmsg_t *e;
@@ -565,7 +565,7 @@ comet_mailbox_add_message(htsmsg_t *m, int isdebug, int rewrite)
   if (atomic_get(&comet_running)) {
     LIST_FOREACH(cmb, &mailboxes, cmb_link) {
 
-      if(cmb->cmb_restricted)
+      if(isrestricted && cmb->cmb_restricted)
         continue;
 
       if(isdebug && !cmb->cmb_debug)
@@ -593,6 +593,6 @@ comet_mailbox_add_logmsg(const char *txt, int isdebug, int rewrite)
   htsmsg_t *m = htsmsg_create_map();
   htsmsg_add_str(m, "notificationClass", "logmessage");
   htsmsg_add_str(m, "logtxt", txt);
-  comet_mailbox_add_message(m, isdebug, 0);
+  comet_mailbox_add_message(m, isdebug, 1, 0);
   htsmsg_destroy(m);
 }
index 344caeae02b8dc493508f3255692de5c093170a2..003a778d8a3fa196956fdea4f2ceb0328f785232 100644 (file)
@@ -65,7 +65,7 @@ void comet_init(void);
 
 void comet_done(void);
 
-void comet_mailbox_add_message(htsmsg_t *m, int isdebug, int rewrite);
+void comet_mailbox_add_message(htsmsg_t *m, int isdebug, int isrestricted, int rewrite);
 
 void comet_mailbox_add_logmsg(const char *txt, int isdebug, int rewrite);