Changeset 3170


Ignore:
Timestamp:
06/12/12 19:11:46 (11 months ago)
Author:
squidly
Message:

modification du script fixperms.sh pour modfier les ACL par fichiers, afin de les modifier après upload par le panel

Location:
alternc/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • alternc/trunk/bureau/class/m_bro.php

    r3150 r3170  
    510510   */ 
    511511  function UploadFile($R) { 
    512     global $_FILES,$err; 
     512    global $_FILES,$err,$cuid; 
    513513    $absolute=$this->convertabsolute($R,0); 
    514514    if (!$absolute) { 
     
    522522        } 
    523523        if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute."/".$_FILES['userfile']['name'])) { 
    524           return $absolute."/".$_FILES['userfile']['name']; 
     524                        exec("sudo /usr/lib/alternc/fixperms.sh -u ".$cuid." -f ".$absolute."/".$_FILES['userfile']['name']); 
     525                        return $absolute."/".$_FILES['userfile']['name']; 
    525526        } else { 
    526527          $err->raise("bro",3); 
  • alternc/trunk/etc/alternc/alternc-sudoers

    r3145 r3170  
    1 alterncpanel    ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota 
     1alterncpanel    ALL = NOPASSWD : /usr/bin/quota, /usr/sbin/setquota, /usr/lib/alternc/fixperms.sh 
    22vmail           ALL = NOPASSWD : /usr/lib/dovecot/deliver 
  • alternc/trunk/src/fixperms.sh

    r3132 r3170  
    3232query="SELECT uid,login FROM membres" 
    3333sub_dir="" 
    34  
     34file="" 
    3535#Two optionals argument 
    3636# -l string : a specific login to fix 
    37 # -u interger : a specifi uid to fix 
    38 while getopts "l:u:d:" optname 
     37# -u interger : a specific uid to fix 
     38# -f interger : a specific file to fix according to a given uid  
     39 
     40while getopts "l:u:f:d:" optname 
    3941  do 
    4042    case "$optname" in 
    4143      "l") 
    42         query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG'" 
     44                if [[ "$OPTARG" =~ ^[a-zA-Z0-9_]+$ ]] ; then 
     45                query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG'" 
     46                else     
     47                        echo "Bad login provided" 
     48                        exit 
     49                fi 
    4350        ;; 
    4451      "u") 
    45         query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG'" 
     52                if [[ "$OPTARG" =~ ^[0-9]+$ ]] ; then 
     53                        query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG'" 
     54                else 
     55                        echo "Bad uid provided" 
     56                        exit 
     57                fi 
     58        ;; 
     59      "f") 
     60                  file="$OPTARG" 
    4661        ;; 
    4762      "d") 
     
    98113      # Set the defaults acl on all the files 
    99114      setfacl -b -k -m d:g:alterncpanel:rwx -m d:u:$GID:rw- -m d:g:$GID:rw- \ 
    100                     -m   g:alterncpanel:rwx -m   u:$GID:rw- -m   g:$GID:rw- \ 
    101               -R "$REP" 
     115                    -Rm   g:alterncpanel:rwx -m   u:$GID:rw- -m   g:$GID:rw- \ 
     116              "$REP" 
    102117 
    103118      read GID LOGIN 
     
    105120} 
    106121 
    107 mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |doone 
     122fixefile(){ 
     123        read GID LOGIN 
     124        /usr/bin/setfacl  -bk $file 
     125        echo "gid: $GID" 
     126        echo "file: $file" 
     127        chown $GID:$GID $file 
     128        chmod 0770 $file 
     129        /usr/bin/setfacl  -m u:$GID:rw- -m g:$GID:rw- -m g:alterncpanel:rw- -m u:$GID:rw- -m g:$GID:rw- $file 
     130        echo file ownership and ACLs changed 
    108131 
     132} 
     133 
     134if [[  $file != "" ]]; then 
     135        if [ -e $file ]; then 
     136                mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |fixefile 
     137        else 
     138                echo "file not found" 
     139        fi 
     140else 
     141        mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "$query" |doone 
     142fi 
Note: See TracChangeset for help on using the changeset viewer.