Secu: Correction faille permettant d'utiliser les portions non protégée de dolibarr avec un user non défini dans dolibarr.

This commit is contained in:
Laurent Destailleur 2005-03-26 13:38:30 +00:00
parent 57be40e68c
commit 13bc7ee2e7

View File

@ -43,26 +43,27 @@ if (!empty ($_SERVER["REMOTE_USER"]))
{ {
// Authentification Apache OK, on va chercher les infos du user // Authentification Apache OK, on va chercher les infos du user
$user->fetch($_SERVER["REMOTE_USER"]); $user->fetch($_SERVER["REMOTE_USER"]);
}
//print "REMOTE_USER:".$_SERVER["REMOTE_USER"];
//exit;
}
else else
{ {
// Authentification Apache OK ou non active // Authentification Apache KO ou non active
if (!empty ($dolibarr_auto_user)) if (!empty ($dolibarr_auto_user))
{ {
// Mode forcé sur un utilisateur (pour debug, demo, ...)
$user->fetch($dolibarr_auto_user); $user->fetch($dolibarr_auto_user);
} }
else else
{ {
// /usr/share/pear // Pas d'authentification Apache ni de mode forcé, on demande le login
//require_once "Auth/Auth.php";
require_once DOL_DOCUMENT_ROOT."/includes/pear/Auth/Auth.php"; require_once DOL_DOCUMENT_ROOT."/includes/pear/Auth/Auth.php";
$pear = $dolibarr_main_db_type.'://'.$dolibarr_main_db_user.':'.$dolibarr_main_db_pass.'@'.$dolibarr_main_db_host.'/'.$dolibarr_main_db_name; $pear = $dolibarr_main_db_type.'://'.$dolibarr_main_db_user.':'.$dolibarr_main_db_pass.'@'.$dolibarr_main_db_host.'/'.$dolibarr_main_db_name;
$params = array( $params = array(
// "dsn" => $conf->db->getdsn(), "dsn" =>$pear,
"dsn" =>$pear, //$db->getdsn($dolibarr_main_db_type,$dolibarr_main_db_user,$dolibarr_main_db_pass,$dolibarr_main_db_host,$dolibarr_main_db_name),
"table" => MAIN_DB_PREFIX."user", "table" => MAIN_DB_PREFIX."user",
"usernamecol" => "login", "usernamecol" => "login",
"passwordcol" => "pass", "passwordcol" => "pass",
@ -75,21 +76,24 @@ else
if ($result) if ($result)
{ {
// Authentification Auth OK, on va chercher les infos du user // Authentification Auth OK, on va chercher les infos du user
dolibarr_syslog ("auth demarre va chercher les infos du user"); dolibarr_syslog ("auth demarre va chercher les infos du user");
$user->fetch($aDol->getUsername()); $user->fetch($aDol->getUsername());
} }
else else
{ {
/* // Le début de la page a été affiché par loginfunction. On ferme juste la page
* Le début de la page est affiché par
* loginfunction
*/
print "</div>\n</div>\n</body>\n</html>"; print "</div>\n</div>\n</body>\n</html>";
die ; exit;
} }
} }
} }
// Si le login n'a pu être récupéré, on est identifié avec un compte qui n'existe pas.
// Tentative de hacking ?
if (! $user->login) accessforbidden();
if (! defined(MAIN_INFO_SOCIETE_PAYS)) if (! defined(MAIN_INFO_SOCIETE_PAYS))
{ {
define(MAIN_INFO_SOCIETE_PAYS,"1"); define(MAIN_INFO_SOCIETE_PAYS,"1");