Show
Ignore:
Timestamp:
04/13/08 06:35:19 (8 months 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)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 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);