0

I wrote a small bash script that collects a crash report (some logs from /var/log and a couple of files from /etc) and the way I want this to work is through NGINX CGI.

Using a link, NGINX will trigger the script, collect all those files, and start a download once done.

My problem right now is with permissions. I can collect some parts of the files but not all of them (dmesg, syslog, etc.)

  • 4
    Can't you have the script run periodically (with cron) independently of nginx and let it collect/update the needed data in a location accessible to the web server. Having the webserver execute anything with root permissions sounds horribly insecure... – Kusalananda Sep 18 '17 at 11:09
  • i agree and that has been bothering me, but having it running with cron won't work, say cron runs the job every 1 min and just after it runs it something nasty happens and i grab the crash report it'll contain nothing useful about the issue that occurred. – TheBrash Sep 18 '17 at 11:35
0

Depending on your distribution, the logs in /var/log possibly have group read permission set for group adm.

You could add the user nginx is running as to the adm group to allow your CGI script to read those files. This way you do not need full root permissions for your script to read these logs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.