@cryptotaxi247 / netdata-1 / commits / 931b3e34e

report running uid and euid when not running properly

Costa Tsaousis (ktsaou) committed Jan 29, 2017 at 22:01 UTC 931b3e34eb80735da43264660fbbf7ef2cb828f3
2 files changed +13 -9
configs.signatures
+1
@@ -331,6 +331,7 @@ declare -A configs_signatures=(
331 ['d8dc489e32f7114c6298fce94e86a8ef']='health.d/entropy.conf'
332 ['d9036091e2232fc2b8bfa8c7484dea28']='apps_groups.conf'
333 ['d9258e671d0d0b6498af1ce16ef030d2']='apps_groups.conf'
334 + ['d9fa0290cdfe4153188bb52dd31191df']='apps_groups.conf'
335 ['da29d2ab1ab7b8fda189960c840e5144']='health.d/swap.conf'
336 ['dad303c5cca7a69345811a01a74f5892']='health.d/net.conf'
337 ['dc0d2b96378f290eec3fcf98b89ad824']='python.d/cpufreq.conf'
src/apps_plugin.c
+12 -9
@@ -3135,23 +3135,26 @@ int main(int argc, char **argv) {
3135
3136 parse_args(argc, argv);
3137
3138 - if(!am_i_running_as_root())
3139 - if(!check_capabilities())
3138 + if(!am_i_running_as_root()) {
3139 + if(!check_capabilities()) {
3140 + uid_t uid = getuid(), euid = geteuid();
3141 #ifdef HAVE_CAPABILITY
3141 - error("apps.plugin should either run as root or have special capabilities. "
3142 + error("apps.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
3143 "Without these, apps.plugin cannot report disk I/O utilization of other processes. "
3143 - "To enable capabilities run: sudo setcap cap_dac_read_search,cap_sys_ptrace+ep %1$s; "
3144 - "To enable setuid to root run: sudo chown root %1$s; sudo chmod 4755 %1$s; "
3145 - , argv[0]
3144 + "To enable capabilities run: sudo setcap cap_dac_read_search,cap_sys_ptrace+ep %s; "
3145 + "To enable setuid to root run: sudo chown root %s; sudo chmod 4755 %s; "
3146 + , uid, euid, argv[0], argv[0], argv[0]
3147 );
3148 #else
3148 - error("apps.plugin should either run as root or have special capabilities. "
3149 + error("apps.plugin should either run as root (now running with uid %u, euid %u) or have special capabilities. "
3150 "Without these, apps.plugin cannot report disk I/O utilization of other processes. "
3151 "Your system does not support capabilities. "
3151 - "To enable setuid to root run: sudo chown root %1$s; sudo chmod 4755 %1$s; "
3152 - , argv[0]
3152 + "To enable setuid to root run: sudo chown root %s; sudo chmod 4755 %s; "
3153 + , uid, euid, argv[0], argv[0]
3154 );
3155 #endif
3156 + }
3157 + }
3158
3159 all_pids_sortlist = callocz(sizeof(pid_t), (size_t)pid_max);
3160 all_pids = callocz(sizeof(struct pid_stat *), (size_t) pid_max);