Précédent   Forum des professionnels en informatique > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 30/12/2010, 11h35   #1
Nouveau Membre du Club
 
Inscription : juin 2004
Messages : 137
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 137
Points : 36
Points : 36
Par défaut Problème avec la commande exec et netstat

Sur un de mes serveur Debian lenny je souhaite exécuter un script php donc voici un extrait :

Code :
1
2
3
4
5
$resultat = exec('netstat -natpu', $lines);
 foreach($lines as $line){
        $output.=$line;
        echo $line .'<br />' ;
    }
et comme résultat je reçoit le message suivant:

Code :
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
32
33
34
35
36
37
38
39
40
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:41895 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:620 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:465 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN -
tcp 0 0 86.65.xxx.xxx:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN -
tcp 0 0 86.65.xxx.xxx:22 82.125.xxx.xxx:49857 ESTABLISHED -
tcp 0 0 127.0.0.1:57843 127.0.0.1:3306 TIME_WAIT -
tcp 0 0 86.65.xxx.xxx:22 82.125.xxx.xxx:50483 ESTABLISHED -
tcp 0 0 86.65.xxx.xxx:22 82.125.xxx.xxx:50082 ESTABLISHED -
tcp6 0 0 :::993 :::* LISTEN -
tcp6 0 0 :::995 :::* LISTEN -
tcp6 0 0 :::110 :::* LISTEN -
tcp6 0 0 :::143 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN 26240/netstat
tcp6 0 0 :::53 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:953 :::* LISTEN -
tcp6 0 0 :::443 :::* LISTEN 26240/netstat
tcp6 0 0 86.65.xxx.xxx:80 82.125.xxx.xxx:50525 ESTABLISHED 26240/netstat
udp 0 0 127.0.0.1:921 0.0.0.0:* -
udp 0 0 86.65.xxx.xxx:53 0.0.0.0:* -
udp 0 0 127.0.0.1:53 0.0.0.0:* -
udp 0 0 0.0.0.0:60488 0.0.0.0:* -
udp 0 0 0.0.0.0:717 0.0.0.0:* -
udp 0 0 0.0.0.0:111 0.0.0.0:* -
udp 0 0 86.65.xxx.xxx:123 0.0.0.0:* -
udp 0 0 127.0.0.1:123 0.0.0.0:* -
udp 0 0 0.0.0.0:123 0.0.0.0:* -
udp6 0 0 :::53 :::* -
udp6 0 0 fe80::20f:b5ff:feaa:123 :::* -
udp6 0 0 ::1:123 :::* -
udp6 0 0 :::123 :::* -
Par contre quand je passe par le terminal de mon serveur linux
en executant la commande
je reçoit ses informations:

Code :
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
32
33
34
35
36
37
38
39
40
Connexions Internet actives (serveurs et établies)
Proto Recv-Q Send-Q Adresse locale          Adresse distante        Etat        PID/Program name
tcp        0      0 0.0.0.0:41895           0.0.0.0:*               LISTEN      1813/rpc.statd
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      2225/mysqld
tcp        0      0 127.0.0.1:620           0.0.0.0:*               LISTEN      2564/famd
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1802/portmap
tcp        0      0 0.0.0.0:465             0.0.0.0:*               LISTEN      2425/master
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      14716/inetd
tcp        0      0 86.65.xxx.xxx:53        0.0.0.0:*               LISTEN      2113/named
tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      2113/named
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2148/sshd
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      2425/master
tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      2113/named
tcp        0      0 86.65.xxx.xxx:22        82.125.xxx.xxx:49857    ESTABLISHED 26026/sshd: cabinet
tcp        0      0 86.65.xxx.xxx:22        82.125.xxx.xxx:50483    ESTABLISHED 26187/sshd: cabinet
tcp        0    300 86.65.xxx.xxx:22        82.125.xxx.xxx:50543    ESTABLISHED 26247/0
tcp        0      0 86.65.xxx.xxx:22        82.125.xxx.xxx:50082    ESTABLISHED 26084/sshd: cabinet
tcp6       0      0 :::993                  :::*                    LISTEN      2316/couriertcpd
tcp6       0      0 :::995                  :::*                    LISTEN      2334/couriertcpd
tcp6       0      0 :::110                  :::*                    LISTEN      2322/couriertcpd
tcp6       0      0 :::143                  :::*                    LISTEN      2304/couriertcpd
tcp6       0      0 :::80                   :::*                    LISTEN      2716/apache2
tcp6       0      0 :::53                   :::*                    LISTEN      2113/named
tcp6       0      0 :::22                   :::*                    LISTEN      2148/sshd
tcp6       0      0 ::1:953                 :::*                    LISTEN      2113/named
tcp6       0      0 :::443                  :::*                    LISTEN      2716/apache2
udp        0      0 127.0.0.1:921           0.0.0.0:*                           2131/lwresd
udp        0      0 86.65.xxx.xxx:53        0.0.0.0:*                           2113/named
udp        0      0 127.0.0.1:53            0.0.0.0:*                           2113/named
udp        0      0 0.0.0.0:60488           0.0.0.0:*                           1813/rpc.statd
udp        0      0 0.0.0.0:717             0.0.0.0:*                           1813/rpc.statd
udp        0      0 0.0.0.0:111             0.0.0.0:*                           1802/portmap
udp        0      0 86.65.xxx.xxx:123       0.0.0.0:*                           2583/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           2583/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           2583/ntpd
udp6       0      0 :::53                   :::*                                2113/named
udp6       0      0 fe80::20f:b5ff:feaa:123 :::*                                2583/ntpd
udp6       0      0 ::1:123                 :::*                                2583/ntpd
udp6       0      0 :::123                  :::*                                2583/ntpd
root@debian:~#
En exécutant le script php je ne reçoit pas les informations de la colonne PID/Program name!
Quelqu'un à une idée pourquoi les commandes exec et netstat me livrent des informations incomplètes quand celles-ci sont exécuté avec le code php?

J'ai l'impression que tous les informations qui dépassent les 80 caractères/ligne sont ignoré ... c'est le cas de de la colonne PID/Program name.

Merci d'avance pour votre aide.
Didier100 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/12/2010, 11h47   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
Je penserais a un problème de droits.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/12/2010, 12h31   #3
Nouveau Membre du Club
 
Inscription : juin 2004
Messages : 137
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 137
Points : 36
Points : 36
Sabotage, Merci pour la réponse rapide ...

J'ai change temporairement les droits du fichier en 777 puis attribue le fichier à root .... cela na rien change ???
Didier100 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/12/2010, 13h23   #4
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
Je pensais aux droits de l'utilisateur PHP.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/12/2010, 16h38   #5
Nouveau Membre du Club
 
Inscription : juin 2004
Messages : 137
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 137
Points : 36
Points : 36
Bonjour,

Veux tu dire par la que je doit installer suPHP ? J'aimerai bien éviter cela si possible...

Quels droit(s) (fichier de configuration) php (variables) sont à modifier pour obtenir le résultat souhaité?
Didier100 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 31/12/2010, 19h01   #6
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
Ca serait plus une question pour des gens qui connaissent Linux et ta distribution.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/01/2011, 22h34   #7
Nouveau Membre du Club
 
Inscription : juin 2004
Messages : 137
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 137
Points : 36
Points : 36
O.K. je me renseigne et posterai la solution ici quand je trouve la réponse à ma question....
Didier100 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/01/2011, 15h29   #8
Nouveau Membre du Club
 
Inscription : juin 2004
Messages : 137
Détails du profil
Informations forums :
Inscription : juin 2004
Messages : 137
Points : 36
Points : 36
J'ai trouvé la réponse grâce à l'aide sur le forum ... http://www.debian-fr.org/probleme-av...at-t31229.html

Il faut activer le bit setuid du programme netstat.

Cela se fait en exécutant la commande suivante

Code :
chmod u+xs /bin/netstat
Sabotage avait raison c'est une question de droit.

C'est valable pour debian et ubuntu ...

Par contre il faut que je trouve un moyen pour que le le bit setuid ne soit pas activé en permanence ... question de sécurité.
Didier100 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 15h32.


 
 
 
 
Partenaires

Hébergement Web