1

I was wondering it is safe or an acceptable practice to use sudo to run an application from another one. For example, Let's say I have an application that uses a configuration file to do its work and, somewhere in that file exists the following line (in this case, I'd like to create a DB):

/usr/bin/sudo -u postgres /usr/bin/psql < /home/userX/create.sql

is this acceptable in a sys admin perspective?

1 Answer 1

1

Yes, that's perfectly fine. A lot of common utilities do that. You should however have some fallback in case the application does not get sudo - but that's just good script writing.

Another way to do things like these, that I do not recommend, is to ask the user to run the application as root, which is bad. So this alternative is better. Also make sure that if the script takes some user input, that the user input is properly santizied.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .