Ignore:
Timestamp:
04/26/06 18:29:45 (8 years ago)
Author:
nahuel
Message:

Correction d'un bug qui empechait la modification des droits sur l'utilisateur n'avait aucun droit.
References: #265

File:
1 edited

Legend:

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

    r1531 r1535  
    295295  /* ----------------------------------------------------------------- */ 
    296296  /** Restore a sql backup script on a user's database. 
    297    */ 
    298   function restore($file,$stdout,$id) { 
     297   * <b>TODO : </b> Add a parameter to choose which database to restore. 
     298   */ 
     299  function restore($file,$stdout,$r) { 
    299300    global $err,$bro,$mem,$L_MYSQL_HOST; 
    300     if (!$r=$this->get_mysql_details($id)) { 
    301       return false; 
    302     } 
    303301    if (!($fi=$bro->convertabsolute($file,0))) { 
    304302      $err->raise("mysql",9); 
    305       return false; 
    306303    } 
    307304    if (substr($fi,-3)==".gz") { 
    308       $exe="/bin/gzip -d -c <".escapeshellarg($fi)." | /usr/bin/mysql -h".escapeshellarg($L_MYSQL_HOST)." -u".escapeshellarg($r["login"])." -p".escapeshellarg($r["pass"])." ".escapeshellarg($r["db"]); 
    309     } elseif (substr($fi,-4)==".bz2") { 
    310       $exe="/bin/bunzip2 -d -c <".escapeshellarg($fi)." | /usr/bin/mysql -h".escapeshellarg($L_MYSQL_HOST)." -u".escapeshellarg($r["login"])." -p".escapeshellarg($r["pass"])." ".escapeshellarg($r["db"]); 
     305      $exe="/bin/gzip -d -c <\"$fi\" | /usr/bin/mysql -h".$L_MYSQL_HOST." -u".$r["login"]." -p".$r["pass"]." ".$r["db"]; 
    311306    } else { 
    312       $exe="/usr/bin/mysql -h".escapeshellarg($L_MYSQL_HOST)." -u".escapeshellarg($r["login"])." -p".escapeshellarg($r["pass"])." ".escapeshellarg($r["db"])." <".escapeshellarg($fi); 
     307      $exe="/usr/bin/mysql -h".$L_MYSQL_HOST." -u".$r["login"]." -p".$r["pass"]." ".$r["db"]." <".$fi; 
    313308    } 
    314309    $exe .= " 2>&1"; 
     
    336331 function get_db_size($dbname) { 
    337332   global $db,$err; 
     333 
    338334   $db->query("SHOW TABLE STATUS FROM `$dbname`;"); 
    339335   $size = 0; 
     
    495491 
    496492    // Ok, database exists and dbname is compliant. Let's proceed 
    497     $db->query("USE mysql"); 
    498493    $db->query("REVOKE ALL PRIVILEGES ON *.* FROM '".$mem->user["login"]."_$user'@'$this->client';"); 
    499     $db->query("DELETE FROM db WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
    500     $db->query("DELETE FROM user WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
     494    $db->query("DELETE FROM mysql.db WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
     495    $db->query("DELETE FROM mysql.user WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
    501496    $db->query("FLUSH PRIVILEGES"); 
    502     $db->query("USE $L_MYSQL_DATABASE"); 
    503497    $db->query("DELETE FROM dbusers WHERE uid='$cuid' AND name='".$mem->user["login"]."_$user';"); 
    504498    return true; 
     
    512506    $dblist=$this->get_dblist(); 
    513507 
    514     $db->query("USE mysql;"); 
    515508    for ( $i=0 ; $i<count($dblist) ; $i++ ) { 
    516       $db->query("SELECT Db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv FROM db WHERE User='".$mem->user["login"].($user?"_":"").$user."' AND Host='$this->client' AND Db='".$dblist[$i]["db"]."';"); 
     509      $db->query("SELECT Db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv FROM mysql.db WHERE User='".$mem->user["login"].($user?"_":"").$user."' AND Host='$this->client' AND Db='".$dblist[$i]["db"]."';"); 
    517510      if ($db->next_record()) 
    518511        $r[]=array("db"=>$dblist[$i]["name"], "select"=>$db->f("Select_priv"), "insert"=>$db->f("Insert_priv"), "update"=>$db->f("Update_priv"), "delete"=>$db->f("Delete_priv"), "create"=>$db->f("Create_priv"), "drop"=>$db->f("Drop_priv"), "references"=>$db->f("References_priv"), "index"=>$db->f("Index_priv"), "alter"=>$db->f("Alter_priv"), "create_tmp"=>$db->f("Create_tmp_table_priv"), "lock"=>$db->f("Lock_tables_priv")); 
     
    520513        $r[]=array("db"=>$dblist[$i]["name"], "select"=>"N", "insert"=>"N", "update"=>"N", "delete"=>"N", "create"=>"N", "drop"=>"N", "references"=>"N", "index"=>"N", "alter"=>"N", "Create_tmp"=>"N", "lock"=>"N" ); 
    521514    } 
    522     $db->query("FLUSH PRIVILEGES"); 
    523     $db->query("USE $L_MYSQL_DATABASE"); 
    524515 
    525516    return $r; 
     
    572563     
    573564    // On remet à zéro tous les droits de l'utilisateur 
    574     $db->query("REVOKE ALL PRIVILEGES ON *.* FROM '$usern'@'$this->client';"); 
     565    $db->query("SELECT * FROM mysql.db WHERE User = '$usern' AND Db = '$dbname';"); 
     566    if($db->num_rows()) 
     567      $db->query("REVOKE ALL PRIVILEGES ON $dbname.* FROM '$usern'@'$this->client';"); 
    575568    if( $strrights ){ 
    576569      $strrights=substr($strrights,0,strlen($strrights)-1); 
    577570      $db->query("GRANT $strrights ON $dbname.* TO '$usern'@'$this->client';");       
    578571    } 
     572    $db->query("FLUSH PRIVILEGES"); 
    579573    return TRUE; 
    580574  } 
Note: See TracChangeset for help on using the changeset viewer.