Bug 235006 - net-mgmt/netdata run as user not recognized in the config file
Summary: net-mgmt/netdata run as user not recognized in the config file
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Matthias Andree
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-16 19:42 UTC by Dries Michiels
Modified: 2020-04-03 12:05 UTC (History)
1 user (show)

See Also:
mmokhi: maintainer-feedback+


Attachments
netdata rc script overhaul checks user name consistency and kills zombie slaves (2.46 KB, patch)
2020-04-01 16:35 UTC, Matthias Andree
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dries Michiels 2019-01-16 19:42:34 UTC
When specifying the following option in the netdata config file:

[global]
        run as user = root

The daemon wont actually run as root. It needs to be set in rc.conf as netdata_user="root".

Is there a way to support setting this from the config file?
Comment 1 Dries Michiels 2019-01-20 11:06:46 UTC
As a side solution, if we could make it possible to alter the PID file location from a variable in rc.conf, this would already be a nice addition. 

: ${netdata_enable="NO"}
: ${netdata_user="netdata"}
: ${netdata_pid="/var/db/netdata/${name}.pid"}

pidfile = ${netdata_pid}
Comment 2 Mahdi Mokhtari freebsd_committer freebsd_triage 2019-04-06 11:48:40 UTC
I assume it's already landed in ports r496470
If so please tell me so I can close it.

Thanks.
Comment 3 Dries Michiels 2019-04-06 12:04:44 UTC
Hi, this issue is still relevant. Although I'm not sure how we can fix this.
Because the rc script uses daemon and does not probe for the "run as user" in "netdata.conf". If you want to run netdata as another user you have to set the netdata_user variable in rc.conf atm.
Comment 4 Matthias Andree freebsd_committer 2020-04-01 16:35:34 UTC
Created attachment 212936 [details]
netdata rc script overhaul checks user name consistency and kills zombie slaves

Please test if the attached improvement to the rcfile addresses the issues.
Comment 5 Dries Michiels 2020-04-03 11:14:10 UTC
Hi, I just tested this but I was a bit surprised, so when we set "run as user = root" in netdata.conf and set netdata_user="root" in rc.conf it works. But I would expect that only setting "run as user = root" in netdata.conf would be sufficient, but that now fails with:

"/usr/local/etc/rc.d/netdata: ERROR: /usr/local/etc/netdata/netdata.conf sets 'run as user = root', but rc.conf* sets 'netdata]'. Both must be consistent.
/usr/local/etc/rc.d/netdata: WARNING: failed precmd routine for netdata"

So my question is; was this the intend? The user still has to modify rc.conf anyway? Or can we extract the user from netdata.conf and use it for as netdata_user in the rc script unconditionally? It should only throw an error when both are explicitly set and do not match (eg, rc.conf = root, netdata.conf = netdata, or the other way around), but setting either one should be fine I think?

PS: Thanks for doing this! The "run as user" is extracted correctly with SED.
Comment 6 Dries Michiels 2020-04-03 11:15:43 UTC
Oops, it seems that it does not work when both are set to root.

/usr/local/etc/rc.d/netdata: ERROR: /usr/local/etc/netdata/netdata.conf sets 'run as user = root', but rc.conf* sets 'root]'. Both must be consistent.
/usr/local/etc/rc.d/netdata: WARNING: failed precmd routine for netdata

My entries: 
rc.conf:
netdata_user="root"

netdata.conf:
run as user = root
Comment 7 Matthias Andree freebsd_committer 2020-04-03 12:05:35 UTC
Hi Dries,

thanks for testing this, I will rework and test this based on your comments, sorry it doesn't work as intended. I will upload a new version later.