]> arthur.barton.de Git - netdata.git/commitdiff
check that apps.plugin runs before trusting setcap
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Fri, 30 Dec 2016 03:54:38 +0000 (05:54 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Fri, 30 Dec 2016 03:54:38 +0000 (05:54 +0200)
netdata-installer.sh
src/apps_plugin.c

index ac19452b36cd04403b4dfb2fecf4e34c1acd7f43..95732e9a35af980acc23726d1a68c06a82ee299c 100755 (executable)
@@ -839,6 +839,15 @@ if [ ${UID} -eq 0 ]
         then
         run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
         setcap_ret=$?
+
+        if [ ${setcap_ret} -eq 0 ]
+            then
+            # if we managed to setcap
+            # but we fail to execute apps.plugin
+            # trigger setuid to root
+            "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" -v >/dev/null 2>&1
+            setcap_ret=$?
+        fi
     fi
 
     if [ ${setcap_ret} -ne 0 ]
index 51cedaff8589f51dd668d7b8c819c5e36c34daff..7d5c325e34edc052b5ca91d2b789232816634cc0 100644 (file)
@@ -2680,6 +2680,11 @@ static void parse_args(int argc, char **argv)
             }
         }
 
+        if(strcmp("version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
+            printf("apps.plugin %s\n", VERSION);
+            exit(0);
+        }
+
         if(strcmp("debug", argv[i]) == 0) {
             debug = 1;
             // debug_flags = 0xffffffff;
@@ -2728,7 +2733,7 @@ static void parse_args(int argc, char **argv)
 
         if(strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
             fprintf(stderr,
-                    "apps.plugin\n"
+                    "apps.plugin %s\n"
                     "(C) 2016 Costa Tsaousis"
                     "GPL v3+\n"
                     "This program is a data collector plugin for netdata.\n"
@@ -2755,6 +2760,10 @@ static void parse_args(int argc, char **argv)
                     "NAME              read apps_NAME.conf instead of\n"
                     "                  apps_groups.conf\n"
                     "                  (default NAME=groups)\n"
+                    "\n"
+                    "version           print program version and exit\n"
+                    "\n"
+                    , VERSION
             );
             exit(1);
         }