Sudo command runs in rails console but not from web
I'm trying to execute a command to add a user to the local machine using useradd from a controller. In rails console, system 'sudo useradd -b /home username' runs fine, but not from the controller. The only response is false. I've tried using backticks, but get no output.
How can I get this 开发者_StackOverflow中文版to work? Is there a flag that I'm missing?
The user that the web app runs under must have sudo access.
That being said, unless you're developing an internal server management app that is absolutely not accessible from the outside, what you're describing sounds really dangerous (creating a user, with security rights to your system, from a web app).
Even if it is an internal app, I hope it's locked down and only accessible to proper admins. :)
精彩评论