Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ACL: Add possibility to not show the failed recordings, fixes #2569
  • Loading branch information
perexg committed May 20, 2015
1 parent 808fd47 commit ec3ba93
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 23 deletions.
4 changes: 4 additions & 0 deletions docs/html/config_access.html
Expand Up @@ -104,6 +104,10 @@
Enable to access to DVR entries created by other users with the ability to
remove the DVR entries.

<dt><b>Failed DVR</b>
<dd>
Enable to access to DVR entries which were not succesfuly recorded.

<dt><b>DVR Config Profile</b>
<dd>
If set, the user will only be able to use the DVR config profile
Expand Down
21 changes: 16 additions & 5 deletions src/access.c
Expand Up @@ -836,18 +836,20 @@ access_entry_update_rights(access_entry_t *ae)
r |= ACCESS_ADVANCED_STREAMING;
if (ae->ae_htsp_streaming)
r |= ACCESS_HTSP_STREAMING;
if (ae->ae_webui)
r |= ACCESS_WEB_INTERFACE;
if (ae->ae_dvr)
r |= ACCESS_RECORDER;
if (ae->ae_htsp_dvr)
r |= ACCESS_HTSP_RECORDER;
if (ae->ae_all_dvr)
r |= ACCESS_ALL_RECORDER;
if (ae->ae_webui)
r |= ACCESS_WEB_INTERFACE;
if (ae->ae_admin)
r |= ACCESS_ADMIN;
if (ae->ae_all_rw_dvr)
r |= ACCESS_ALL_RW_RECORDER;
if (ae->ae_failed_dvr)
r |= ACCESS_FAILED_RECORDER;
if (ae->ae_admin)
r |= ACCESS_ADMIN;
ae->ae_rights = r;
}

Expand Down Expand Up @@ -882,6 +884,7 @@ access_entry_create(const char *uuid, htsmsg_t *conf)
ae->ae_htsp_streaming = 1;
ae->ae_htsp_dvr = 1;
ae->ae_all_dvr = 1;
ae->ae_failed_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)
Expand Down Expand Up @@ -1343,6 +1346,13 @@ const idclass_t access_entry_class = {
.name = "All DVR (rw)",
.off = offsetof(access_entry_t, ae_all_rw_dvr),
},
{
.type = PT_BOOL,
.id = "failed_dvr",
.name = "Failed DVR",
.off = offsetof(access_entry_t, ae_failed_dvr),
.opts = PO_ADVANCED | PO_HIDDEN,
},
{
.type = PT_STR,
.id = "dvr_config",
Expand Down Expand Up @@ -1449,11 +1459,12 @@ access_init(int createdefault, int noacl)
ae->ae_streaming = 1;
ae->ae_adv_streaming = 1;
ae->ae_htsp_streaming = 1;
ae->ae_webui = 1;
ae->ae_dvr = 1;
ae->ae_htsp_dvr = 1;
ae->ae_all_dvr = 1;
ae->ae_all_rw_dvr = 1;
ae->ae_webui = 1;
ae->ae_failed_dvr = 1;
ae->ae_admin = 1;
access_entry_update_rights(ae);

Expand Down
9 changes: 6 additions & 3 deletions src/access.h
Expand Up @@ -68,6 +68,7 @@ typedef struct access_entry {
int ae_htsp_dvr;
int ae_all_dvr;
int ae_all_rw_dvr;
int ae_failed_dvr;
struct dvr_config *ae_dvr_config;
LIST_ENTRY(access_entry) ae_dvr_config_link;

Expand Down Expand Up @@ -122,15 +123,17 @@ typedef struct access_ticket {
#define ACCESS_RECORDER (1<<4)
#define ACCESS_HTSP_RECORDER (1<<5)
#define ACCESS_ALL_RECORDER (1<<6)
#define ACCESS_ADMIN (1<<7)
#define ACCESS_ALL_RW_RECORDER (1<<8)
#define ACCESS_ALL_RW_RECORDER (1<<7)
#define ACCESS_FAILED_RECORDER (1<<8)
#define ACCESS_ADMIN (1<<9)
#define ACCESS_OR (1<<30)

#define ACCESS_FULL \
(ACCESS_STREAMING | ACCESS_ADVANCED_STREAMING | \
ACCESS_HTSP_STREAMING | ACCESS_WEB_INTERFACE | \
ACCESS_RECORDER | ACCESS_HTSP_RECORDER | \
ACCESS_ALL_RECORDER | ACCESS_ADMIN | ACCESS_ALL_RW_RECORDER)
ACCESS_ALL_RECORDER | ACCESS_ALL_RW_RECORDER | \
ACCESS_FAILED_RECORDER | ACCESS_ADMIN)

/**
* Create a new ticket for the requested resource and generate a id for it
Expand Down
13 changes: 1 addition & 12 deletions src/dvr/dvr.h
Expand Up @@ -503,18 +503,7 @@ htsmsg_t *dvr_entry_class_pri_list(void *o);
htsmsg_t *dvr_entry_class_config_name_list(void *o);
htsmsg_t *dvr_entry_class_duration_list(void *o, const char *not_set, int max, int step);

static inline int dvr_entry_verify(dvr_entry_t *de, access_t *a, int readonly)
{
if (readonly && !access_verify2(a, ACCESS_ALL_RECORDER))
return 0;

if (!access_verify2(a, ACCESS_ALL_RW_RECORDER))
return 0;

if (strcmp(de->de_owner ?: "", a->aa_username ?: ""))
return -1;
return 0;
}
int dvr_entry_verify(dvr_entry_t *de, access_t *a, int readonly);

/**
*
Expand Down
22 changes: 22 additions & 0 deletions src/dvr/dvr_db.c
Expand Up @@ -47,6 +47,28 @@ static void dvr_timer_stop_recording(void *aux);
static int dvr_entry_class_disp_title_set(void *o, const void *v);
static int dvr_entry_class_disp_subtitle_set(void *o, const void *v);

/*
*
*/
int
dvr_entry_verify(dvr_entry_t *de, access_t *a, int readonly)
{
if (access_verify2(a, ACCESS_FAILED_RECORDER) &&
(de->de_sched_state == DVR_COMPLETED &&
de->de_last_error != SM_CODE_OK))
return -1;

if (readonly && !access_verify2(a, ACCESS_ALL_RECORDER))
return 0;

if (!access_verify2(a, ACCESS_ALL_RW_RECORDER))
return 0;

if (strcmp(de->de_owner ?: "", a->aa_username ?: ""))
return -1;
return 0;
}

/*
*
*/
Expand Down
2 changes: 1 addition & 1 deletion src/htsp_server.c
Expand Up @@ -1115,7 +1115,7 @@ htsp_method_async(htsp_connection_t *htsp, htsmsg_t *in)
/* Send all DVR entries */
LIST_FOREACH(de, &dvrentries, de_global_link)
if (!dvr_entry_verify(de, htsp->htsp_granted_access, 1) &&
htsp_user_access_channel(htsp,de->de_channel))
htsp_user_access_channel(htsp, de->de_channel))
htsp_send_message(htsp, htsp_build_dvrentry(de, "dvrEntryAdd"), NULL);

/* Send EPG updates */
Expand Down
11 changes: 9 additions & 2 deletions src/webui/static/app/acleditor.js
Expand Up @@ -10,6 +10,13 @@ tvheadend.acleditor = function(panel, index)
'profile,conn_limit,dvr,htsp_dvr,all_dvr,all_rw_dvr,' +
'dvr_config,channel_min,channel_max,channel_tag,comment';

var list2 = 'enabled,username,password,prefix,' +
'webui,admin,' +
'streaming,adv_streaming,htsp_streaming,' +
'profile,conn_limit,dvr,htsp_dvr,all_dvr,all_rw_dvr,' +
'failed_dvr,dvr_config,channel_min,channel_max,channel_tag,' +
'comment';

tvheadend.idnode_grid(panel, {
url: 'api/access/entry',
titleS: 'Access Entry',
Expand All @@ -36,13 +43,13 @@ tvheadend.acleditor = function(panel, index)
tabIndex: index,
edit: {
params: {
list: list
list: list2
}
},
add: {
url: 'api/access/entry',
params: {
list: list
list: list2
},
create: { }
},
Expand Down

0 comments on commit ec3ba93

Please sign in to comment.