2011-03-06 20:43:51 +00:00
|
|
|
|
#!/bin/bash -e
|
2006-05-16 18:20:14 +00:00
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# $Id: fixperms.sh,v 1.1 2005/08/29 19:21:31 benjamin Exp $
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
# AlternC - Web Hosting System
|
|
|
|
|
# Copyright (C) 2002 by the AlternC Development Team.
|
|
|
|
|
# http://alternc.org/
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
# Based on:
|
|
|
|
|
# Valentin Lacambre's web hosting softwares: http://altern.org/
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
# LICENSE
|
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
|
# modify it under the terms of the GNU General Public License (GPL)
|
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
# Original Author of file: Benjamin Sonntag for Metaconsult
|
|
|
|
|
# Purpose of file: Fix permission and ownership of html files
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
|
2011-12-31 15:46:11 +00:00
|
|
|
|
#Default Query : fixperms for all account
|
|
|
|
|
query="SELECT uid,login FROM membres"
|
2011-12-31 16:00:30 +00:00
|
|
|
|
sub_dir=""
|
2011-12-31 15:46:11 +00:00
|
|
|
|
|
|
|
|
|
#Two optionals argument
|
|
|
|
|
# -l string : a specific login to fix
|
|
|
|
|
# -u interger : a specifi uid to fix
|
2011-12-31 16:00:30 +00:00
|
|
|
|
while getopts "l:u:d:" optname
|
2011-12-31 15:46:11 +00:00
|
|
|
|
do
|
|
|
|
|
case "$optname" in
|
|
|
|
|
"l")
|
|
|
|
|
query="SELECT uid,login FROM membres WHERE login LIKE '$OPTARG'"
|
|
|
|
|
;;
|
|
|
|
|
"u")
|
|
|
|
|
query="SELECT uid,login FROM membres WHERE uid LIKE '$OPTARG'"
|
|
|
|
|
;;
|
2011-12-31 16:00:30 +00:00
|
|
|
|
"d")
|
|
|
|
|
sub_dir="$OPTARG"
|
|
|
|
|
;;
|
2011-12-31 15:46:11 +00:00
|
|
|
|
"?")
|
|
|
|
|
echo "Unknown option $OPTARG - stop processing"
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
":")
|
|
|
|
|
echo "No argument value for option $OPTARG - stop processing"
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
# Should not occur
|
|
|
|
|
echo "Unknown error while processing options"
|
|
|
|
|
exit
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2006-05-16 18:20:14 +00:00
|
|
|
|
CONFIG_FILE="/etc/alternc/local.sh"
|
|
|
|
|
|
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
|
|
|
|
|
|
|
|
umask 022
|
|
|
|
|
|
|
|
|
|
if [ ! -r "$CONFIG_FILE" ]; then
|
|
|
|
|
echo "Can't access $CONFIG_FILE."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ `id -u` -ne 0 ]; then
|
|
|
|
|
echo "fixperms.sh must be launched as root"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
. "$CONFIG_FILE"
|
|
|
|
|
|
2008-04-24 16:10:27 +00:00
|
|
|
|
doone() {
|
2006-05-16 18:20:14 +00:00
|
|
|
|
read GID LOGIN
|
2011-05-22 09:22:45 +00:00
|
|
|
|
while [ "$LOGIN" ] ; do
|
2006-05-16 18:20:14 +00:00
|
|
|
|
if [ "$DEBUG" ]; then
|
2011-05-22 19:18:43 +00:00
|
|
|
|
echo "Setting rights and ownership for user $LOGIN having gid $GID"
|
2006-05-16 18:20:14 +00:00
|
|
|
|
fi
|
|
|
|
|
INITIALE=`echo $LOGIN |cut -c1`
|
2011-12-31 16:00:30 +00:00
|
|
|
|
REP="$ALTERNC_LOC/html/$INITIALE/$LOGIN/$sub_dir"
|
2011-12-31 15:46:11 +00:00
|
|
|
|
|
2011-05-22 09:22:45 +00:00
|
|
|
|
# Set the file readable only for the AlternC User
|
2011-05-22 19:18:43 +00:00
|
|
|
|
chown -R $GID:$GID "$REP"
|
2011-05-22 09:22:45 +00:00
|
|
|
|
chmod 2770 -R "$REP"
|
|
|
|
|
|
|
|
|
|
# Delete existings ACL
|
2011-05-22 17:23:59 +00:00
|
|
|
|
# Set the defaults acl on all the files
|
2011-05-22 19:18:43 +00:00
|
|
|
|
setfacl -b -k -m d:g:alterncpanel:rw- -m d:u:$GID:rw- -m d:g:$GID:rw- \
|
|
|
|
|
-m g:alterncpanel:rw- -m u:$GID:rw- -m g:$GID:rw- \
|
2011-12-31 15:46:11 +00:00
|
|
|
|
-R "$REP"
|
2011-05-22 09:22:45 +00:00
|
|
|
|
|
2011-05-22 19:18:43 +00:00
|
|
|
|
read GID LOGIN
|
2006-05-16 18:20:14 +00:00
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-31 15:46:11 +00:00
|
|
|
|
mysql --defaults-file=/etc/alternc/my.cnf -B -e "$query" |grep -v ^uid|doone
|