Sh: ffmpeg: Permission denied

Bonjour,

J’ai un serveur Debian Linux 6.0 et j’utilise Webmin 1.580.
J’ai fait un script perl pour convertir des vidéos avec ffmpeg et j’ai configuré une tâche CRON sous Webmin qui s’execute toutes les minutes (utilisateur “root” et commande “perl /var/www/mon-site/cgi-bin/mon-script.pl”)
Le script fonctionne très bien lorsque je l’exécute manuellement depuis webmin ou en ligne de commande (avec le même utilisateur: root) et j’obtiens bien mes vidéos converties.
Par contre il plante s’il est lancé automatiquement avec la tâche CRON et j’ai le message d’erreur suivant :

“sh: ffmpeg: Permission denied”

Le message d’erreur semble indiquer que c’est un pb de droit d’exécution mais mon script perl et ffmpeg ont tous les droits (chmod 777).
Et dans ce cas pourquoi pour le même utilisateur cela fonctionne sauf quand le script est lancé avec CRON…?
Serais ce un pb lié à ma configuration apache ?

Si quelqu’un a une idée d’où peut venir le pb, je lui serais très reconnaissant de me guider vers une solution !
Merci pour votre aide.

Salut,

Tu peux montrer ton fichier cron, ça ne peut venir que de lui d’après les symptômes.

Salut,

Voilà le résultat de “crontab -l” :

          • perl /var/www/mon-site/cgi-bin/test-ffmpeg.pl

Voilà le contenu du fichier “/etc/crontab” :

/etc/crontab: system-wide crontab

Unlike any other crontab you don’t have to run the `crontab’

command to install the new version when you edit this file

and files in /etc/cron.d. These files also have username fields,

that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

m h dom mon dow user command

17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )

Est ce qu’il y a autre chose que tu veux voir ?

Salut,

Éventuellement le contenu du script.
et

vdir /var/www/mon-site/ vdir /var/www/mon-site/cgi-bin/

Voilà le contenu du script (script de test pour résoudre ce pb) :

use warnings;
use strict;
use DBI;
use POSIX;
my $dateLog = (strftime “%A %d-%m-%y %H:%M:%S”, localtime)." | ";
open(LOG, “>>/var/www/mon-site/logs/test-ffmpeg.log”) || die “Ouverture log KO”;
print LOG $dateLog.“Test ffmpeg\n”;
system “ffmpeg 2> /var/www/mon-site/logs/test-ffmpeg.log”;
print LOG $dateLog.“Test ffmpeg terminé\n”;

Voilà le résultat de “vdir /var/www/mon-site/” :

drwxrwxrwx 2 root root 4096 26 mai 10:19 cgi-bin
drwxrwxrwx 2 root root 4096 29 mai 09:06 composants
drwxrwxrwx 2 root root 4096 16 avril 12:42 css
drwxrwxrwx 2 root root 4096 21 mai 09:05 flowplayer
drwxrwxrwx 4 root root 4096 30 mai 08:37 img
-rwxrwxrwx 1 root root 5429 30 mai 11:50 index.php
drwxrwxrwx 2 root root 4096 21 mai 09:05 js
drwxrwxrwx 3 root root 4096 26 mai 10:05 logs
drwxrwxrwx 2 root root 4096 29 mai 16:19 miniatures
drwxrwxrwx 2 root root 4096 30 mai 11:40 page
drwxrwxrwx 2 root root 4096 17 avril 08:20 photos
-rw-r–r-- 1 root root 26 19 avril 14:35 robot.txt
drwxrwxrwx 2 root root 4096 16 avril 12:44 traitements
drwxrwxrwx 2 root root 4096 31 mai 16:38 uploads
drwxrwxrwx 3 root root 4096 29 mai 16:19 videos

Et voilà le résultat de “vdir /var/www/mon-site/cgi-bin/” :

-rwxrwxrwx 1 root root 1078 2 juin 05:57 test-ffmpeg.pl

Salut,
Tel quel ça fonctionne chez moi (j’ai un peu réduit les droits tout de même…)

vdir /var/www/mon-site/cgi-bin/ total 4 -rwxr-xr-x 1 www-data www-data 350 juin 2 09:16 test-ffmpeg.pl

Je me demande si ce n’est pas au niveau de le conf de apache que ça coince…

AddHandler cgi-script .cgi .pl Options +ExecCGI

Voilà ce que j’ai mis dans la config du VirtualHost (fichier /etc/apache2/sites-available/default) :

... ScriptAlias /cgi-bin/ /var/www/mon-site/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ...