summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2020-05-07 10:45:41 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2020-05-07 10:45:41 +0200
commit35b936200f21fa96aef35ae6c98df512477360bc (patch)
tree04a2939bcd2128ab2b8dbc1166b8d3add6ff5d99
parente6c450b34695c499658581d9b655391346978c5d (diff)
downloadvdr-35b936200f21fa96aef35ae6c98df512477360bc.tar.gz
vdr-35b936200f21fa96aef35ae6c98df512477360bc.tar.bz2
Fixed dropping capabilities in case cap_sys_time is not available
-rw-r--r--HISTORY1
-rw-r--r--vdr.c18
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 <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;