source: alternc/trunk/src/fixperms.sh @ 2117

Revision 2117, 2.0 KB checked in by anarcat, 5 years ago (diff)

Major redesign of the MySQL backend interface to fix a security issue.
See: #318.

As of now, the MySQL configuration used everywhere by AlternC is not
stored in the main configuration file (/etc/alternc/local.sh) but in a
MySQL configuration file in /etc/alternc/my.cnf, which enables us to
call mysql without exposing the password on the commandline.

The changes here are quite invasive but will allow us to factor out
the MySQL configuration better. See #364.

This includes a partial rewrite of the mysql.sh logic, which is now ran
from the postinst script (and not alternc.install) which will allow us
to actually change the MySQL root user properly. See #601.

This commit was tested like this:

  • clean install on etch (working)
  • upgrade from a clean 0.9.7 (working)
  • Property svn:executable set to *
Line 
1#!/bin/sh -e
2
3#
4# $Id: fixperms.sh,v 1.1 2005/08/29 19:21:31 benjamin Exp $
5# ----------------------------------------------------------------------
6# AlternC - Web Hosting System
7# Copyright (C) 2002 by the AlternC Development Team.
8# http://alternc.org/
9# ----------------------------------------------------------------------
10# Based on:
11# Valentin Lacambre's web hosting softwares: http://altern.org/
12# ----------------------------------------------------------------------
13# LICENSE
14#
15# This program is free software; you can redistribute it and/or
16# modify it under the terms of the GNU General Public License (GPL)
17# as published by the Free Software Foundation; either version 2
18# of the License, or (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23# GNU General Public License for more details.
24#
25# To read the license please visit http://www.gnu.org/copyleft/gpl.html
26# ----------------------------------------------------------------------
27# Original Author of file: Benjamin Sonntag for Metaconsult
28# Purpose of file: Fix permission and ownership of html files
29# ----------------------------------------------------------------------
30#
31
32CONFIG_FILE="/etc/alternc/local.sh"
33
34PATH=/sbin:/bin:/usr/sbin:/usr/bin
35
36umask 022
37
38if [ ! -r "$CONFIG_FILE" ]; then
39    echo "Can't access $CONFIG_FILE."
40    exit 1
41fi
42
43if [ `id -u` -ne 0 ]; then
44    echo "fixperms.sh must be launched as root"
45    exit 1
46fi
47
48. "$CONFIG_FILE"
49
50function doone {
51    read GID LOGIN
52    while [ "$LOGIN" ] 
53      do
54      if [ "$DEBUG" ]; then
55          echo "Setting rights and ownership for user $LOGIN having gid $GID"
56      fi
57      INITIALE=`echo $LOGIN |cut -c1`
58      REP="$ALTERNC_LOC/html/$INITIALE/$LOGIN"
59           
60      find $REP -type d -exec chmod g+s \{\} \;
61          chown -R 33.$GID $REP
62          read GID LOGIN
63    done
64}
65
66mysql --defaults-file=/etc/alternc/my.cnf -B -e "select uid,login from membres" |grep -v ^uid|doone
67
Note: See TracBrowser for help on using the repository browser.