Plugins requiring sudo

Some commands require sudo privileges to run. The agent runs under the user sd-agent which is a regular, unprivileged user which means you need to specifically run commands in your plugin code using sudo.

This can be done using something like subprocess in Python (note: lsof is used as an example so you should replace with the relevant command):

Popen(['sudo', 'lsof', 'arg1', 'arg2'])

You also need to modify the /etc/sudoers (using visudo) file to allow the agent to run this command:

sd-agent ALL=(ALL) NOPASSWD: /usr/sbin/lsof

And finally comment out this line in the sudoers file because the agent does not run with a TTY:

#Defaults    requiretty

Official Plugins Requiring sudo

Entropy:

Our official entropy plugin requires sudo to function. Here's an example for your sudoers file: 

sd-agent ALL=(ALL) NOPASSWD: /bin/cat /proc/sys/kernel/random/entropy_avail 

Postfix:

Our official postfix plugin requires sudo to function. Here's an example for your sudoers file: 

sd-agent ALL=(ALL) NOPASSWD: /usr/bin/find 
Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.