From 5ec120c37863665c45366416fc4bce3e9c0065e8 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Fri, 12 Dec 2014 12:01:21 +0100 Subject: [PATCH] ACL: Add HTSP Recorder permission, fixes #2541 --- docs/html/config_access.html | 4 ++++ src/access.c | 13 ++++++++++++- src/access.h | 4 +++- src/htsp_server.c | 26 +++++++++++++------------- src/webui/static/app/acleditor.js | 3 ++- src/webui/webui.c | 15 +++++++++------ 6 files changed, 43 insertions(+), 22 deletions(-) diff --git a/docs/html/config_access.html b/docs/html/config_access.html index 392439f5..e62900b7 100644 --- a/docs/html/config_access.html +++ b/docs/html/config_access.html @@ -89,6 +89,10 @@ The columns have the following functions:
Enables access to all video recording functions. This also include administration of the auto recordings. +
HTSP DVR +
+ Enables access to video recording functions for the HTSP protocol (Showtime, XBMC etc.). +
DVR Config Profile
If set, the user will only be able to use the DVR config profile diff --git a/src/access.c b/src/access.c index 93b12004..dde6415e 100644 --- a/src/access.c +++ b/src/access.c @@ -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 ?: "", a->aa_username ?: "", 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", diff --git a/src/access.h b/src/access.h index 84cb05db..58567624 100644 --- a/src/access.h +++ b/src/access.h @@ -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 \ diff --git a/src/htsp_server.c b/src/htsp_server.c index d7b2e0e9..1d0569e7 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -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])) diff --git a/src/webui/static/app/acleditor.js b/src/webui/static/app/acleditor.js index 0f9c33fb..97ca4299 100644 --- a/src/webui/static/app/acleditor.js +++ b/src/webui/static/app/acleditor.js @@ -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 }, diff --git a/src/webui/webui.c b/src/webui/webui.c index d58f0d7c..98e4f1c9 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -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;