Code

Added external resolution hook to environment
[gosa.git] / include / functions_setup.inc
index b27ff74ac877434b2a9a88010b1b8a8ac101b26d..cabcbbdb1c9128883b402e4fe900c3d2757a03c0 100644 (file)
@@ -32,28 +32,13 @@ function view_schema_check($table)
 
 function is_schema_readable($server, $admin, $password)
 {
-  $ds= ldap_connect ($server);
-  if (!$ds) {
-    return (false);
-  }
-  ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
-  $r= ldap_bind ($ds, $admin, $password);
-
-  /* Get base to look for schema */
-  $sr  = @ldap_read ($ds, "", "objectClass=*", array("subschemaSubentry"));
-  $attr= @ldap_get_entries($ds,$sr);
-  if (!isset($attr[0]['subschemasubentry'][0])){
-    return (false);
-  }
+  $ldap = new LDAP($admin,$password,$server);
+  $tmp = $ldap->get_objectclasses();
 
-  $nb= $attr[0]['subschemasubentry'][0];
-  $objectclasses= array();
-  $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
-  $attrs= ldap_get_entries($ds,$sr);
-  if (!isset($attrs[0])){
-    return (false);
+  if(count($tmp)){
+    return(true);
   }
-  return(true);
+  return(false);
 } 
 
 function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false)
@@ -78,8 +63,8 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false
       "gosaApplication"       => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
       "gosaApplicationGroup"  => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"),
 
-      "GOhard"                => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
-      "gotoTerminal"          => array("version" => "2.0", "class" => "terminals","file" => "goto.schema"),
+      "GOhard"                => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
+      "gotoTerminal"          => array("version" => "2.5", "class" => "terminals","file" => "goto.schema"),
       "goServer"              => array("version" => "2.4","class" => "server","file" => "goserver.schema"),
       "goTerminalServer"      => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
       "goShareServer"           => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"),
@@ -92,35 +77,13 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false
       "goFaxServer"           => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"),
       );
 
-  /* Build LDAP connection */
-  $ds= ldap_connect ($server);
-  if (!$ds) {
-    return (array(array("msg" => _("Can't bind to LDAP. No schema check possible!"), "status" => FALSE)));
-  }
-  ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
-  $r= ldap_bind ($ds, $admin, $password);
-
-  /* Get base to look for schema */
-  $sr  = @ldap_read ($ds, "", "objectClass=*", array("subschemaSubentry"));
-  $attr= @ldap_get_entries($ds,$sr);
-  if (!isset($attr[0]['subschemasubentry'][0])){
+  /* Get objectclasses */
+  $ldap = new LDAP($admin,$password, $server);
+  $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)));
   }
 
-  /* Get list of objectclasses */
-  $nb= $attr[0]['subschemasubentry'][0];
-  $objectclasses= array();
-  $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses"));
-  $attrs= ldap_get_entries($ds,$sr);
-  if (!isset($attrs[0])){
-    return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE)));
-  }
-  foreach ($attrs[0]['objectclasses'] as $val){
-    $name= preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val);
-    if ($name != $val){
-      $objectclasses[$name]= $val;
-    }
-  }
   /* Walk through objectclasses and check if they are needed or not */
   foreach ($required_classes as $key => $value){
     if (isset($value['class'])){
@@ -216,6 +179,16 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false
     $affich['phpgroupware']['msg']= _("Support for phpgroupware enabled")."<td class=\"check\">phpgwaccount.schema</td>";
     $affich['phpgroupware']['status']= TRUE;
   }
+  
+  if (!isset($objectclasses['trustAccount'])){
+    $messages['trustAccount']['msg']= _("Support for trustAccount disabled, no schema seems to be installed");
+    $affich['trustAccount']['msg']= $messages['trustAccount']['msg']."<td class=\"check\">trust.schema</td>";
+    $messages['trustAccount']['status']= FALSE;
+    $affich['trustAccount']['status']= FALSE;
+  }else{
+    $affich['trustAccount']['msg']= _("Support for trustAccount enabled")."<td class=\"check\">trust.schema</td>";
+    $affich['trustAccount']['status']= TRUE;
+  }
 
   if (!isset($objectclasses['goFonAccount'])){
     $messages['phoneaccount']['msg']= _("Support for gofon disabled, no schema seems to be installed");
@@ -226,6 +199,26 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false
     $affich['phoneaccount']['msg']= _("Support for gofon enabled")."<td class=\"check\">gofon.schema</td>";
     $affich['phoneaccount']['status']= true;
   }
+
+  if (!isset($objectclasses['nagiosContact'])){
+    $messages['nagioscontact']['msg']= _("Support for nagios disabled, no schema seems to be installed");
+    $affich['nagioscontact']['msg']= $messages['nagioscontact']['msg']."<td class=\"check\">nagios.schema</td>";
+    $messages['nagioscontact']['status']= FALSE;
+    $affich['nagioscontact']['status']= FALSE;
+  }else{
+    $affich['nagioscontact']['msg']= _("Support for nagios enabled")."<td class=\"check\">nagios.schema</td>";
+    $affich['nagioscontact']['status']= true;
+  }
+  
+  if ((!isset($objectclasses['apple-user'])) || (!isset($objectclasses['mount'])) ){
+    $messages['netatalk']['msg']= _("Support for netatalk disabled, no schema seems to be installed");
+    $affich['netatalk']['msg']= $messages['netatalk']['msg']."<td class=\"check\">apple.schema</td>";
+    $messages['netatalk']['status']= FALSE;
+    $affich['netatalk']['status']= FALSE;
+  }else{
+    $affich['netatalk']['msg']= _("Support for netatalk enabled")."<td class=\"check\">apple.schema</td>";
+    $affich['netatalk']['status']= true;
+  }
   
   /* Fix for PHP Fehler "Undefined index: ldapconf"
    * Ablaufverfolgung[1]: Funktion schema_check        Datei: /home/hickert/gosa/include/functions_setup.inc (Zeile 230)
@@ -281,6 +274,7 @@ function perform_php_checks(&$faults)
   $msg= "";
 
   $msg.= "<h1>"._("PHP setup inspection")."</h1>";
+
   $msg.= check (       $faults, _("Checking for PHP version (>=4.1.0)"),
       _("PHP must be of version 4.1.0 or above for some functions and known bugs in PHP language."),
       version_compare(phpversion(), "4.1.0")>=0);
@@ -288,6 +282,10 @@ function perform_php_checks(&$faults)
   $msg.= check (       $faults, _("Checking if register_globals is set to 'off'"),
       _("register_globals is a PHP mechanism to register all global varibales to be accessible from scripts without changing the scope. This may be a security risk. GOsa will run in both modes."),
       $check_globals == 0, FALSE);
+  
+  $msg.= check (  $faults, _("PHP session.gc_maxlifetime (>= 86400 seconds)."),
+      _("PHP uses this value for the garbage collector to delete old sessions, setting this value to one day will prevent loosing session and cookie  before they really timeout."),
+      ini_get("session.gc_maxlifetime") >= 86400,FALSE);
 
   $msg.= check (       $faults, _("Checking for ldap module"),
       _("This is the main module used by GOsa and therefore really required."),
@@ -337,13 +335,13 @@ function perform_php_checks(&$faults)
 }
 
 function get_link($function_name) {
-  $result= "http://de.php.net/manual/en/function.";
+  $result= "<a href='http://de.php.net/manual/en/function.";
 
   /* Replace all underscores with hyphens (phpdoc convention) */
   $function_name= str_replace("_", "-", $function_name);
 
   /* Append to base URL */
-  $result.= $function_name.'.php';
+  $result.= $function_name.".php'>$function_name</a>";
 
   return $result;
 }
@@ -370,9 +368,9 @@ function perform_additional_function_checks(&$faults) {
   /* Only print message, if function is not callable */
   foreach($functions as $key => $fn_name) {
     if(!is_callable($fn_name)) {
-      $msg.= check ($faults, sprintf(_("Checking for function <b><a href='%s' target='_blank'>%s</a></b>"), get_link($fn_name), $fn_name),
-        sprintf(_("The function <b><a href='%s' target='_blank'>%s</a></b> is used by GOsa. There is no information if it's optional or required yet."),get_link($fn_name),$fn_name),
-        is_callable($fn_name), FALSE);
+      $msg.= check ($faults, sprintf(_("Checking for function %s"), "<b>".get_link($fn_name)."</b>"),
+        sprintf(_("The function %s is used by GOsa. There is no information if it's optional or required yet."), "<b>".get_link($fn_name)."</b>"),
+        is_callable($fn_name), false);
     }
   }
   return $msg;
@@ -494,19 +492,21 @@ function parse_contrib_conf()
   }
 
   /* Look for samba password generation method */
-  if(file_exists("/usr/lib/gosa/mkntpasswd")){
-    $pwdhash  = "/usr/lib/gosa/mkntpasswd";
+  if(file_exists("/usr/bin/mkntpasswd")){
+    $pwdhash  = "/usr/bin/mkntpasswd";
   } elseif (preg_match("/^Usage: mkntpwd /", shell_exec ("mkntpwd 2>&1"))){
     $pwdhash= "mkntpwd";
   } else {
     $pwdhash=('perl -MCrypt::SmbHash -e "ntlmgen \"\$ARGV[0]\", \$lm, \$nt; print \"\${lm}:\${nt}\n\";" $1');
   }
 
+
   /* Define which variables will be replaced */
   $replacements['{LOCATIONNAME}']  = $ldapconf['location'];
   $replacements['{SAMBAVERSION}']  = $used_samba_version;
   $replacements['{LDAPBASE}']      = $ldapconf['base'];
   $replacements['{LDAPADMIN}']     = $ldapconf['admin'];
+  $replacements['{UIDBASE}']       = $ldapconf['uidbase'];
   $replacements['{DNMODE}']        = $ldapconf['peopledn'];
   $replacements['{LDAPHOST}']      = $ldapconf['uri'];
   $replacements['{PASSWORD}']      = $ldapconf['password'];
@@ -531,6 +531,8 @@ function parse_contrib_conf()
   $possible_plugins['pureftp'][]     = "'\n.*<tab.*pureftp.*>.*\n'i";
   $possible_plugins['webdav'][]      = "'\n.*<tab.*webdav.*>.*\n'i";
   $possible_plugins['phpgroupware'][]= "'\n.*<tab.*phpgroupware.*>.*\n'i";
+  $possible_plugins['netatalk'][0]    = "'\n.*<plugin.*netatalk+.*\n.*>.*\n'i";
+  $possible_plugins['netatalk'][1]    = "'\n.*<tab.*netatalk.*>.*\n'i";
 
   /*Header information
      Needed to send the generated gosa.conf to the browser */
@@ -578,7 +580,7 @@ function parse_contrib_conf()
     }
 
     /* Data readed, types replaced, samba version detected and checked if
-       we need to add SID and RIDBASE. Check if there is an ivbbEntry in
+       we need to add SID and RIDBASE. Check if there is an ivbbentry in
        the LDAP tree, in this case we will set the governmentmode to true.
        Create LDAP connection, to check if theres a domain Objekt definen
        in the LDAP schema. */
@@ -587,7 +589,7 @@ function parse_contrib_conf()
     }
 
     /* Try to find a Samba Domain Objekt */
-    $ldap->search("(objectClass=ivbbEntry)");
+    $ldap->search("(objectClass=ivbbentry)");
 
     /* Something found ??? so we need to define ridbase an SID by ourselfs */
     if($ldap->count()> 0) {
@@ -603,11 +605,10 @@ function parse_contrib_conf()
       $str = str_replace("mailMethod=\"{MAILMETHOD}\"","",$str);
     }
 
-
     /* Remove all unused plugins */
-    foreach($possible_plugins as $key=> $plugin) {
-      foreach($plugin as $key=>$val) {
-        if(in_array($plugin,$classes)) {
+    foreach(array_keys($possible_plugins) as $akey) {
+      if(array_key_exists($akey,$classes)) {
+        foreach($possible_plugins[$akey] as $key=>$val) {
           $str = preg_replace($val,"\n",$str);
         }
       }
@@ -812,14 +813,14 @@ function show_setup_page4($withoutput = true)
       print_red (_("Can't bind to the specified LDAP server! Please make sure that it is reachable for GOsa."));
     }
   } else {
-    $sr=   @ldap_search ($ds, "", "objectClass=*", array("namingContexts"));
+    $sr=   @ldap_search ($ds, 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 informations twice"));
+        print_red(_("Bind to server successful, but the server seems to be completly empty, please check all information twice"));
       }
 
     } else {