ACL: Add HTSP Recorder permission, fixes #2541

This commit is contained in:
Jaroslav Kysela 2014-12-12 12:01:21 +01:00
parent d6b59b9ee3
commit 5ec120c378
6 changed files with 43 additions and 22 deletions

View 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

View 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",

View 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 \

View 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]))

View 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 },

View 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;