Best practice to launch root script from cPanel plugin

a_guy

Registered
Mar 10, 2021
2
1
3
Romania
cPanel Access Level
DataCenter Provider
Howdy,

I'm writing a cPanel plugin that needs to trigger a script that runs as root (and a two parameters are sent to the script).

I don't want to run the whole plugin with escalated privileges for obvious reasons.
I'm not keen on adding the script to sudoers to always run as root either (though looks like a simple and ~secure way).

Ideally I would be able to define custom a hook and trigger the hook from the cPanel plugin and have a script that listens to hook on the other end.
I don't think I can define custom hooks, at least I didn't find this in docs.

Other ideas also cross my mind: use some file watcher based on inotify and trigger when the script when a file is created in any of the cPanel accounts.
Or some sort of dbus communication, maybe a queue, but RabbitMQ sounds like an overkill.
Some cron to check file created: old school and adds delay.

So, before reinventing the wheel, I thought I'd ask how are you folks doing this?
What would be a lite and secure way to launch script as root from regular cPanel user plugin?


Thanks
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,442
1,004
313
cPanel Access Level
Root Administrator
  • Like
Reactions: cPanelTJ