Changeset 2117


Ignore:
Timestamp:
04/13/08 06:35:19 (5 years ago)
Author:
anarcat
Message:

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)
Location:
alternc/trunk
Files:
16 edited

Legend:

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

    r2115 r2117  
    1414$config_file = fopen('/etc/alternc/local.sh', 'r'); 
    1515while (FALSE !== ($line = fgets($config_file))) { 
    16     if (ereg('^([A-Z0-9_]*)="([^"]*)"', $line, $regs)) { 
     16    if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) { 
    1717        $GLOBALS['L_'.$regs[1]] = $regs[2]; 
    1818        if (isset($compat[$regs[1]])) { 
     
    2323 
    2424fclose($config_file); 
     25 
     26$config_file = fopen('/etc/alternc/my.cnf', 'r'); 
     27while (FALSE !== ($line = fgets($config_file))) { 
     28    if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) { 
     29        switch ($regs[1]) { 
     30        case "user": 
     31            $GLOBALS['L_MYSQL_LOGIN'] = $regs[2]; 
     32            break; 
     33        case "password": 
     34            $GLOBALS['L_MYSQL_PWD'] = $regs[2]; 
     35            break; 
     36        case "host": 
     37            $GLOBALS['L_MYSQL_HOST'] = $regs[2]; 
     38            break; 
     39        case "database": 
     40            $GLOBALS['L_MYSQL_DATABASE'] = $regs[2]; 
     41            break; 
     42        } 
     43    } 
     44} 
     45 
     46fclose($config_file); 
  • alternc/trunk/debian/changelog

    r2105 r2117  
    11alternc (0.9.7+dev) stable; urgency=low UNRELEASED 
    22 
     3  * move mysql configuration into a valid MySQL configuration file 
     4    (/etc/alternc/my.cnf). This fixes a serious security issue (#318) 
     5    where the MySQL root password was passed on the commandline.  Those 
     6    changes are pretty invasive and might break upgrades, cron jobs and 
     7    your cat... 
    38  * standardisation of the web interface, along with some esthetic changes, by 
    49    Marc Angles, sponsored by Koumbit 
  • alternc/trunk/debian/config

    r2048 r2117  
    3838    # source the current config 
    3939    . /etc/alternc/local.sh 
     40fi 
     41if [ -r /etc/alternc/my.cnf ]; then 
     42    # make mysql configuration available as shell variables 
     43    # to convert from .cnf to shell syntax, we: 
     44    # * match only lines with "equal" in them (/=/) 
     45    # * remove whitespace around the = and add a left quote operator ' (;s) 
     46    # * add a right quote operator at the end of line (;s) 
     47    # * convert mysql variables into our MYSQL_ naming convention (;s) 
     48    # * print the result (;p) 
     49    eval `sed -n -e "/=/{s/ *= */='/;s/\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_LOGIN/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf` 
    4050fi 
    4151 
  • alternc/trunk/debian/postinst

    r2108 r2117  
    8484DEFAULT_MX="" 
    8585 
    86 # MySQL configuration 
    87 MYSQL_HOST="" 
    88 MYSQL_DATABASE="" 
    89 MYSQL_USER="" 
    90 MYSQL_PASS="" 
     86# Note: MySQL username/password configuration now stored in /etc/alternc/my.cnf 
     87 
    9188# quels clients mysql sont permis (%, localhost, etc) 
    9289MYSQL_CLIENT="" 
     
    120117    update_var alternc/bind_internal BIND_INTERNAL 
    121118    update_var alternc/default_mx DEFAULT_MX  
    122     update_var alternc/mysql/host MYSQL_HOST  
    123     update_var alternc/mysql/db MYSQL_DATABASE  
    124     update_var alternc/mysql/user MYSQL_USER  
    125     update_var alternc/mysql/password MYSQL_PASS  
    126119    update_var alternc/mysql/client MYSQL_CLIENT  
    127120    update_var alternc/alternc_location ALTERNC_LOC 
     
    130123    mv -f $CONFIGFILE.tmp $CONFIGFILE 
    131124 
     125    # Setup grants 
     126    db_get "alternc/mysql/host" 
     127    MYSQL_HOST="$RET" 
     128    if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then 
     129        # compatibility shims with my.cnf 
     130        host="$RET" 
     131        db_get "alternc/mysql/db" 
     132        database="$RET" 
     133        db_get "alternc/mysql/user" 
     134        user="$RET" 
     135        db_get "alternc/mysql/password" 
     136        password="$RET" 
     137         
     138        # we source (instead of forking) mysql.sh so that it gets the local environment above 
     139        . /usr/share/alternc/install/mysql.sh 
     140    fi 
     141 
    132142    # forget the password 
    133143    db_reset alternc/mysql/password || true 
  • alternc/trunk/debian/postrm

    r1835 r2117  
    1616case "$1" in 
    1717  purge) 
    18     rm -f /etc/alternc/local.sh /etc/alternc/bureau.conf 
     18    rm -f /etc/alternc/local.sh /etc/alternc/my.cnf /etc/alternc/bureau.conf 
    1919    rm -f /var/backups/alternc/etc-installed.tar.gz 
    2020 
  • alternc/trunk/install/alternc.install

    r1995 r2117  
    55# on a new server. THIS SCRIPT ERASE ALL DATA ON THE AlternC SYSTEM !! 
    66# YOU HAVE BEEN WARNED ! 
     7 
     8# This script now assumes it has MySQL connectivity through 
     9# /etc/alternc/my.cnf 
    710 
    811set -e  
     
    7982. /etc/alternc/local.sh 
    8083 
     84# XXX: copy-paste from debian/config 
     85if [ -r /etc/alternc/my.cnf ]; then 
     86    # make mysql configuration available as shell variables 
     87    # to convert from .cnf to shell syntax, we: 
     88    # * match only lines with "equal" in them (/=/) 
     89    # * remove whitespace around the = and add a left quote operator ' (;s) 
     90    # * add a right quote operator at the end of line (;s) 
     91    # * convert mysql variables into our MYSQL_ naming convention (;s) 
     92    # * print the result (;p) 
     93    eval `sed -n -e "/=/{s/ *= */='/;s/\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_LOGIN/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf` 
     94fi 
     95 
    8196WARNING="WARNING: Do not edit this file, edit the one in /etc/alternc/templates and launch alternc.install again." 
    8297 
     
    102117fi 
    103118 
    104 SED_SCRIPT=" 
     119# XXX: I assume this is secure if /tmp is sticky (+t) 
     120# we should have a better way to deal with templating, of course. 
     121SED_SCRIPT=`mktemp` 
     122cat > $SED_SCRIPT <<EOF 
    105123s\\%%hosting%%\\$HOSTING\\; 
    106124s\\%%fqdn%%\\$FQDN\\; 
     
    122140s\\%%version%%\\$VERSION\\; 
    123141s\\%%ns2_ip%%\\$NS2_IP\\; 
    124 " 
     142EOF 
    125143 
    126144####################################################################### 
     
    146164    TEMPLATE="$TEMPLATE_DIR/${file##etc/}" 
    147165    if [ -f "$TEMPLATE" ]; then 
    148         sed -e "$SED_SCRIPT" < $TEMPLATE > /$file 
    149     fi 
    150 done 
     166        sed -f "$SED_SCRIPT" < $TEMPLATE > /$file 
     167    fi 
     168done 
     169rm -f $SED_SCRIPT 
    151170 
    152171####################################################################### 
     
    154173# 
    155174tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES 
    156  
    157 ###################################################################### 
    158 # Initialize database 
    159 # 
    160 if [ "$MYSQL_HOST" != "localhost" -o -e /usr/sbin/mysqld ]; then 
    161     echo "Setup MySQL and database..." 
    162     /usr/share/alternc/install/mysql.sh "$MYSQL_HOST" "$MYSQL_USER" "$MYSQL_PASS" "$MYSQL_DATABASE" 
    163 fi 
    164175 
    165176########################################################################  
     
    264275 
    265276# Creating admin user if needed 
    266 HAS_ROOT="`mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$MYSQL_DATABASE" -e "SELECT COUNT(*) FROM membres WHERE login = 'admin' OR login = 'root' and su = 1" | tail -1`" 
     277HAS_ROOT=`mysql --defaults-file=/etc/alternc/my.cnf -e "SELECT COUNT(*) FROM membres WHERE login = 'admin' OR login = 'root' and su = 1" | tail -1` 
    267278if [ "$HAS_ROOT" != "1" ]; then 
    268279    echo "Creating admin user..." 
  • alternc/trunk/install/mysql.sh

    r2059 r2117  
    1 #!/bin/sh  
     1#!/bin/sh 
    22# 
    33# $Id: mysql.sh,v 1.11 2006/01/11 22:51:28 anarcat Exp $ 
     
    2929# ---------------------------------------------------------------------- 
    3030# 
    31  
    32 sqlserver="$1" 
    33 rootlogin="$2" 
    34 rootpass="$3" 
    35 systemdb="$4" 
    36  
    37 if [ -z "$rootlogin" -o -z "$rootpass" -o -z "$systemdb" ] 
    38 then 
    39     echo "Usage: mysql.sh <mysqlserver> <rootlogin> <rootpass> <systemdb>" 
    40     exit 1 
    41 fi 
    42  
    43 mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf -h$sqlserver " 
     31  
     32# This script expects the following environment to exist: 
     33# * host 
     34# * user 
     35# * password 
     36# * database 
     37#  
     38# XXX: the sed script should be generated here 
     39# 
     40# So this file should generally be sourced like this: 
     41# . /usr/share/alternc/install/mysql.sh 
     42# 
     43# Those values are used to set the username/passwords... 
    4444 
    4545# The grant all is the most important right needed in this script. 
     46echo "Granting users..." 
     47# cat <<EOF 
     48# host: $host 
     49# user: $user 
     50# password: $password 
     51# database: $database 
     52# EOF 
     53 
     54MYSQL_CONFIG="/etc/alternc/my.cnf" 
     55 
     56. /etc/alternc/local.sh 
     57# the purpose of this "grant" is to make sure that the generated my.cnf works 
     58# this means (a) creating the user and (b) creating the database 
     59grant="GRANT ALL ON *.* TO '$user'@'${MYSQL_CLIENT}' IDENTIFIED BY '$password' WITH GRANT OPTION; 
     60CREATE DATABASE IF NOT EXISTS $database;" 
     61 
     62echo -n "Trying debian.cnf: " 
     63mysql="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf" 
    4664# If this call fail, we may be connected to a mysql-server version 5.0. 
    47 echo "Granting users " 
    48 # In that case, change mysql parameters and retry. Use root / nopassword. 
    49 $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 
    50 if [ "$?" -ne "0" ] 
     65# In that case, change mysql parameters and retry. Use root / nopassword. 
     66if ! $mysql <<EOF 
     67$grant 
     68EOF 
    5169then 
    52     echo "debian-sys-maintainer doesn't have the right credentials, assuming we're doing an upgrade" 
    53     mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass"  
    54     $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 
    55     if [ "$?" -ne "0" ]  
    56         then  
    57         echo "Still not working, assuming clean install and empty root password" 
    58         mysql="/usr/bin/mysql -h$sqlserver -uroot " 
    59         $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'${MYSQL_CLIENT}' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 
    60         if [ "$?" -ne "0" ]  
     70    echo "failed: debian-sys-maintainer doesn't have the right credentials" 
     71    echo -n "are we doing an upgrade? " 
     72    mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG" 
     73    if ! $mysql <<EOF 
     74$grant 
     75EOF 
     76    then  
     77        echo "No" 
     78        echo -n "Assuming clean install (empty root password)... " 
     79        mysql="/usr/bin/mysql -h$host -uroot " 
     80        if ! $mysql <<EOF 
     81$grant 
     82EOF 
    6183        then  
    62             echo "Can't grant system user $rootlogin, aborting";  
    63             exit 1  
     84            echo "Failed" 
     85            echo -n "Assuming pre 0.9.8 version... " 
     86            mysql="/usr/bin/mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS" 
     87            if ! $mysql <<EOF 
     88$grant 
     89EOF 
     90            then 
     91                echo "No." 
     92                echo "Can't grant system user $user, aborting";  
     93                exit 1  
     94            fi 
    6495        fi 
    6596    fi 
    6697fi 
     98echo "ok!" 
    6799 
    68 # Now we can use rootlogin and rootpass.  
    69 mysql="/usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass"  
     100if [ -f $MYSQL_CONFIG ]; then 
     101    echo "Updating mysql configuration in $MYSQL_CONFIG" 
     102else 
     103    echo "Creating mysql configuration in $MYSQL_CONFIG" 
     104    cat > $MYSQL_CONFIG <<EOF 
     105# AlternC - Web Hosting System - MySQL Configuration 
     106# Automatically generated by AlternC configuration, do not edit 
     107# This file will be modified on package configuration 
     108# (e.g. upgrade or dpkg-reconfigure alternc) 
     109[client] 
     110EOF 
     111    chown root:www-data $MYSQL_CONFIG 
     112    chmod 640 $MYSQL_CONFIG 
     113fi 
    70114 
    71 echo "Setting AlternC '$systemdb' system table and privileges " 
    72 $mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;"  
     115# create a sed script to create/update the file 
     116function set_value() { 
     117    var=$1 
     118    RET=$2 
     119    grep -Eq "^ *$var=" $MYSQL_CONFIG || echo "$var=" >> $MYSQL_CONFIG 
     120    SED_SCRIPT="$SED_SCRIPT;s\\^ *$var=.*\\$var=\"$RET\"\\" 
     121} 
    73122 
    74 echo "Installing AlternC schema " 
    75 $mysql $systemdb < /usr/share/alternc/install/mysql.sql 
     123SED_SCRIPT="" 
     124# hostname was empty in older (pre-0.9.6?) versions 
     125if [ -z "$host" ]; then 
     126    host="localhost" 
     127fi 
     128set_value host $host 
     129set_value database $database 
     130set_value user $user 
     131set_value password $password 
    76132 
    77 /usr/bin/mysql -h$sqlserver -u$rootlogin -p$rootpass $systemdb -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" 
     133# take extra precautions here with the mysql password: 
     134# put the sed script in a temporary file 
     135SED_SCRIPT_NAME=`mktemp` 
     136cat > $SED_SCRIPT_NAME <<EOF 
     137$SED_SCRIPT 
     138EOF 
     139sed -f "$SED_SCRIPT_NAME" < $MYSQL_CONFIG > $MYSQL_CONFIG.$$ 
     140mv -f $MYSQL_CONFIG.$$ $MYSQL_CONFIG 
     141rm -f $SED_SCRIPT_NAME 
     142 
     143# Now we should be able to use the mysql configuration 
     144mysql="/usr/bin/mysql --defaults-file=$MYSQL_CONFIG" 
     145 
     146echo "Checking for MySQL connectivity" 
     147$mysql -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!" 
     148 
     149# Final mysql setup: db schema 
     150echo "installing AlternC schema in $database..." 
     151$mysql < /usr/share/alternc/install/mysql.sql || echo cannot load database schema 
     152 
  • alternc/trunk/install/upgrade_check.sh

    r1798 r2117  
    4646                  case "$ext" in 
    4747                  sql) 
    48                         mysql -f -h $MYSQL_HOST -u $MYSQL_USER -p$MYSQL_PASS $MYSQL_DATABASE \ 
     48                        mysql -f --defaults-file=/etc/alternc/my.cnf \ 
    4949                        < $file || true 
    5050                        ;; 
  • alternc/trunk/src/basedir_prot.sh

    r1922 r2117  
    1818. /etc/alternc/local.sh 
    1919. /usr/lib/alternc/functions.sh 
    20  
    21 if [ -z "$MYSQL_HOST" ] 
    22 then 
    23     MYSQL_HOST="localhost" 
    24 fi 
    2520 
    2621echo -n "adding open_base_dir protection for:" 
  • alternc/trunk/src/fixperms.sh

    r1646 r2117  
    6464} 
    6565 
    66 mysql -h"$MYSQL_HOST" -p"$MYSQL_PASS" -u"$MYSQL_USER" "$MYSQL_DATABASE" -B -e "select uid,login from membres" |grep -v ^uid|doone 
     66mysql --defaults-file=/etc/alternc/my.cnf -B -e "select uid,login from membres" |grep -v ^uid|doone 
    6767 
  • alternc/trunk/src/functions.sh

    r2050 r2117  
    310310                # implantons localement ce que nous avons besoin, puisque admintools 
    311311                # n'est pas là 
    312                 mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -B -N -e \ 
     312                mysql --defaults-file=/etc/alternc/my.cnf -B -N -e \ 
    313313                'SELECT a.login FROM membres a, sub_domaines b WHERE a.uid = b.compte AND \ 
    314314                CONCAT(IF(sub="", "", CONCAT(sub, ".")), domaine) = "'"$1"'" LIMIT 1;' 
  • alternc/trunk/src/sqlbackup.sh

    r1796 r2117  
    2929 
    3030set -e 
    31  
    32 # Get mysql user and password :  
    33 . /etc/alternc/local.sh 
    3431 
    3532function dobck { 
     
    6461              "${target_dir}/${db}.sql.${i}${ext}" 2>/dev/null || true  
    6562        if [ "$compressed" -eq 1 ]; then 
    66             mysqldump -h"$MYSQL_HOST" -u"$login" -p"$pass" "$db" --add-drop-table --allow-keywords -Q -f -q -a -e | 
     63            mysqldump --defaults-file=/etc/alternc/my.cnf --add-drop-table --allow-keywords -Q -f -q -a -e | 
    6764                gzip -c > "${target_dir}/${db}.sql${ext}" 
    6865        else 
    69             mysqldump -h"$MYSQL_HOST" -u"$login" -p"$pass" "$db" --add-drop-table --allow-keywords -Q -f -q -a -e \ 
     66            mysqldump --defaults-file=/etc/alternc/my.cnf --add-drop-table --allow-keywords -Q -f -q -a -e \ 
    7067                > "${target_dir}/${db}.sql" 
    7168        fi 
     
    8481fi 
    8582 
    86 /usr/bin/mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" \ 
    87     "$MYSQL_DATABASE" -B << EOF | tail -n '+2' | dobck 
     83/usr/bin/mysql --defaults-file=/etc/alternc/my.cnf -B << EOF | tail -n '+2' | dobck 
    8884SELECT login, pass, db, bck_history, bck_gzip, bck_dir 
    8985  FROM db 
  • alternc/trunk/src/update_domains.sh

    r1993 r2117  
    7575. "$CONFIG_FILE" 
    7676 
    77 if [ -z "$MYSQL_HOST" -o -z "$MYSQL_DATABASE" -o -z "$MYSQL_USER" -o \ 
    78      -z "$MYSQL_PASS" -o -z "$DEFAULT_MX" -o -z "$PUBLIC_IP" ]; then 
     77if [ -z "$DEFAULT_MX" -o -z "$PUBLIC_IP" ]; then 
    7978    echo "Bad configuration. Please use:" 
    8079    echo "   dpkg-reconfigure alternc" 
     
    9796HTML_HOME="$DATA_ROOT/html" 
    9897 
    99 MYSQL_SELECT="mysql -h${MYSQL_HOST} -u${MYSQL_USER} 
    100                     -p${MYSQL_PASS} -Bs ${MYSQL_DATABASE}" 
    101 MYSQL_DELETE="mysql -h${MYSQL_HOST} -u${MYSQL_USER} 
    102                     -p${MYSQL_PASS} ${MYSQL_DATABASE}" 
     98MYSQL_SELECT="mysql --defaults-file=/etc/alternc/my.cnf -Bs " 
     99MYSQL_DELETE="mysql --defaults-file=/etc/alternc/my.cnf " 
    103100 
    104101######################################################################## 
  • alternc/trunk/tools/get_account_by_domain

    r877 r2117  
    7676# Have to get AlternC conf file : 
    7777! [ -f "$ALTERNC_CONF_FILE" ] && { echo $MISSING_CONF_FILE ; exit 1 ; } || . $ALTERNC_CONF_FILE 
    78 # Must have access to mysql to retreive accounts owning domains : 
    79 [ -z "$MYSQL_HOST" ] && MYSQL_HOST=localhost 
    80 $mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -e "select count(*) from domaines_standby;" > /dev/null 2>&1 
    81 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } || mysql="$mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -B -N -e " 
     78mysql="$mysql --defaults-file=/etc/alternc/my.cnf" 
     79$mysql -e "select count(*) from domaines_standby;" > /dev/null 2>&1 
     80[ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } 
    8281 
    8382# Does the stuff 
    84 $mysql "select concat(a.login, \" (\", a.mail, \")\") from membres a, sub_domaines b where a.uid = b.compte and concat(if(sub=\"\", \"\", concat(sub, \".\")), domaine)  = \"${1}\";" 
     83$mysql -B -N -e "select concat(a.login, \" (\", a.mail, \")\") from membres a, sub_domaines b where a.uid = b.compte and concat(if(sub=\"\", \"\", concat(sub, \".\")), domaine)  = \"${1}\";" 
    8584 
    8685 
  • alternc/trunk/tools/get_domains_by_account

    r877 r2117  
    7575! [ -f "$ALTERNC_CONF_FILE" ] && { echo $MISSING_CONF_FILE ; exit 1 ; } || . $ALTERNC_CONF_FILE 
    7676# Must have access to mysql to retreive accounts owning domains : 
    77 [ -z "$MYSQL_HOST" ] && MYSQL_HOST=localhost 
    78 $mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -e "select count(*) from domaines_standby;" > /dev/null 2>&1 
    79 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } || mysql="$mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -B -N -e " 
     77mysql="$mysql --defaults-file=/etc/alternc/my.cnf -B -N -e" 
     78$mysql "select count(*) from domaines_standby;" > /dev/null 2>&1 
     79[ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } 
    8080 
    8181# Does the stuff 
  • alternc/trunk/tools/top_http_users

    r1605 r2117  
    169169[ -f "$ALTERNC_CONF_FILE" ] || { echo $MISSING_CONF_FILE ; exit 1 ; } && . $ALTERNC_CONF_FILE 
    170170# Must have access to mysql to retreive accounts owning domains : 
    171 [ -z "$MYSQL_HOST" ] && MYSQL_HOST=localhost 
    172 $mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -e "select count(*) from domaines_standby;" > /dev/null 2>&1 
    173 [ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } || mysql="$mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS -D$MYSQL_DATABASE -B -N -e " 
    174  
     171mysql="$mysql --defaults-file=/etc/alternc/my.cnf -B -N -e" 
     172$mysql "select count(*) from domaines_standby;" > /dev/null 2>&1 
     173[ "$?" != 0 ] && { echo "$MYSQL_UNREACHABLE_DATABASE" ; exit 1 ; } 
    175174# Prevents executing more than one shell at the same time 
    176175$lockfilecreate --retry 1 $LOCK_FILE 
Note: See TracChangeset for help on using the changeset viewer.