]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
ACL: Add HTSP Recorder permission, fixes #2541
authorJaroslav Kysela <perex@perex.cz>
Fri, 12 Dec 2014 11:01:21 +0000 (12:01 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 12 Dec 2014 11:01:21 +0000 (12:01 +0100)
docs/html/config_access.html
src/access.c
src/access.h
src/htsp_server.c
src/webui/static/app/acleditor.js
src/webui/webui.c

index 392439f5930e01ac9dafe043404a048e28fc6bd9..e62900b7bfd0cf0b7b7e2104224037832f0f89ed 100644 (file)
@@ -89,6 +89,10 @@ The columns have the following functions:
   <dd>
   Enables access to all video recording functions. This also include administration of the auto recordings.
 
+  <dt><b>HTSP DVR</b>
+  <dd>
+  Enables access to video recording functions for the HTSP protocol (Showtime, XBMC etc.).
+
   <dt><b>DVR Config Profile</b>
   <dd>
   If set, the user will only be able to use the DVR config profile
index 93b120043778337d9f056fb4fc5f3a9b805d32c7..dde6415e4774d9e0e6fed20805831976f0c60f90 100644 (file)
@@ -357,13 +357,15 @@ access_dump_a(access_t *a)
   int first;
 
   snprintf(buf, sizeof(buf),
-    "%s:%s [%s%s%s%s%s], conn=%u, chmin=%llu, chmax=%llu%s",
+    "%s:%s [%s%s%s%s%s%s%s], conn=%u, chmin=%llu, chmax=%llu%s",
     a->aa_representative ?: "<no-id>",
     a->aa_username ?: "<no-user>",
     a->aa_rights & ACCESS_STREAMING          ? "S" : "",
     a->aa_rights & ACCESS_ADVANCED_STREAMING ? "A" : "",
+    a->aa_rights & ACCESS_HTSP_STREAMING     ? "T" : "",
     a->aa_rights & ACCESS_WEB_INTERFACE      ? "W" : "",
     a->aa_rights & ACCESS_RECORDER           ? "R" : "",
+    a->aa_rights & ACCESS_HTSP_RECORDER      ? "E" : "",
     a->aa_rights & ACCESS_ADMIN              ? "*" : "",
     a->aa_conn_limit,
     (long long)a->aa_chmin, (long long)a->aa_chmax,
@@ -808,6 +810,8 @@ access_entry_update_rights(access_entry_t *ae)
     r |= ACCESS_HTSP_STREAMING;
   if (ae->ae_dvr)
     r |= ACCESS_RECORDER;
+  if (ae->ae_htsp_dvr)
+    r |= ACCESS_HTSP_RECORDER;
   if (ae->ae_webui)
     r |= ACCESS_WEB_INTERFACE;
   if (ae->ae_admin)
@@ -843,6 +847,7 @@ access_entry_create(const char *uuid, htsmsg_t *conf)
 
   if (conf) {
     ae->ae_htsp_streaming = 1;
+    ae->ae_htsp_dvr       = 1;
     idnode_load(&ae->ae_id, conf);
     /* note password has PO_NOSAVE, thus it must be set manually */
     if ((s = htsmsg_get_str(conf, "password")) != NULL)
@@ -1286,6 +1291,12 @@ const idclass_t access_entry_class = {
       .name     = "Video Recorder",
       .off      = offsetof(access_entry_t, ae_dvr),
     },
+    {
+      .type     = PT_BOOL,
+      .id       = "htsp_dvr",
+      .name     = "HTSP DVR",
+      .off      = offsetof(access_entry_t, ae_htsp_dvr),
+    },
     {
       .type     = PT_STR,
       .id       = "dvr_config",
index 84cb05db8d8d93a70103c36980f7478356f07df6..585676240bade9d88711fa59614ae46a53c15431 100644 (file)
@@ -65,6 +65,7 @@ typedef struct access_entry {
   uint32_t ae_conn_limit;
 
   int ae_dvr;
+  int ae_htsp_dvr;
   struct dvr_config *ae_dvr_config;
   LIST_ENTRY(access_entry) ae_dvr_config_link;
 
@@ -117,7 +118,8 @@ typedef struct access_ticket {
 #define ACCESS_HTSP_STREAMING     (1<<2)
 #define ACCESS_WEB_INTERFACE      (1<<3)
 #define ACCESS_RECORDER           (1<<4)
-#define ACCESS_ADMIN              (1<<5)
+#define ACCESS_HTSP_RECORDER      (1<<5)
+#define ACCESS_ADMIN              (1<<6)
 #define ACCESS_OR                 (1<<30)
 
 #define ACCESS_FULL \
index d7b2e0e948806a32905975bf884cab37f0ca1c19..1d0569e7a68de65ecff6f19364d906f150f1da58 100644 (file)
@@ -2191,14 +2191,14 @@ struct {
   { "getEvents",                htsp_method_getEvents,          ACCESS_HTSP_STREAMING},
   { "epgQuery",                 htsp_method_epgQuery,           ACCESS_HTSP_STREAMING},
   { "getEpgObject",             htsp_method_getEpgObject,       ACCESS_HTSP_STREAMING},
-  { "getDvrConfigs",            htsp_method_getDvrConfigs,      ACCESS_RECORDER},
-  { "addDvrEntry",              htsp_method_addDvrEntry,        ACCESS_RECORDER},
-  { "updateDvrEntry",           htsp_method_updateDvrEntry,     ACCESS_RECORDER},
-  { "cancelDvrEntry",           htsp_method_cancelDvrEntry,     ACCESS_RECORDER},
-  { "deleteDvrEntry",           htsp_method_deleteDvrEntry,     ACCESS_RECORDER},
-  { "addAutorecEntry",          htsp_method_addAutorecEntry,    ACCESS_RECORDER},
-  { "deleteAutorecEntry",       htsp_method_deleteAutorecEntry, ACCESS_RECORDER},
-  { "getDvrCutpoints",          htsp_method_getDvrCutpoints,    ACCESS_RECORDER},
+  { "getDvrConfigs",            htsp_method_getDvrConfigs,      ACCESS_HTSP_RECORDER},
+  { "addDvrEntry",              htsp_method_addDvrEntry,        ACCESS_HTSP_RECORDER},
+  { "updateDvrEntry",           htsp_method_updateDvrEntry,     ACCESS_HTSP_RECORDER},
+  { "cancelDvrEntry",           htsp_method_cancelDvrEntry,     ACCESS_HTSP_RECORDER},
+  { "deleteDvrEntry",           htsp_method_deleteDvrEntry,     ACCESS_HTSP_RECORDER},
+  { "addAutorecEntry",          htsp_method_addAutorecEntry,    ACCESS_HTSP_RECORDER},
+  { "deleteAutorecEntry",       htsp_method_deleteAutorecEntry, ACCESS_HTSP_RECORDER},
+  { "getDvrCutpoints",          htsp_method_getDvrCutpoints,    ACCESS_HTSP_RECORDER},
   { "getTicket",                htsp_method_getTicket,          ACCESS_HTSP_STREAMING},
   { "subscribe",                htsp_method_subscribe,          ACCESS_HTSP_STREAMING},
   { "unsubscribe",              htsp_method_unsubscribe,        ACCESS_HTSP_STREAMING},
@@ -2209,11 +2209,11 @@ struct {
   { "subscriptionLive",         htsp_method_live,               ACCESS_HTSP_STREAMING},
   { "subscriptionFilterStream", htsp_method_filter_stream,      ACCESS_HTSP_STREAMING},
   { "getProfiles",              htsp_method_getProfiles,        ACCESS_HTSP_STREAMING},
-  { "fileOpen",                 htsp_method_file_open,          ACCESS_RECORDER},
-  { "fileRead",                 htsp_method_file_read,          ACCESS_RECORDER},
-  { "fileClose",                htsp_method_file_close,         ACCESS_RECORDER},
-  { "fileStat",                 htsp_method_file_stat,          ACCESS_RECORDER},
-  { "fileSeek",                 htsp_method_file_seek,          ACCESS_RECORDER},
+  { "fileOpen",                 htsp_method_file_open,          ACCESS_HTSP_RECORDER},
+  { "fileRead",                 htsp_method_file_read,          ACCESS_HTSP_RECORDER},
+  { "fileClose",                htsp_method_file_close,         ACCESS_HTSP_RECORDER},
+  { "fileStat",                 htsp_method_file_stat,          ACCESS_HTSP_RECORDER},
+  { "fileSeek",                 htsp_method_file_seek,          ACCESS_HTSP_RECORDER},
 };
 
 #define NUM_METHODS (sizeof(htsp_methods) / sizeof(htsp_methods[0]))
index 0f9c33fbddfd81b2fc42fcfed3bf38af51631103..97ca4299f581b33bfab556d93894ccda67799c0f 100644 (file)
@@ -7,7 +7,7 @@ tvheadend.acleditor = function(panel, index)
     var list = 'enabled,username,password,prefix,' +
                'webui,admin,' +
                'streaming,adv_streaming,htsp_streaming,' +
-               'profile,conn_limit,dvr,dvr_config,' +
+               'profile,conn_limit,dvr,htsp_dvr,dvr_config,' +
                'channel_min,channel_max,channel_tag,comment';
 
     tvheadend.idnode_grid(panel, {
@@ -24,6 +24,7 @@ tvheadend.acleditor = function(panel, index)
             adv_streaming:  { width: 200 },
             htsp_streaming: { width: 200 },
             dvr:            { width: 150 },
+            htsp_dvr:       { width: 150 },
             webui:          { width: 140 },
             admin:          { width: 100 },
             conn_limit:     { width: 160 },
index d58f0d7c5abc686284e2f7dd554e42a64db780ea..98e4f1c93aaf6d82ea2344cbd646e1db0c4a498d 100644 (file)
@@ -1073,9 +1073,10 @@ page_play(http_connection_t *hc, const char *remain, void *opaque)
     return HTTP_STATUS_NOT_FOUND;
 
   if(hc->hc_access == NULL ||
-     (access_verify2(hc->hc_access, ACCESS_STREAMING) &&
-      access_verify2(hc->hc_access, ACCESS_ADVANCED_STREAMING) &&
-      access_verify2(hc->hc_access, ACCESS_RECORDER)))
+     access_verify2(hc->hc_access, ACCESS_OR |
+                                   ACCESS_STREAMING |
+                                   ACCESS_ADVANCED_STREAMING |
+                                   ACCESS_RECORDER))
     return HTTP_STATUS_UNAUTHORIZED;
 
   playlist = http_arg_get(&hc->hc_req_args, "playlist");
@@ -1116,9 +1117,10 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque)
     return HTTP_STATUS_BAD_REQUEST;
 
   if(hc->hc_access == NULL ||
-     (access_verify2(hc->hc_access, ACCESS_STREAMING) &&
-      access_verify2(hc->hc_access, ACCESS_ADVANCED_STREAMING) &&
-      access_verify2(hc->hc_access, ACCESS_RECORDER)))
+     (access_verify2(hc->hc_access, ACCESS_OR |
+                                    ACCESS_STREAMING |
+                                    ACCESS_ADVANCED_STREAMING |
+                                    ACCESS_RECORDER)))
     return HTTP_STATUS_UNAUTHORIZED;
 
   pthread_mutex_lock(&global_lock);
@@ -1244,6 +1246,7 @@ page_imagecache(http_connection_t *hc, const char *remain, void *opaque)
                                     ACCESS_STREAMING |
                                     ACCESS_ADVANCED_STREAMING |
                                     ACCESS_HTSP_STREAMING |
+                                    ACCESS_HTSP_RECORDER |
                                     ACCESS_RECORDER)))
     return HTTP_STATUS_UNAUTHORIZED;