]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Allow restriction for one DVR configuration mapped to one user
authorJaroslav Kysela <perex@perex.cz>
Thu, 1 Mar 2012 16:37:07 +0000 (17:37 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 1 Mar 2012 16:55:24 +0000 (17:55 +0100)
In some use cases, it may be usefull to not allow selection of the
DVR configuration for the end-users. Map the DVR configuration by name
matching the username for these restricted users (DVR configuration must
be identical to the username, otherwise the default configuration is used).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/access.c
src/access.h
src/webui/extjs.c
src/webui/static/app/acleditor.js

index 080d6d8485281f6a5f0aa465c88abe53b963960d..f40c1ab37f3b727eec2fbdc432c0e3faaa8fa2fa 100644 (file)
@@ -391,6 +391,7 @@ access_record_build(access_entry_t *ae)
 
   htsmsg_add_u32(e, "streaming", ae->ae_rights & ACCESS_STREAMING     ? 1 : 0);
   htsmsg_add_u32(e, "dvr"      , ae->ae_rights & ACCESS_RECORDER      ? 1 : 0);
+  htsmsg_add_u32(e, "dvrallcfg", ae->ae_rights & ACCESS_RECORDER_ALL  ? 1 : 0);
   htsmsg_add_u32(e, "webui"    , ae->ae_rights & ACCESS_WEB_INTERFACE ? 1 : 0);
   htsmsg_add_u32(e, "admin"    , ae->ae_rights & ACCESS_ADMIN         ? 1 : 0);
 
@@ -480,6 +481,9 @@ access_record_update(void *opaque, const char *id, htsmsg_t *values,
   if(!htsmsg_get_u32(values, "dvr", &u32))
     access_update_flag(ae, ACCESS_RECORDER, u32);
 
+  if(!htsmsg_get_u32(values, "dvrallcfg", &u32))
+    access_update_flag(ae, ACCESS_RECORDER_ALL, u32);
+
   if(!htsmsg_get_u32(values, "admin", &u32))
     access_update_flag(ae, ACCESS_ADMIN, u32);
 
index 7af118e20874f6720a825b466b81956e4e98db18..37f42a08b5e8311b95942ab2806d6371d8079009 100644 (file)
@@ -58,7 +58,8 @@ typedef struct access_ticket {
 #define ACCESS_STREAMING       0x1
 #define ACCESS_WEB_INTERFACE   0x2
 #define ACCESS_RECORDER        0x4
-#define ACCESS_ADMIN           0x8
+#define ACCESS_RECORDER_ALL    0x8
+#define ACCESS_ADMIN           0x10
 #define ACCESS_FULL 0x3f
 
 /**
index 3ed9f8b442797c7cb9a5d4bd2603ddd414406865..b4677e22768fd8e92ed26d9498e55649b5c4b5f6 100644 (file)
@@ -624,6 +624,9 @@ extjs_confignames(http_connection_t *hc, const char *remain, void *opaque)
     out = htsmsg_create_map();
     array = htsmsg_create_list();
 
+    if (http_access_verify(hc, ACCESS_RECORDER_ALL))
+      goto skip;
+
     LIST_FOREACH(cfg, &dvrconfigs, config_link) {
       e = htsmsg_create_map();
       htsmsg_add_str(e, "identifier", cfg->dvr_config_name);
@@ -634,6 +637,7 @@ extjs_confignames(http_connection_t *hc, const char *remain, void *opaque)
       htsmsg_add_msg(array, NULL, e);
     }
 
+skip:
     htsmsg_add_msg(out, "entries", array);
 
   } else {
@@ -787,6 +791,18 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
       return HTTP_STATUS_BAD_REQUEST;
     }
 
+    if (http_access_verify(hc, ACCESS_RECORDER_ALL)) {
+      config_name = NULL;
+      LIST_FOREACH(cfg, &dvrconfigs, config_link) {
+        if (strcmp(cfg->dvr_config_name, hc->hc_username) == 0) {
+          config_name = cfg->dvr_config_name;
+          break;
+        }
+      }
+      if (config_name == NULL)
+        tvhlog(LOG_INFO,"dvr","User '%s' has no dvr config with identical name, using default...", hc->hc_username);
+    }
+
     dvr_entry_create_by_event(config_name,
                               e, hc->hc_representative, NULL, DVR_PRIO_NORMAL);
 
@@ -857,6 +873,18 @@ extjs_dvr(http_connection_t *hc, const char *remain, void *opaque)
     if(stop < start)
       stop += 86400;
 
+    if (http_access_verify(hc, ACCESS_RECORDER_ALL)) {
+      config_name = NULL;
+      LIST_FOREACH(cfg, &dvrconfigs, config_link) {
+        if (strcmp(cfg->dvr_config_name, hc->hc_username) == 0) {
+          config_name = cfg->dvr_config_name;
+          break;
+        }
+      }
+      if (config_name == NULL)
+        tvhlog(LOG_INFO,"dvr","User '%s' has no dvr config with identical name, using default...", hc->hc_username);
+    }
+
     dvr_entry_create(config_name,
                      ch, start, stop, title, NULL, hc->hc_representative, 
                     NULL, NULL, 0, dvr_pri2val(pri));
index d9864d837120d2ecc632d38ccfef77ebd1771dcf..eaeddbf49f92ba30a23596e49af560082e1c45a3 100644 (file)
@@ -20,6 +20,12 @@ tvheadend.acleditor = function() {
        width: 100
     });
 
+    var dvrallcfgColumn = new Ext.grid.CheckColumn({
+       header: "All Configs (VR)",
+       dataIndex: 'dvrallcfg',
+       width: 100
+    });
+
     var webuiColumn = new Ext.grid.CheckColumn({
        header: "Web Interface",
        dataIndex: 'webui',
@@ -52,6 +58,7 @@ tvheadend.acleditor = function() {
        },
        streamingColumn,
        dvrColumn,
+       dvrallcfgColumn,
        webuiColumn,
        adminColumn,
        {
@@ -63,14 +70,14 @@ tvheadend.acleditor = function() {
     ]);
     
     var UserRecord = Ext.data.Record.create([
-       'enabled','streaming','dvr','admin','webui','username',
+       'enabled','streaming','dvr','dvrallcfg','admin','webui','username',
        'prefix','password','comment'
     ]);
 
     return new tvheadend.tableEditor('Access control', 'accesscontrol', cm,
                                     UserRecord,
                                     [enabledColumn, streamingColumn,
-                                     dvrColumn, webuiColumn,
+                                     dvrColumn, dvrallcfgColumn, webuiColumn,
                                      adminColumn],
                                     null,
                                     'config_access.html', 'group');