|
Revision 2117, 3.4 kB
(checked in by anarcat, 9 months ago)
|
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/ksh |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
PATH="" |
|---|
| 31 |
PROG_NAME=get_domains_by_account |
|---|
| 32 |
PROG_VERSION=0.1.0 |
|---|
| 33 |
ALTERNC_ETC=/etc/alternc |
|---|
| 34 |
ALTERNC_CONF_FILE=$ALTERNC_ETC/local.sh |
|---|
| 35 |
export TEXTDOMAIN=alternc-admintools |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
id=/usr/bin/id |
|---|
| 41 |
mysql=/usr/bin/mysql |
|---|
| 42 |
gettext=/usr/bin/gettext |
|---|
| 43 |
printf=/usr/bin/printf |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
[ -x "$gettext" ] || { echo "Cannot execute $gettext"; exit 1 ; } |
|---|
| 47 |
|
|---|
| 48 |
for i in $id $mysql $printf |
|---|
| 49 |
do |
|---|
| 50 |
! [ -x "$i" ] && { echo "$($gettext "Unable to execute") ${i}."; exit 1 ; } |
|---|
| 51 |
done |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
HELP=$($gettext "Gives domains and sub-domains attached to an account.") |
|---|
| 57 |
USAGE=`$printf "$($gettext "Usage: %s account.")" $PROG_NAME` |
|---|
| 58 |
NOT_FOUND_MSG=$($gettext "does not exist.") |
|---|
| 59 |
NON_ROOT_MSG=$($gettext "You have to be root (uid 0) to execute this program.") |
|---|
| 60 |
MISSING_PROG=$($gettext "Unable to execute") |
|---|
| 61 |
MISSING_CONF_FILE=`$printf "$($gettext "Can't find %s. Are you sure AlterncC is properly installed?")" $ALTERNC_CONF_FILE` |
|---|
| 62 |
MYSQL_UNREACHABLE_DATABASE=`$printf "$($gettext "Cannot access accounts database. Please check either %s or Mysql state.")" $ALTERNC_CONF_FILE` |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
[ "`$id -u`" != "0" ] && { echo $NON_ROOT_MSG ; exit 1 ; } |
|---|
| 70 |
|
|---|
| 71 |
[ -z "$1" ] && { echo $USAGE ; exit 1 ; } |
|---|
| 72 |
|
|---|
| 73 |
[ "$1" = "-h" ] || [ "$1" = "--help" ] && { echo $HELP ; echo $USAGE ; exit 0 ; } |
|---|
| 74 |
|
|---|
| 75 |
! [ -f "$ALTERNC_CONF_FILE" ] && { echo $MISSING_CONF_FILE ; exit 1 ; } || . $ALTERNC_CONF_FILE |
|---|
| 76 |
|
|---|
| 77 |
mysql="$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 ; } |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
$mysql "select concat(a.sub, if(a.sub=\"\",\"\", \".\"), a.domaine) from sub_domaines a, membres b where a.compte = b.uid and b.login = \"${1}\";" |
|---|
| 83 |
|
|---|
| 84 |
|
|---|