Ad Widget

Collapse

zbbix_agentd doesn't want to run as root, no matter what I try

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BPMb
    Junior Member
    • May 2019
    • 4

    #1

    zbbix_agentd doesn't want to run as root, no matter what I try

    I have zabbix_agentd running on Centos 8 and I have a UserParameter that checks the health of the ZFS pool. This always worked fine because the previous version of the agent I was using ran as root user so was allowed to run the zpool command. I noticed this is no longer the case.

    I checked the docs and found this one: https://www.zabbix.com/documentation..._agent_as_root

    I followed that guide but still the agent is run as user zabbix instead of root. I tried several things, first off, my configuration;

    Location systemctl script: /usr/lib/systemd/system/zabbix-agent.service
    Contents of that script:
    Code:
    [Unit]
    Description=Zabbix Agent
    After=syslog.target
    After=network.target
    
    [Service]
    Environment="CONFFILE=/etc/zabbix/zabbix_agentd.conf"
    EnvironmentFile=-/etc/sysconfig/zabbix-agent
    Type=forking
    Restart=on-failure
    PIDFile=/run/zabbix/zabbix_agentd.pid
    KillMode=control-group
    ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE
    ExecStop=/bin/kill -SIGTERM $MAINPID
    RestartSec=10s
    
    [Install]
    WantedBy=multi-user.target
    As you can see I edited this one and changed User=zabbix and Groups=zabbix to root, doesn't work..

    I tried adding the override.conf file both in /etc/systemd/system/zabbix-agent.service.d as well as /usr/lib/systemd/system/zabbix-agent.service.d but no dice, still running as user zabbix.

    I also tried putting the systemctl scripts in /etc/systemd/system/zabbix-agent.service.d and it launches fine, but still as user zabbix..

    I also added AllowRoot=1 to /etc/zabbix/zabbix_agentd.conf but still nothing..

    I can't figure out why this is happening and I'm hoping someone can point me in the right direction..

    UPDATE: I used the systemctl script above together with AllowRoot=1 in the conf file on Ubuntu 20 and that worked immediately? Something in CentOS maybe?

    Thanks!
    Last edited by BPMb; 26-08-2020, 21:33.
  • BPMb
    Junior Member
    • May 2019
    • 4

    #2
    SOLVED! Made a rookie mistake I'm afraid, SELinux was still enabled.. Disabled it and then it worked!

    Comment

    • isaqueprofeta
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Aug 2020
      • 154

      #3
      Just a piece of advice: Are you really sure you need to run it's as root? Try tweaking with permissions and/or setfacl, it's more secure.

      Comment

      • tim.mooney
        Senior Member
        • Dec 2012
        • 1427

        #4
        Originally posted by isaqueprofeta
        Just a piece of advice: Are you really sure you need to run it's as root? Try tweaking with permissions and/or setfacl, it's more secure.
        I totally agree. Only if there's no other workaround would I even consider running the client as root.

        In this case, since BPMb is already using a UserParameter, just add 'sudo' to the parameter and add a rule to the /etc/sudoers.d/zabbix.conf to allow the zabbix user to run the zfs command(s) as root with NOPASSWD.

        Comment

        Working...