Droit de fichier depuis apache

Bonsoir à tous,

j’aurai besoin d’une aide.

J’ai un serveur intranet avec apache2, mysql, php…

J’ai réaliser une page en php pour réaliser la création de répertoire dans un dossier. Ce dossier (ou doit être créé les répertoire) est un lien symbolique qui part sur un emplacement réseau.

Problème lorsqu’il essai de créer un répertoire il lui retourne:

Warning: chmod() [function.chmod]: Operation not permitted in /var/www/ged/v0.1a/ajax/ajax_new_societe.php on line 45

Par exemple: le script arrive à créer le premier niveau des répertoires:

drwxr-xr-x 2 root root 0 2009-10-07 14:12 1
drwxr-xr-x 2 root root 0 2009-10-07 14:12 2
drwxr-xr-x 2 root root 0 2009-10-07 14:12 3
drwxr-xr-x 2 root root 0 2009-10-07 14:12 4
drwxr-xr-x 2 root root 0 2009-10-07 14:12 5
drwxr-xr-x 2 root root 0 2009-10-07 14:12 6

avec des droit 755 (alors que dans mon script je demande 777) avec comme propriétaire root group root, il lui est donc impossible de créer les sous répertoire.
Mon code php:

///////////CREATION DU DOSSIER SOCIETE
		$res = mysql_query("INSERT INTO societe (id_societe, nom_societe, initial_societe) VALUES ('','$test', '$test2')");
		$dossierdepart = '../../../doc_ged/';
		$res0 = mysql_query("SELECT id_societe, nom_societe FROM societe;");
			while($row = mysql_fetch_array($res0))
					{
					$dossier = ''.$dossierdepart.''.$row['id_societe'].'/';
					
					if(IsDir_or_CreateIt($dossier)) 
					{
					echo "deja écréé==>".$dossier."<<<";
					
					} 
					else 
					{
					$old = umask(0);
					mkdir("$dossier", 0777); 
					umask($old);
					echo 'création du dossier'.$dossier.'<br/>';
					};
					
					//echo ''.$dossier.'<br/>';
					
					//echo "1";
					
					////////////////////////////////
						
						/////////////////////////
						$sql1=mysql_query("select id_type, nom_type FROM type ORDER BY nom_type");
							while($row1 = mysql_fetch_array($sql1))
							{
							
							//dossier Type
							$dossier2 = ''.$dossier.''.$row1["id_type"].'/';
							if(IsDir_or_CreateIt($dossier2)) 
								{
								echo "deja écréé==>".$dossier2."<<<<br/>";
								} 
								else 
								{
								mkdir("$dossier2", 0777); 
								echo 'création du dossier'.$dossier2.'<br/>';
								};
								
								
								////////////////////////////////////
								
								///////////////////////////////////////
								


							}
					}

voila:
apache2.conf

User www-data
Group www-data

Voici un ps aux

root@XXXXXXX-desktop:/var/www/doc_ged# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.2   2912  1844 ?        Ss   Jul29   0:01 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Jul29   0:00 [migration/0]
root         3  0.0  0.0      0     0 ?        SN   Jul29   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    Jul29   0:00 [watchdog/0]
root         5  0.0  0.0      0     0 ?        S<   Jul29   0:00 [events/0]
root         6  0.0  0.0      0     0 ?        S<   Jul29   0:00 [khelper]
root         7  0.0  0.0      0     0 ?        S<   Jul29   0:00 [kthread]
root        30  0.0  0.0      0     0 ?        S<   Jul29   0:01 [kblockd/0]
root        31  0.0  0.0      0     0 ?        S<   Jul29   0:00 [kacpid]
root        32  0.0  0.0      0     0 ?        S<   Jul29   0:00 [kacpi_notify]
root       101  0.0  0.0      0     0 ?        S<   Jul29   0:00 [kseriod]
root       122  0.0  0.0      0     0 ?        S    Jul29  13:25 [pdflush]
root       124  0.0  0.0      0     0 ?        S<   Jul29   0:10 [kswapd0]
root       125  0.0  0.0      0     0 ?        S<   Jul29   0:00 [aio/0]
root      1962  0.0  0.0      0     0 ?        S<   Jul29   0:00 [scsi_eh_0]
root      1964  0.0  0.0      0     0 ?        S<   Jul29   0:00 [ksuspend_usbd]
root      1965  0.0  0.0      0     0 ?        S<   Jul29   0:00 [khubd]
root      2457  0.0  0.0      0     0 ?        S<   Jul29   0:00 [ata/0]
root      2458  0.0  0.0      0     0 ?        S<   Jul29   0:00 [ata_aux]
root      2460  0.0  0.0      0     0 ?        S<   Jul29   0:00 [scsi_eh_1]
root      2461  0.0  0.0      0     0 ?        S<   Jul29   2:58 [scsi_eh_2]
root      2754  0.0  0.0      0     0 ?        S<   Jul29   0:46 [kjournald]
root      2955  0.0  0.1   2892  1232 ?        S<s  Jul29   0:00 /sbin/udevd --daemon
root      3090  0.0  0.8  28876  7692 ?        Ss   Oct05   0:00 /usr/sbin/apache2 -k start
www-data  3095  0.0  1.1  31208  9972 ?        S    Oct05   0:04 /usr/sbin/apache2 -k start
www-data  3097  0.0  1.0  30380  9160 ?        S    Oct05   0:03 /usr/sbin/apache2 -k start
www-data  3098  0.0  0.9  30036  8760 ?        S    Oct05   0:03 /usr/sbin/apache2 -k start
www-data  3115  0.0  1.0  31196  9836 ?        S    Oct05   0:01 /usr/sbin/apache2 -k start
www-data  3219  0.0  0.9  30276  9016 ?        S    Oct05   0:02 /usr/sbin/apache2 -k start
root      3447  0.0  0.0      0     0 ?        S<   Jul29   0:00 [cifsoplockd]
root      3448  0.0  0.0      0     0 ?        S<   Jul29   0:00 [cifsdnotifyd]
root      3459  0.0  0.0      0     0 ?        S    Jul29   0:06 [cifsd]
www-data  3482  0.0  1.0  30432  9064 ?        S    Oct06   0:00 /usr/sbin/apache2 -k start
www-data  3483  0.0  0.7  29320  6908 ?        S    Oct06   0:00 /usr/sbin/apache2 -k start
root      3505  0.0  0.2   7880  2404 ?        Ss   Oct06   0:00 sshd: XXXXXXX [priv]
XXXXXXX  3509  0.0  0.1   8040  1664 ?        S    Oct06   0:02 sshd: XXXXXXX@pts/0
XXXXXXX  3510  0.0  0.3   5624  3100 pts/0    Ss   Oct06   0:00 -bash
root      3528  0.0  0.3   5140  2932 pts/0    S    Oct06   0:02 /bin/bash
www-data  3663  0.0  1.0  30368  9140 ?        S    Oct05   0:03 /usr/sbin/apache2 -k start
root      3804  0.0  0.0      0     0 ?        S<   Jul29   0:00 [kpsmoused]
root      4176  0.0  0.0      0     0 ?        S<   Jul29   1:24 [kjournald]
root      4178  0.0  0.0      0     0 ?        S<   Jul29   0:44 [kjournald]
root      4488  0.0  0.0   1652   512 tty4     Ss+  Jul29   0:00 /sbin/getty 38400 tty4
root      4489  0.0  0.0   1652   512 tty5     Ss+  Jul29   0:00 /sbin/getty 38400 tty5
root      4493  0.0  0.0   1648   508 tty2     Ss+  Jul29   0:00 /sbin/getty 38400 tty2
root      4494  0.0  0.0   1648   504 tty3     Ss+  Jul29   0:00 /sbin/getty 38400 tty3
root      4495  0.0  0.0   1648   508 tty1     Ss+  Jul29   0:00 /sbin/getty 38400 tty1
root      4500  0.0  0.0   1652   512 tty6     Ss+  Jul29   0:00 /sbin/getty 38400 tty6
root      4741  0.0  0.1   2256  1176 ?        Ss   Jul29   0:00 /usr/sbin/acpid -c /etc/acpi/events -s /var/run/acpid.socket
root      4847  0.0  0.0   1700   664 ?        Ss   Jul29   0:23 /sbin/syslogd
root      4899  0.0  0.0   1796   528 ?        Ss   Jul29   0:00 /bin/dd bs 1 if /proc/kmsg of /var/run/klogd/kmsg
klog      4901  0.0  0.1   2552  1368 ?        Ss   Jul29   0:00 /sbin/klogd -P /var/run/klogd/kmsg
103       4922  0.0  0.1   2848  1052 ?        Ss   Jul29   3:14 /usr/bin/dbus-daemon --system
107       4938  0.0  0.9  10128  8424 ?        Ss   Jul29   1:25 /usr/sbin/hald
root      4939  0.0  0.1   2876  1024 ?        S    Jul29   0:00 hald-runner
107       4945  0.0  0.0   2104   888 ?        S    Jul29   0:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.so
107       4955  0.0  0.0   2100   896 ?        S    Jul29   0:00 hald-addon-keyboard: listening on /dev/input/event2
107       4958  0.0  0.0   2104   900 ?        S    Jul29   0:00 hald-addon-keyboard: listening on /dev/input/event3
107       4961  0.0  0.0   2104   900 ?        S    Jul29   0:00 hald-addon-keyboard: listening on /dev/input/event4
107       4975  0.0  0.1   2104   912 ?        S    Jul29   3:08 hald-addon-storage: polling /dev/scd0
root      4988  0.0  0.0   1940   696 ?        Ss   Jul29   0:06 /usr/sbin/dhcdbd --system
root      5003  0.0  0.2   4132  1864 ?        Ss   Jul29   0:00 /usr/sbin/NetworkManager --pid-file /var/run/NetworkManager/
avahi     5021  0.0  0.1   2672  1388 ?        Ss   Jul29   0:00 avahi-daemon: running [XXXXXXX-desktop.local]
avahi     5022  0.0  0.0   2672   464 ?        Ss   Jul29   0:00 avahi-daemon: chroot helper
root      5035  0.0  0.1   3028  1144 ?        Ss   Jul29   0:00 /usr/sbin/NetworkManagerDispatcher --pid-file /var/run/Netwo
root      5048  0.0  0.0   2872   804 ?        Ss   Jul29   0:00 /usr/bin/system-tools-backends
root      5049  0.0  0.1   2716  1220 ?        S    Jul29   0:00 dbus-daemon --session --print-address --nofork
root      5081  0.0  0.1  12348  1412 ?        Ss   Jul29   0:00 /usr/sbin/gdm
root      5082  0.0  0.2  12844  2572 ?        S    Jul29   0:00 /usr/sbin/gdm
root      5087  0.0  1.9  37744 17828 tty7     Ss+  Jul29   8:38 /usr/X11R6/bin/X :0 -br -audit 0 -auth /var/lib/gdm/:0.Xauth
root      5173  0.0  0.0   6412   832 ?        Ss   Jul29   0:00 /usr/sbin/hpiod
hplip     5176  0.0  0.5   9988  4892 ?        S    Jul29   0:00 python /usr/sbin/hpssd
root      5238  0.0  0.0   1712   524 ?        S    Jul29   0:00 /bin/sh /usr/bin/mysqld_safe
mysql     5280  0.0  2.3 127308 21048 ?        Sl   Jul29   3:25 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --u
root      5282  0.0  0.0   1640   536 ?        S    Jul29   0:00 logger -p daemon.err -t mysqld_safe -i -t mysqld
mail      5401  0.0  0.0   2796   500 ?        S    Jul29   0:06 /usr/sbin/nullmailer-send -d
root      5449  0.0  0.1   6336  1236 ?        Ss   Jul29   0:42 /usr/sbin/nmbd -D
root      5455  0.0  0.2   9644  2568 ?        Ss   Jul29   0:01 /usr/sbin/smbd -D
root      5475  0.0  0.1   5088   972 ?        Ss   Jul29   0:00 /usr/sbin/sshd
root      5480  0.0  0.0   9484   740 ?        S    Jul29   0:00 /usr/sbin/smbd -D
root      5528  0.0  0.0   2352   856 ?        Ss   Jul29   0:00 /usr/sbin/xinetd -pidfile /var/run/xinetd.pid -stayalive
root      5565  0.0  0.1   2696  1004 ?        Ss   Jul29   0:00 /usr/sbin/hcid -x -s
root      5582  0.0  0.0      0     0 ?        S<   Jul29   0:00 [krfcommd]
daemon    5617  0.0  0.0   1908   420 ?        Ss   Jul29   0:00 /usr/sbin/atd
root      5631  0.0  0.1   2284   908 ?        Ss   Jul29   0:04 /usr/sbin/cron
root      5694  0.0  0.0   1500   152 ?        S    Jul29   0:00 /usr/bin/vmnet-bridge -d /var/run/vmnet-bridge-0.pid /dev/vm
root      5699  0.0  1.6  18336 14616 ?        Ss   Jul29  19:31 /usr/sbin/vmware-serverd -s -d
root      7415  0.0  0.1   2560   992 pts/0    R+   08:12   0:00 ps aux
cupsys    8010  0.0  0.2   4840  2096 ?        SNs  Jul30  40:10 /usr/sbin/cupsd
www-data 11010  0.0  0.8  29316  7608 ?        S    Oct05   0:00 /usr/sbin/apache2 -k start
www-data 11011  0.0  1.0  31224  9892 ?        S    Oct05   0:02 /usr/sbin/apache2 -k start
root     15421  0.0  0.0      0     0 ?        S    Sep21   2:26 [pdflush]
XXXXXXX 15480  0.0  1.2  30892 11696 ?        Ssl  Sep21   0:00 x-session-manager
XXXXXXX 15518  0.0  0.0   4252   532 ?        Ss   Sep21   0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session
XXXXXXX 15521  0.0  0.0   2660   632 ?        S    Sep21   0:00 /usr/bin/dbus-launch --exit-with-session x-session-manager
XXXXXXX 15522  0.0  0.1   2852  1052 ?        Ss   Sep21   0:00 /usr/bin/dbus-daemon --fork --print-pid 4 --print-address 8
XXXXXXX 15524  0.0  0.5   7200  4608 ?        S    Sep21   0:01 /usr/lib/libgconf2-4/gconfd-2 6
XXXXXXX 15527  0.0  0.1   2760  1000 ?        S    Sep21   0:00 /usr/bin/gnome-keyring-daemon
XXXXXXX 15529  0.0  1.0  29772  9780 ?        Sl   Sep21   0:02 /usr/lib/control-center/gnome-settings-daemon
XXXXXXX 15542  0.7 47.6 527804 431668 ?       S<sl Sep22 165:58 /usr/lib/vmware/bin/vmware-vmx -C /var/IMAGEVMWARE/Windows S
XXXXXXX 16003  0.0  0.3  31648  3232 ?        Ssl  Sep21   0:00 /usr/lib/bonobo-activation/bonobo-activation-server --ac-act
XXXXXXX 16008  0.1  1.2  31188 10924 ?        S    Sep21  26:50 /usr/lib/vino/vino-server --oaf-activate-iid=OAFIID:GNOME_Re
XXXXXXX 16012  0.0  1.1  17804 10728 ?        S    Sep21   0:11 /usr/bin/metacity --sm-client-id=default0
XXXXXXX 16014  0.0  2.2  44844 19944 ?        S    Sep21   1:07 gnome-panel --sm-client-id default1
XXXXXXX 16017  0.0  3.3  85216 30328 ?        S    Sep21   1:03 nautilus --no-default-window --sm-client-id default2
XXXXXXX 16025  0.0  0.5  19200  5012 ?        Ss   Sep21   1:26 gnome-volume-manager --sm-client-id default4
XXXXXXX 16031  0.0  0.3   8604  3440 ?        S    Sep21   0:00 /usr/lib/gnome-vfs-2.0/gnome-vfs-daemon
XXXXXXX 16043  0.0  1.0  64672  9404 ?        S    Sep21   0:00 /usr/lib/gnome-applets/trashapplet --oaf-activate-iid=OAFIID
XXXXXXX 16046  0.0  0.0   2456   888 ?        S    Sep21   0:00 /usr/lib/nautilus-cd-burner/mapping-daemon
XXXXXXX 16068  0.0  1.4  34868 13144 ?        S    Sep21   0:02 update-notifier
XXXXXXX 16070  0.0  1.1  68644 10228 ?        Sl   Sep21   0:00 /usr/lib/evolution/2.10/evolution-alarm-notify
XXXXXXX 16075  0.0  1.1  32068 10688 ?        S    Sep21   0:04 nm-applet --sm-disable
XXXXXXX 16076  0.2  0.9  41448  8476 ?        S    Sep21  52:47 gnome-cups-icon --sm-client-id default3
XXXXXXX 16080  0.0  0.6  31760  6288 ?        Ss   Sep21   0:04 gnome-power-manager
XXXXXXX 16090  0.0  1.3  35384 12632 ?        S    Sep21   0:00 /usr/lib/gnome-applets/mixer_applet2 --oaf-activate-iid=OAFI
XXXXXXX 16094  0.0  1.0  36816  9668 ?        Sl   Sep21   0:00 /usr/lib/evolution/2.10/evolution-exchange-storage --oaf-act
XXXXXXX 16117  0.0  0.7  58764  6596 ?        Sl   Sep21   0:00 /usr/lib/evolution/evolution-data-server-1.10 --oaf-activate
XXXXXXX 16158  0.0  0.4  16364  4492 ?        Ss   Sep21   0:04 gnome-screensaver
XXXXXXX 16176  0.0  1.2  31464 11548 ?        S    Sep21   0:03 /usr/lib/notification-daemon/notification-daemon
XXXXXXX 17156  0.0  0.0   1712   520 ?        S    Sep21   0:00 /bin/sh /usr/lib/vmware/lib/wrapper-gtk24.sh /usr/lib/vmware
XXXXXXX 17170  0.0  4.2  97280 38168 ?        S    Sep21   9:40 /usr/lib/vmware/bin/vmware /var/IMAGEVMWARE/Windows Server 2
XXXXXXX 17171  0.0  0.0   1712   280 ?        S    Sep21   0:00 /bin/sh /usr/lib/vmware/lib/wrapper-gtk24.sh /usr/lib/vmware
root     26353  0.0  0.0   4840   636 ?        SNs  Oct04   0:00 pure-ftpd (SERVER)
root@XXXXXXX-desktop:/var/www/doc_ged#

Le dossier (var/www/ et le dossier ou doivent être créé le répertoire) a comme propriétaire www-data et groupe www-data.

Je n’arrive pas avoir d’où vient le problème? Problème de droit ? au niveau php?

Merci d’avance pour votre aide.

guigui69

Je revient vers vous,

juste pour faire un test

au lieu de partir sur mon dossier doc_ged (lien symbolique qui part sur un emplacement réseau windows), j’ai indiqué un repertoire qui était dans mon www ( /ged/test).

Et a partir de la j’ai aucun message d’erreur, il me créer les repertoire sous repertoire avec l’utilisateur www-data group www-data.

Quel est le problème au niveau de mon lien symbolique et de ses droit? pourquoi root ?

merci

guigui69