I'm building a control panel in PHP. This CP will manage Linux users, their screen sessions and files.
I want to list all approaches and choose the most secure way which will be comfortable for user too.
/etc/sudoers
wwwuser ALL = NOPASSWD: ALL
This allows any command to be run via www server user. It's security nightmare.
/etc/sudoers
wwwuser ALL = NOPASSWD: /path/to/scripts/scripts/
This method uses small bash scripts with only few lines. Unfortunately those scripts must take arguments increasing attack surface. For example this script create new user
#/bin/bash useradd $1 -s /bin/bash
I can't list all allowed usernames so I must use args.
In this method all commands that need root rights, are sent to queue. Queue daemon runs as root so it can create users etc.