X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Ffunctions_setup.inc;h=7d41ffd9586ea098f34505e041639ae356a5199a;hb=4ef5a0ec2c799536446dd29d5d828488cc14608f;hp=cabcbbdb1c9128883b402e4fe900c3d2757a03c0;hpb=3e55208d7fa8bb18218a52fedbfd53403f06ab55;p=gosa.git diff --git a/include/functions_setup.inc b/include/functions_setup.inc index cabcbbdb1..7d41ffd95 100644 --- a/include/functions_setup.inc +++ b/include/functions_setup.inc @@ -30,9 +30,9 @@ function view_schema_check($table) } -function is_schema_readable($server, $admin, $password) +function is_schema_readable($server, $admin, $password, $follow_referrals=FALSE, $tls=FALSE) { - $ldap = new LDAP($admin,$password,$server); + $ldap = new LDAP($admin, $password, $server, $follow_referrals, $tls); $tmp = $ldap->get_objectclasses(); if(count($tmp)){ @@ -41,7 +41,7 @@ function is_schema_readable($server, $admin, $password) return(false); } -function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false) +function schema_check($server, $admin, $password, $follow_referrals=FALSE, $tls=FALSE, $aff=0, $CalledByIndexPhP=false) { global $config; @@ -78,7 +78,7 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false ); /* Get objectclasses */ - $ldap = new LDAP($admin,$password, $server); + $ldap = new LDAP($admin,$password, $server, $follow_referrals, $tls); $objectclasses = $ldap->get_objectclasses(); if(count($objectclasses) == 0){ return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE))); @@ -338,6 +338,7 @@ function get_link($function_name) { $result= "=1.1.2)"), + _("GraphicsMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."), + ($major > 1 || ($major == 1 && $minor >= 1) || ($major == 1 && $minor == 1 && $minor2 >= 2) ) ); + } else { + $msg.= check ( $faults, _("Checking for ImageMagick (>=5.4.0)"), + _("ImageMagick is used to convert user supplied images to fit the suggested size and the unified JPEG format."), + ($major > 5 || ($major == 5 && $minor >= 4))); + } } else { $msg.= check ( $faults, _("Checking imagick module for PHP"), _("Imagick is used to convert user supplied images to fit the suggested size and the unified JPEG format from PHP script."), function_exists('imagick_blob2image'), TRUE); @@ -622,11 +630,14 @@ function parse_contrib_conf() /* Show setup_page 1 */ function show_setup_page1($withoutput = true) { - $faults = array(); + $faults = false; + $faults2 = false; $smarty = get_smarty(); $smarty->assign ("content", get_template_path('setup_introduction.tpl')); $smarty->assign ("tests", perform_php_checks($faults)); - $smarty->assign ("detailed_tests", perform_additional_function_checks($faults)); + $smarty->assign ("detailed_tests", perform_additional_function_checks($faults2)); + + $faults = $faults || $faults2; /* This var is true if anything went wrong */ if ($faults){ @@ -646,14 +657,14 @@ function show_setup_page1($withoutput = true) $smarty->display (get_template_path('setup.tpl')); } - return (!$faults); + return ($faults); } /* Show setup_page 2 */ function show_setup_page2($withoutput = true) { - $faults = array(); + $faults = false; $smarty = get_smarty(); $smarty->assign ("content", get_template_path('setup_step2.tpl')); $smarty->assign ("tests", perform_additional_checks($faults)); @@ -671,7 +682,7 @@ function show_setup_page2($withoutput = true) $smarty->display (get_template_path('setup.tpl')); } - return (!$faults); + return ($faults); } @@ -701,18 +712,7 @@ function show_setup_page3($withoutput = true) /* No error till now */ $fault = false; - /* If we pushed the Button continue */ - if(isset($_POST['continue3'])){ - if(!isset($uri)) { - $fault = true; - - /* Output the Error */ - if($withoutput) { - print_red (_("You've to specify an ldap server before continuing!")); - $smarty->assign ("content", get_template_path('setup_step3.tpl')); - } - } - } elseif (!$ds = @ldap_connect (validate($uri))) { + if (!$ds = @ldap_connect (validate($uri))) { $fault =true; /* Output the Error */ @@ -757,13 +757,49 @@ function show_setup_page3($withoutput = true) $smarty->display (get_template_path('setup.tpl')); } - return (!$fault); + return ($fault); } function show_setup_page4($withoutput = true) { $smarty= get_smarty(); + $checkvars = array("location", "admin", "password", "peopleou", "base", + "peopledn", "arr_crypts", "uidbase","errorlvl"); + + $fault = false; + $uri = $_SESSION['ldapconf']['uri']; + $ldapconf = $_SESSION['ldapconf']; + $arr_crypts= array(); + $temp = ""; + + /* check POST data */ + if(isset($_POST['check'])) { + + /* Check if all needed vars are submitted */ + foreach($checkvars as $key) { + if($key == "peopleou"){ + continue; + } + if($key == "groupou"){ + continue; + } + + if((isset($_POST[$key]))&&(!empty($_POST[$key]))) { + $_SESSION['ldapconf'][$key] = $_POST[$key]; + } else { + if($withoutput) { + print_red(sprintf(_("You're missing the required attribute '%s' from this formular. Please complete!"), $key)); + } + $fault = true; + } + } + } + + /* Transfer base */ + if(isset($_POST['base'])){ + $_SESSION['ldapconf']['base']= $_POST['base']; + } // ? if(!isset($_SESSION['ldapconf']['base'])){ @@ -775,14 +811,6 @@ function show_setup_page4($withoutput = true) } require_once("class_password-methods.inc"); - $fault = false; - $uri = $_SESSION['ldapconf']['uri']; - $ldapconf = $_SESSION['ldapconf']; - $arr_crypts= array(); - $temp = ""; - $checkvars = array("location", "admin", "password", "peopleou", "base", - "peopledn", "arr_crypts", "mail", "uidbase","errorlvl"); - if(!isset($_SESSION['ldapconf']['arr_cryptkeys'])) { require_once("class_password-methods.inc"); $tmp= passwordMethod::get_available_methods_if_not_loaded(); @@ -797,7 +825,7 @@ function show_setup_page4($withoutput = true) /* If there are some empty vars in ldapconnect - these values also represent out default values */ - if(!$ds = @ldap_connect (validate($uri))){ + if(!$ds = @ldap_connect (validate($uri))){ $fault = true; if($withoutput){ print_red (_("Can't connect to the specified LDAP server! Please make sure that is reachable for GOsa.")); @@ -805,22 +833,21 @@ function show_setup_page4($withoutput = true) } elseif(!@ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){ $fault = true; if($withoutput){ - print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa.")); + print_red (_("Can't set ldap protocol version 3.")); } } elseif(!$r= @ldap_bind ($ds)){ $fault = true; if($withoutput){ - print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa.")); + print_red (_("Could not bind to the specified LDAP server! Please make sure that it is reachable for GOsa.")); } } else { - $sr= @ldap_search ($ds, NULL, "objectClass=*", array("namingContexts")); + $sr= @ldap_search ($r, NULL, "objectClass=*", array("namingContexts")); $attr= @ldap_get_entries($ds,$sr); if((empty($attr))) { - $base= "dc=example,dc=net"; if($withoutput){ - print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice")); +# print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice")); } } else { @@ -855,37 +882,16 @@ function show_setup_page4($withoutput = true) if(!isset($_SESSION['ldapconf']['mail'])){ $_SESSION['ldapconf']['mail']= 0; } - $tmp= array_flip($_SESSION['ldapconf']['arr_cryptkeys']); - if(!isset($_SESSION['ldapconf']['arr_crypts'])){ - $_SESSION['ldapconf']['arr_crypts'] = $tmp['md5']; + if(!isset($_SESSION['ldapconf']['follow_referrals'])){ + $_SESSION['ldapconf']['follow_referrals']= FALSE; } - - /* check POST data */ - if(isset($_POST['check'])) { - - /* Check if all needed vars are submitted */ - foreach($checkvars as $key) { - if($key == "peopleou"){ - continue; - } - if($key == "groupou"){ - continue; - } - - if((isset($_POST[$key]))&&($_POST[$key]!="")) { - $_SESSION['ldapconf'][$key] = $_POST[$key]; - } else { - if($withoutput) { - print_red(sprintf(_("You're missing the required attribute '%s' from this formular. Please complete!"), $key)); - } - $fault = true; - } - } + if(!isset($_SESSION['ldapconf']['tls'])){ + $_SESSION['ldapconf']['tls']= FALSE; } - /* Transfer base */ - if(isset($_POST['base'])){ - $_SESSION['ldapconf']['base']= $_POST['base']; + $tmp= array_flip($_SESSION['ldapconf']['arr_cryptkeys']); + if(!isset($_SESSION['ldapconf']['arr_crypts'])){ + $_SESSION['ldapconf']['arr_crypts'] = $tmp['md5']; } $smarty->assign("arr_cryptkeys",$_SESSION['ldapconf']['arr_cryptkeys']); @@ -895,17 +901,25 @@ function show_setup_page4($withoutput = true) $smarty->assign($key,$val); } - if(isset($_POST['check'])) { + if(isset($_POST['check']) || (isset($_POST['admin'])) && isset($_POST['password'])) { $ldap= new LDAP($_SESSION['ldapconf']['admin'], $_SESSION['ldapconf']['password'], - $_SESSION['ldapconf']['uri']); + $_SESSION['ldapconf']['uri'], + $_SESSION['ldapconf']['follow_referrals'], + $_SESSION['ldapconf']['tls']); $m= schema_check($_SESSION['ldapconf']['uri'], $_SESSION['ldapconf']['admin'], - $_SESSION['ldapconf']['password']); + $_SESSION['ldapconf']['password'], + $_SESSION['ldapconf']['follow_referrals'], + $_SESSION['ldapconf']['tls']); + $_SESSION['classes']= $m; - if(!is_schema_readable($ldapconf['uri'],$ldapconf['admin'],$ldapconf['password'])){ + //TODO: Ask user for referrals and TLS config options during setup. They are initialized to false at the moment: + $ldapconf['follow_referrals'] = false; + $ldapconf['tls'] = false; + if(!is_schema_readable($ldapconf['uri'], $ldapconf['admin'], $ldapconf['password'], $ldapconf['follow_referrals'], $ldapconf['tls'])){ if($withoutput){ print_red(_("Can't read schema informations, GOsa needs to know your schema setup. Please verify that it is readable for GOsa")); } @@ -934,7 +948,8 @@ function show_setup_page4($withoutput = true) if($withoutput){ $smarty->display (get_template_path('setup.tpl')); } - return (!$fault); + + return ($fault); } @@ -954,7 +969,12 @@ function show_setup_page5($withoutput=true) $smarty->assign("webgroup", $info['name']); $smarty->assign("path", CONFIG_DIR); $message= ""; - $m= schema_check($ldapconf['uri'], $ldapconf['admin'], $ldapconf['password'],1); + + //TODO:Ask user for referral and TLS config options during setup. They are initialized to false at the moment: + $ldapconf['follow_referrals'] = false; + $ldapconf['tls'] = false; + + $m= schema_check($ldapconf['uri'], $ldapconf['admin'], $ldapconf['password'], $ldapconf['follow_referrals'], $ldapconf['tls'], 1); if($withoutput) { $smarty->assign ("schemas", view_schema_check($m)); @@ -998,69 +1018,48 @@ function create_user_for_setup($withoutput=true) We check that, if this user or group is missing we ask for creating them */ $ldap= new LDAP($_SESSION['ldapconf']['admin'], $_SESSION['ldapconf']['password'], $_SESSION['ldapconf']['uri']); - /* - Now we are testing for a group, with the rights :all - */ - + /* Now we are testing for a group, with the rights :all */ $ldap->cd($ldapconf['base']); $ldap->search("(&(objectClass=gosaObject)(gosaSubtreeACL=:all))"); $group_cnt = $ldap->count(); $data = $ldap->fetch(); -// $str_there = "Searching for Aminitrative users

"; - - /* - We need to create administrative user and group because theres no group found - */ + /* We need to create administrative user and group because there was no group found */ if($group_cnt < 1) { - /* - Set var to create user - */ -// $str_there = "no group found
"; - $need_to_create_group = true; $need_to_create_user = true; - /* Output error */ - if(($withoutput)&&(!isset($_POST['new_admin']))){ - print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!")); - } +# if(($withoutput)&&(!isset($_POST['new_admin']))){ +# print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!")); +# } } else { -// $str_there = "Group found
".$data['dn']; - $need_to_create_group = false; - $ldap->clearResult(); - /* We found an Administrative Group, is there a user, too */ + /* We found an Administrative Group, is there a user too ? */ if(isset($data['memberUid'][0])) { - $str = "uid=".$data['memberUid']['0']; + $str = "uid=".$data['memberUid']['0']; $ldap->search("(&(objectClass=gosaAccount)(objectClass=person)(".$str."))"); - $data2 = $ldap->fetch(); + $data2 = $ldap->fetch(); /* We must create a user */ if (($ldap->count() < 1)||(!isset($data2))) { -// $str_there.="Missing user"; - $need_to_create_user = true; - - if(($withoutput)&&(!isset($_POST['new_admin']))){ - print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!")); - } +# if(($withoutput)&&(!isset($_POST['new_admin']))){ +# print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!")); +# } }else { -// $str_there.="
User found
".$data2['dn']; $need_to_create_user = false; } } else { $need_to_create_user=true; - if(($withoutput)&&(!isset($_POST['new_admin']))){ - print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!")); - } -// $str_there.="
No User found
"; +# if(($withoutput)&&(!isset($_POST['new_admin']))){ +# print_red(_("You're missing an administrative account for GOsa, you'll not be able to administrate anything!")); +# } } } @@ -1110,8 +1109,7 @@ function create_user_for_setup($withoutput=true) $ldap->cd($dn); $ldap->add($arr); if($ldap->error!="Success"){ - print_red($ldap->error); - print_red("Can't create user, and / or Group, possibly this problem depends on an empty LDAP server. Check your configuration and try again!"); + show_ldap_error($ldap->get_error(),_("User and/or group could not be created, please check your configuration twice !")); } } } @@ -1154,7 +1152,7 @@ function create_user_for_setup($withoutput=true) return(true); } else { - if((!isset($create_user))||(!($create_user))) { + if((!isset($need_to_create_user))||(!($need_to_create_user))) { $smarty->assign ("content", get_template_path('setup_useradmin.tpl')); $smarty->assign("exists",true); } else {