[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Permissions altérées



pyfux a écrit :

>Bonjour à tous,
>
>voilà, j'ai écris un petit script bash pour modifier automatiquement les
>permissions sur différents répertoires.
>Malheureusement, une erreur s'est glissé et cela à modifié les
>permissions de certains fichiers. La conséquence est que maintenant avec
>mon utilisateur pyfux, je ne peux plus lancer X.
>
>Voila le code:
>
>#!/bin/bash
>
>user=pyfux
>basedir=/var
>perm=a-rwx,ug+r
>
>path[0]=$basedir/www-data
>path[1]=$basedir/www-data/php.include
>path[2]=$basedir/www/media.web
>path[3]=$basedir/www/media.web/images
>path[4]=$basedir/www/media.web/javascript
>
>for index  in  `seq 0 ${#path[@]}`
>do
>    echo "Modification du prorietaire du repertoire: ${path[index]}";
>    chown $user ${path[index]};
>    chgrp $user ${path[index]};
>    echo "Modification des perm des fichiers du rep: ${path[index]}";
>    chmod $perm ${path[index]}/*;
>done
>
>
>Bien, cherchez l'erreur...
>
>
>
>
>
>La réponse: for index  in  `seq 0 ${#path[@]}`
>incrémente d'un index en trop: le 5ième.
>Ainsi lors de la 5ieme itération, les traitements (chown, chgrp et
>chmod) opère sur:   /  !!!!
>
>Comment revenir sur les anciens droits pour les répertoire juste
>sous / ?
>  
>
Si tu n'as pas fait de recursion, tu ferais mieux de le faire a la main.
Voici ce que j'ai sur une installation par defaut:

drwxr-xr-x    2 root root   4096 Sep 27 16:07 bin
drwxr-xr-x    3 root root   4096 Sep 27 16:09 boot
lrwxrwxrwx    1 root root     11 Mar 22  2005 cdrom
drwxr-xr-x   14 root root  14500 Sep 28 16:13 dev
drwxr-xr-x  128 root root   8192 Sep 28 09:08 etc
drwxrwsr-x    5 root staff  4096 Sep 12 10:58 home
drwxr-xr-x    2 root root   4096 Mar 22  2005 initrd
lrwxrwxrwx    1 root root     32 Aug 30 11:36 initrd.img
lrwxrwxrwx    1 root root     32 Apr 19 09:30 initrd.img.old
drwxr-xr-x   15 root root   8192 Sep 26 09:11 lib
drwxr-xr-x    2 root root  16384 Mar 22  2005 lost+found
drwxr-xr-x    6 root root   4096 Mar 29  2005 media
drwxr-xr-x    2 root root   4096 Mar 22  2005 mnt
drwxr-xr-x    2 root root   4096 Mar 22  2005 opt
dr-xr-xr-x  140 root root      0 Sep 28 09:07 proc
drwxr-xr-x   13 root root   4096 Sep 28 09:10 root
drwxr-xr-x    2 root root   8192 Sep 27 16:08 sbin
drwxr-xr-x    2 root root   4096 Mar 22  2005 srv
drwxr-xr-x   10 root root      0 Sep 28 09:07 sys
drwxrwxrwt   11 root root   4096 Sep 28 16:24 tmp
drwxr-xr-x   12 root root   4096 Jul 13 12:46 usr
drwxr-xr-x   15 root root   4096 Jun  2 09:38 var
lrwxrwxrwx    1 root root     29 Aug 30 11:36 vmlinuz
lrwxrwxrwx    1 root root     29 Apr 19 09:30 vmlinuz.old

A+

>PyFux, le débordeur de array
>
>  
>



Reply to: