Bonjour, mon serveur apache tourne sous l'utilisateur nobody et j'ai créé un script bash permettant d'ajouter un utilisateur au système.

nobody n'ayant pas les droits pour exécuter la commande useradd, j'ai utilisé la commandu sudo dans mon script et modifier le fichier /etc/sudoers :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
 
# Host alias specification
 
# User alias specification
 
# Cmnd alias specification
 
# Defaults specification
 
# Runas alias specification
 
# User privilege specification
root	ALL=(ALL) ALL
 
# Uncomment to allow people in group wheel to run all commands
# %wheel	ALL=(ALL)	ALL
 
# Same thing without a password
# %wheel	ALL=(ALL)	NOPASSWD: ALL
 
# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now
 
nobody localhost = NOPASSWD: /usr/sbin/useradd, /usr/sbin/usermod, /usr/sbin/userdel, /usr/sbin/groupadd, /usr/sbin/groupmod, /usr/sbin/groupdel
mais lorsque j'éxécute le script ou la commande sudo j'obtient l'erreur suivante :

Erreur dans les logs apache :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] >>> sudoers file: syntax error, line 30 <<<, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] sudo: , referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] parse error in /etc/sudoers near line 30, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] , referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] sendmail: warning: My hostname localhost is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] /usr/local/apache/2.0.54/cgi-bin/uncgid/ajout_ut.sh: line 12: plop: command not found, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] >>> sudoers file: syntax error, line 30 <<<, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] sudo: , referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] parse error in /etc/sudoers near line 30, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] , referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] sendmail: warning: My hostname localhost is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] postdrop: warning: My hostname localhost is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf, referer: http://127.0.0.1/
[Thu Oct 13 11:17:23 2005] [error] [client 127.0.0.1] postdrop: warning: My hostname localhost is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf, referer: http://127.0.0.1/
Erreur en lancant sudo:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
[[root@localhost uncgid]# sudo
>>> sudoers file: syntax error, line 32 <<<
sudo: parse error in /etc/sudoers near line 32
sendmail: warning: My hostname localhost is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf
postdrop: warning: My hostname localhost is not a fully qualified name - set myhostname or mydomain in /etc/postfix/main.cf
Si quelqu'un peut m'éclairer car je ne vois pas le problème.

Pour info voila le script bahs exécuté par apache :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash
 
user=$WWW_user;
nom_complet=$WWW_nom;
pwd=$WWW_pwd;
shell=$WWW_shell;
 
echo "Content-type : text/html; charset = iso-8859-1";
echo;
 
sudo useradd -m -c "$nom_complet" -s "$shell" -r "$user";
$pwd | sudo passwd --stdin $user;
Merci d'avance