Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #69 from perexg/fixes-dvrallcfg

Allow restriction for one DVR configuration mapped to one user
  • Loading branch information...
commit 7604e830477af7fa47aecb9f3cc2e2284bbd23fe 2 parents 7dcf7d1 + 6097dcd
@andoma andoma authored
View
4 src/access.c
@@ -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);
View
3  src/access.h
@@ -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
/**
View
30 src/webui/extjs.c
@@ -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,19 @@ 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 (cfg->dvr_config_name && hc->hc_username &&
+ strcmp(cfg->dvr_config_name, hc->hc_username) == 0) {
+ config_name = cfg->dvr_config_name;
+ break;
+ }
+ }
+ if (config_name == NULL && hc->hc_username)
+ 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 +874,19 @@ 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 (cfg->dvr_config_name && hc->hc_username &&
+ strcmp(cfg->dvr_config_name, hc->hc_username) == 0) {
+ config_name = cfg->dvr_config_name;
+ break;
+ }
+ }
+ if (config_name == NULL && hc->hc_username)
+ 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));
View
11 src/webui/static/app/acleditor.js
@@ -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');
Please sign in to comment.
Something went wrong with that request. Please try again.