silvanmelchior / RPi_Cam_Web_Interface

A web interface for the RPi Cam
MIT License
1.53k stars 492 forks source link

Have problem with start_vid.sh #633

Closed markxyx closed 3 years ago

markxyx commented 3 years ago

I add a line to start_vid.sh. I ran it in terminal with no problem. It created a audio.wav file in /var/www/media as what I asked it to do.

IMG_20210908_225322

When I use web interface to record a video. Nothing happened. I checked the log. It shows Raspimjpeg executed start_vid.sh. what did I missed?

mmexport1631099557343

roberttidey commented 3 years ago

For a macro script to execute successfully under the web interface it must satisfy three conditions.

  1. It must be executable. This is achieved using the chmod command. You must have already done this as you are executing it from a command line.

  2. It must be owned by user www-data. The web server runs as user www-data and anything executed by it must have the same owner. This is for security reasons as user www-data has limited privileges to stop nasty things being done. You make script owned by www-data by using the chown command e.g. chown www-data:www-data /var/www/macros/start_vid.sh

  3. Any processes actions within the script must be allowed for user www-data otherwise they will not successfully run. So user www-data may need to be explicitly given permission for run arecord. One way to achieve that is to add the process to the sudoers file /etc/sudoers.d/RPI_Cam_Web_Interface This already has entries to allow the web interface to run the shutdown and date commands. Use those as an example.

markxyx commented 3 years ago

You are legend. It works.