diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2020-05-07 10:45:41 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2020-05-07 10:45:41 +0200 |
commit | 35b936200f21fa96aef35ae6c98df512477360bc (patch) | |
tree | 04a2939bcd2128ab2b8dbc1166b8d3add6ff5d99 /vdr.c | |
parent | e6c450b34695c499658581d9b655391346978c5d (diff) | |
download | vdr-35b936200f21fa96aef35ae6c98df512477360bc.tar.gz vdr-35b936200f21fa96aef35ae6c98df512477360bc.tar.bz2 |
Fixed dropping capabilities in case cap_sys_time is not available
Diffstat (limited to 'vdr.c')
-rw-r--r-- | vdr.c | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -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 <getopt.h> @@ -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; |