Changeset 1772

Show
Ignore:
Timestamp:
01/13/07 00:03:33 (2 years ago)
Author:
anarcat
Message:

Fix a race condition in update_domaines.sh that could allow users to
bypass open_basedir protections when creating domains. Reported by
jerome.

This required changing basedir_prot's behavior so that it creates the
protection even if the symlink doesn't exist, which might create extra
files that are not necessary, but "better be safe than sorry". We
could also fix this in a subsequent release.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • alternc/trunk/debian/changelog

    r1768 r1772  
    66  * Make it possible to erase files and directories in file browser. Closes: #1002. 
    77  * Fix mail accounts creation. Closes: #1003. 
     8  * Fix a race condition in update_domains.sh which could allow users to 
     9    bypass openbasedir protection when creating domains. Reported by  
     10    Jerome Moinet. 
    811 
    912 -- Antoine Beaupré <anarcat@koumbit.org>  Fri, 12 Jan 2007 15:59:42 -0500 
  • alternc/trunk/src/basedir_prot.sh

    r912 r1772  
    9494                    dom="/var/alternc/dns/$initial_domain/$i" 
    9595                fi 
    96                 if [ -e "$dom" ]; then 
    97                         doms="$doms $dom" 
    98                 else 
    99                         echo skipping non-existent domain "$dom" >&2 
    100                 fi 
     96                doms="$doms $dom" 
    10197        done 
    10298else 
  • alternc/trunk/src/update_domains.sh

    r1672 r1772  
    124124add_to_php_override() { 
    125125    local fqdn="$1" 
    126     local escaped_fqdn=`echo "$fqdn" | sed 's/\([\*|\.]\)/\\\\\1/g'` 
    127  
    128     if ! grep -q "^${escaped_fqdn}$" "$CHANGED_PHP_OVERRIDES_TMP_FILE"; then 
    129         echo "$fqdn" >> "$CHANGED_PHP_OVERRIDES_TMP_FILE" 
    130     fi 
     126 
     127    /usr/lib/alternc/basedir_prot.sh "$fqdn" >> "$DOMAIN_LOG_FILE" 
     128
     129 
     130remove_php_override() { 
     131    local fqdn="$1" 
     132    local letter=`print_domain_letter $fqdn` 
     133 
     134    sed -i "/$fqdn/d" $APACHECONF_DIR/override_php.conf 
     135    rm -f $APACHECONF_DIR/$letter/$fqdn 
    131136} 
    132137 
     
    236241    delete_host "$domain" "$host" 
    237242 
     243    if [ "$host" = "@" -o -z "$host" ]; then 
     244        FQDN="$domain" 
     245    else 
     246        FQDN="$host.$domain" 
     247    fi 
     248    if [ "$host_type" != "$TYPE_IP" ]; then 
     249        add_to_php_override "$FQDN" 
     250    fi 
     251 
    238252    if [ "$host_type" = "$TYPE_IP" ]; then 
    239253       ip="$value" 
     
    395409HOSTS_TMP_FILE=`mktemp -t alternc.update_domains.XXXXXX` 
    396410RELOAD_ZONES_TMP_FILE=`mktemp -t alternc.update_domains.XXXXXX` 
    397 CHANGED_PHP_OVERRIDES_TMP_FILE=`mktemp -t alternc.update_domains.XXXXXX` 
    398411 
    399412cleanup() { 
    400413    rm -f "$LOCK_FILE" "$DOMAINS_TMP_FILE" "$HOSTS_TMP_FILE" 
    401     rm -f "$RELOAD_ZONES_TMP_FILE" "$CHANGED_PHP_OVERRIDES_TMP_FILE" 
     414    rm -f "$RELOAD_ZONES_TMP_FILE" 
    402415    exit 0 
    403416} 
     
    450463    USER_LETTER=`print_user_letter "$user"` 
    451464 
    452     add_to_php_override "$domain" 
    453     add_to_php_override "www.$domain" 
    454  
    455465    case "$action" in 
    456466      $ACTION_INSERT) 
     
    500510    IFS="$OLD_IFS" 
    501511 
    502     if [ "$host" = "@" -o -z "$host" ]; then 
    503         FQDN="$domain" 
    504     else 
    505         FQDN="$host.$domain" 
    506     fi 
    507     if [ "$type" != "$TYPE_IP" ]; then 
    508         add_to_php_override "$FQDN" 
    509     fi 
    510  
    511512    case "$action" in 
    512513      $ACTION_UPDATE | $ACTION_INSERT) 
     
    526527done < "$HOSTS_TMP_FILE" 
    527528IFS="$OLD_IFS" 
    528  
    529 # Update PHP overrides (basedir protection) 
    530 for domain in `cat "$CHANGED_PHP_OVERRIDES_TMP_FILE"`; do 
    531     /usr/lib/alternc/basedir_prot.sh "$domain" >> "$DOMAIN_LOG_FILE" 
    532 done 
    533529 
    534530# Reload configuration for named and apache