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.sqlis this acceptable in a sys admin perspective?
Use sudo from another programm
security;sudo
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.