From 35b936200f21fa96aef35ae6c98df512477360bc Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Thu, 7 May 2020 10:45:41 +0200 Subject: Fixed dropping capabilities in case cap_sys_time is not available --- HISTORY | 1 + vdr.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/HISTORY b/HISTORY index b05d449b..642ea258 100644 --- a/HISTORY +++ b/HISTORY @@ -9430,3 +9430,4 @@ Video Disk Recorder Revision History in SCR systems, and Helmut Binder for helping with the implementation). - Fixed compatibility with current versions of glibc (thanks to Manuel Reimer). - The SVDRP command DELC now also accepts a channel id (suggested by Manuel Reimer). +- Fixed dropping capabilities in case cap_sys_time is not available. diff --git a/vdr.c b/vdr.c index 1f2e7ef8..0002214e 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.tvdr.de * - * $Id: vdr.c 4.30 2019/05/23 09:48:35 kls Exp $ + * $Id: vdr.c 4.31 2020/05/07 10:45:41 kls Exp $ */ #include @@ -131,20 +131,18 @@ static bool DropCaps(void) fprintf(stderr, "vdr: cap_get_proc failed: %s\n", strerror(errno)); return false; } - char *caps_text = cap_to_text(caps_all, NULL); - if (!caps_text) { - fprintf(stderr, "vdr: cap_to_text failed: %s\n", strerror(errno)); - return false; - } - if (cap_free(caps_all)) { - fprintf(stderr, "vdr: cap_free failed: %s\n", strerror(errno)); + cap_flag_value_t cap_flag_value; + if (cap_get_flag(caps_all, CAP_SYS_TIME, CAP_PERMITTED , &cap_flag_value)) { + fprintf(stderr, "vdr: cap_get_flag failed: %s\n", strerror(errno)); return false; } cap_t caps; - if (strstr(caps_text,"cap_sys_time")) + if (cap_flag_value == CAP_SET) caps = cap_from_text("= cap_sys_nice,cap_sys_time,cap_net_raw=ep"); - else + else { + fprintf(stdout,"vdr: OS does not support cap_sys_time\n"); caps = cap_from_text("= cap_sys_nice,cap_net_raw=ep"); + } if (!caps) { fprintf(stderr, "vdr: cap_from_text failed: %s\n", strerror(errno)); return false; -- cgit v1.2.3