From: hickert Date: Fri, 13 Apr 2007 07:17:18 +0000 (+0000) Subject: Renamed setup step classes. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bf462dc5c237b48cdad12a5393ec2afe8e519902;p=gosa.git Renamed setup step classes. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6037 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/setup/class_setupStep1.inc b/setup/class_setupStep1.inc deleted file mode 100644 index d7a759383..000000000 --- a/setup/class_setupStep1.inc +++ /dev/null @@ -1,78 +0,0 @@ -lang = get_browser_language(); - $this->lang_selected = ""; - $this->is_enabled = TRUE; - $this->is_active = TRUE; - $this->update_strings(); - } - - function update_strings() - { - $this->s_title = _("Language setup"); - $this->s_title_long = _("Language setup"); - $this->s_info = _("This step is allows you to select your prefered language."); - } - - function execute() - { - $this->languages = array("" => _("Automatic"), - "de_DE" => _("German"), - "fr_FR" => _("French"), - "en_EN" => _("English"), - "ru_RU" => _("Russian")); - - $smarty = get_smarty(); - $smarty->assign("languages", $this->languages); - $smarty->assign("lang", $this->lang); - $smarty->assign("lang_selected",$this->lang_selected); - return($smarty->fetch(get_template_path("setup_step1.tpl",TRUE,dirname(__FILE__)))); - } - - function save_object() - { - if((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) { - $this->lang_selected = $_POST['lang_selected']; - $this->is_completed = TRUE; - - if($this->lang_selected != ""){ - $_SESSION['lang'] = $this->lang_selected; - }else{ - $_SESSION['lang'] = $this->lang; - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep2.inc b/setup/class_setupStep2.inc deleted file mode 100644 index b9bbfbf27..000000000 --- a/setup/class_setupStep2.inc +++ /dev/null @@ -1,307 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("Installation check"); - $this->s_title_long = _("Basic installation checks"); - $this->s_info = _("Some basic checks for PHP version, ldap extension..."); - } - - - /* Execute and display template */ - function execute() - { - $this->run_checks(); - $smarty = get_smarty(); - $smarty->assign("basic" ,$this->basic_checks); - $smarty->assign("config" ,$this->config_checks); - $smarty->assign("is_writeable",$this->is_writeable); - return($smarty->fetch(get_template_path("setup_step2.tpl",TRUE,dirname(__FILE__)))); - } - - - /* Execute all checks */ - function run_checks() - { - $this->basic_checks = array(); - $this->config_checks = array(); - $this->is_writeable = array(); - - /* PHP version check */ - $N = _("Checking PHP version"); - $D = sprintf(_("PHP must be of version %s or %s or above for some functions."),"4.3.10","5.2.0"); - $S = _("GOsa requires functions that may not be available in older PHP versions, just update to a supported PHP version."); - $R = $this->check_php_version(); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking imap extension */ - $N = _("Checking for ldap module"); - $D = _("This is the main module used by GOsa and therefore really required."); - $S = _("The ldap module (PHP4-ldap/PHP5-ldap) is required to communicate with your ldap server."); - $R = is_callable("ldap_bind"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check for gettext support */ - $N = _("Checking for gettext support"); - $D = _("Gettext support is required for internationalized GOsa."); - $S = _("This should be activated while compiling your PHP. (--with-gettext)"); - $R = is_callable("bindtextdomain"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checing for iconv */ - $N = _("Checking for iconv support"); - $D = _("This module is used by GOsa to convert samba munged dial informations and is therefore required. "); - $S = _("This should be activated while compiling your PHP. (--with-iconv)"); - $R = is_callable("iconv"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check for installed mhash module */ - $N = _("Checking for mhash module"); - $D = _("To use SSHA encryption, you'll need this module. GOsa will run without it."); - $S = _("The mhash module for PHP 4/5 is not available, please install it. (php4-mhash/php5-mhash)"); - $R = is_callable("mhash"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Is imap module available */ - $N = _("Checking for imap module"); - $D = _("The IMAP module is needed to communicate with the IMAP server. It gets status informations, creates and deletes mail users."); - $S = _("This module is used to communicate with your mail server. Please install (PHP4-imap PHP5-imap)"); - $R = is_callable("imap_open"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check getacl in imap module */ - $N = _("Checking for getacl in imap"); - $D = _("The getacl support is needed for shared folder permissions. The standard IMAP module is not capable of reading acl's. You need a recend PHP version for this feature."); - $S = $D; - $R = is_callable("imap_getacl"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Mysql module loaded ? */ - $N = _("Checking for mysql module"); - $D = _("MySQL support is needed for reading GOfax reports from databases."); - $S = _("This module is required to communicate with database servers, for example used in phone and fax addons. Please install (PHP4-mysql PHP5-mysql)"); - $R = is_callable("mysql_query"); - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking for kadm5 module */ - $N = _("Checking for kadm5 module"); - $D = _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."); - $S = _("This module is required to manage user in kerberos, it is downloadable via PEAR network"); - $R = is_callable("kadm5_init_with_password"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Snmp module available ? */ - $N = _("Checking for snmp Module"); - $D = _("Simple Network Management Protocol (SNMP) is required for client monitoring."); - $S = _("This module is required for client monitoring. (PHP4-snmp/PHP5-snmp)"); - $R = is_callable("snmpget"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking for Cups module */ - $N = _("Checking for cups module"); - $D = _("In order to read available printers from IPP protocol instead of printcap files, you've to install the CUPS module."); - $S = $D; - $R = is_callable("cups_get_dest_list"); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking for F ping utility */ - $query= "LC_ALL=C LANG=C fping -v 2>&1"; - $output= shell_exec ($query); - $N = _("Checking for fping utility"); - $D = _("The fping utility is only used if you've got a thin client based terminal environment running."); - $S = _("The fping utility is only used in thin client based terminal environment."); - $R = preg_match("/^fping:/", $output); - $M = FALSE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Checking generate LM/NT password hashes */ - $query= "mkntpwd 2>&1"; - $output= shell_exec ($query); - $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output); - if (!$have_mkntpwd){ - $query= 'LC_ALL=C LANG=C perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen $ARGV[0]), $/;" &>/dev/null'; - system ($query, $ret); - $have_mkntpwd |= ($ret == 0); - } - - $N = _("Password hashes"); - $D = _("In order to use SAMBA 2/3, you've to install some additional packages to generate password hashes."); - $S = _("In order to use samba 2/3 you've to install some additional packages to generate password hashes. (e.g. libmhash2)"); - $R = $have_mkntpwd; - $M = TRUE; - $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - - /* PHP Configuration checks - */ - - /* Register_globals off */ - $N = _("register_globals"." ".""._("Off").""); - $D = _("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."); - $S = _("Search for 'register_globals' in your php.ini and switch it to 'Off'."); - $R = ini_get("register_globals") == 0; - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - - /* session lifetime set to >=86400 seconds ? */ - $N = ("session.gc_maxlifetime"." "." >= 86400"); - $D = _("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."); - $S = _("Search for 'session.gc_maxlifetime' in your php.ini and set it to 86400 or higher."); - $R = ini_get("session.gc_maxlifetime") >= 86400; - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Session auto start must be turned off */ - $session_auto_start = ini_get('session.auto_start'); - $N = _("session.auto_start"." ".""._("Off").""); - $D = _("In Order to use GOsa without any trouble, the session.auto_register option in your php.ini must be set to 'Off'."); - $S = _("Search for 'session.auto_start' in your php.ini and set it to 'Off'."); - $R = !$session_auto_start['local_value']; - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check if memory limit is set to 32 or > */ - $N = _("memory_limit")." "." >= 32"; - $D = _("GOsa needs at least 32MB of memory, less will cause unpredictable errors! Increase it for larger setups."); - $S = _("Search for 'memory_limit' in your php.ini and set it to '32M' or higher."); - $R = ini_get('memory_limit') >= 32 ; - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Implicit Flush disabled can increase performance */ - $N = _("implicit_flush")." ".""._("Off").""; - $D = _("This option influences the Output handling. Turn this Option off, to increase performance."); - $S = _("Search for 'implicit_flush' in your php.ini and set it to 'Off'."); - $R = ini_get('implicit_flush'); - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Check if execution time is set to 30 */ - $N = _("max_execution_time")." "." >= 30"; - $D = _("The Execution time should be at least 30 seconds, because some actions may consume more time."); - $S = _("Search for 'max_execution_time' in your php.ini and set it to '30' or higher."); - $R = ini_get("max_execution_time") >= 30 ; - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Expose php should be set to off */ - $N = _("expose_php")." "._("Off").""; - $D = _("Increase the server security by setting expose_php to 'off'. PHP won't send any Information about the server you are running in this case."); - $S = _("Search for 'expose_php' in your php.ini and set if to 'Off'."); - $R = !ini_get("expose_php"); - $M = FALSE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* Automatic quoting must be turned on */ - $N = _("magic_quotes_gpc")." "._("On").""; - $D = _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."); - $S = _("Search for 'magic_quotes_gpc' in your php.ini and set it to 'On'."); - $R = ini_get('magic_quotes_gpc'); - $M = TRUE; - $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - - /* Configuration file - */ - - /* Check if we can create a config file.*/ - $N = _("Configuration file writeable."); - $D = _("The Configuration file can't be written"); - $S = sprintf(_("The GOsa reads its configuration from a file located in (%s/%s). The setup can write the configuration directly in this file, if it is writeable."),CONFIG_DIR,CONFIG_FILE); - $R = ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE)) // is there a config file ? - || (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR)); // There is non, but can we create a file there ? - $M = FALSE; - $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); - - /* If we have writeaccess to the config dir, check if there is already a config file */ -# if($R){ -# -# /* check if there is already a config file. */ -# $N = _("No old configuration file."); -# $D = "";//_(""); -# $S = _("If there is already a configuration file, this file will be overwritten when GOsa setup finishes. Please move your old config file away."); -# $R = !file_exists(CONFIG_DIR."/".CONFIG_FILE); -# $M = FALSE; -# $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); -# } - } - - - function save_object() - { - /* If everything is fine, set this step to completed - * and allow switching to next setup step - */ - $failed = false; - foreach(array("basic_checks","config_checks","is_writeable") as $type){ - foreach($this->$type as $obj){ - - if($obj['MUST'] && !$obj['RESULT']){ - $failed = true; - break; - } - } - } - $this->is_completed = !$failed; - } - - - /* Check if current PHP version is compatible - with the current version of GOsa */ - function check_php_version() - { - if(preg_match("/^5/",phpversion())){ - return(version_compare(phpversion(),"5.2.0",">=")); - }else{ - return(version_compare(phpversion(),"4.3.10",">=")); - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep3.inc b/setup/class_setupStep3.inc deleted file mode 100644 index db861f868..000000000 --- a/setup/class_setupStep3.inc +++ /dev/null @@ -1,81 +0,0 @@ -update_strings(); - } - - - function load_license() - { - if(!file_exists("../setup/license.txt")){ - $this->License = "License not found. Setup stops here."; - $this->license_found = false; - }else{ - $fp = fopen("../setup/license.txt","r"); - $this->License = ""; - while (!feof($fp)){ - $this->License .= fread($fp, 255); - } - $this->license_found = true; - } - } - - - function update_strings() - { - $this->s_title = _("License"); - $this->s_title_long = _("GNU / GPL-License"); - $this->s_info = _("GNU / GPL-License"); - } - - - function execute() - { - $this->load_license(); - - $smarty = get_smarty(); - $smarty -> assign("License",nl2br($this->License)); - $smarty -> assign("license_found",$this->license_found); - - return($smarty -> fetch (get_template_path("../setup/setup_step3.tpl"))); - } - - - function save_object() - { - if($this->license_found){ - $this->is_completed = true; - }else{ - $this->is_completed = false; - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep4.inc b/setup/class_setupStep4.inc deleted file mode 100644 index 3e3bc899a..000000000 --- a/setup/class_setupStep4.inc +++ /dev/null @@ -1,161 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("Ldap settings"); - $this->s_title_long = _("Ldap connection setup"); - $this->s_info = _("This dialog allows the basic configuration of GOsa's behaviour and properties in your main configuration."); - } - - - function execute() - { - $smarty = get_smarty(); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - /* Assign connection status */ - $smarty->assign("connection_status",$this->get_connection_status()); - - /* Handle namingContext detection */ - $attr = @LDAP::get_naming_contexts($this->connection); - unset($attr['count']); - $smarty->assign("namingContexts",$attr); - $smarty->assign("namingContextsCount",count($attr)); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - - /* Addign resolved users */ - $smarty->assign("resolve_user",$this->resolve_user); - if($this->resolve_user){ - $tmp = $this->resolve_user(); - $smarty->assign("resolved_users",$tmp); - $smarty->assign("resolved_users_count",count($tmp)); - $smarty->assign("resolve_filter",$this->resolve_filter); - } - return($smarty -> fetch (get_template_path("../setup/setup_step4.tpl"))); - } - - function get_connection_status() - { - $this->connect_id = FALSE; - $this->bind_id = FALSE; - - @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); - $this->connect_id = @ldap_connect($this->connection); - - @ldap_set_option($this->connect_id, LDAP_OPT_PROTOCOL_VERSION, 3); - $this->bind_id = @ldap_bind($this->connect_id, $this->admin, $this->password); - - if(!$this->bind_id){ - $str = sprintf(_("Anonymous bind failed on server '%s'."),$this->connection); - if(!empty($this->admin)){ - $str = sprintf(_("Bind as user '%s' failed on server '%s'."),$this->admin,$this->connection); - } - return("".$str.""); - }else{ - if(empty($this->admin)){ - $str = sprintf(_("Anonymous bind successful on server '%s'. Please specify user and password."),$this->connection); - return("".$str.""); - }else{ - $str = sprintf(_("Bind as user '%s' successful on server '%s'."),$this->admin,$this->connection); - return("".$str.""); - } - } - } - - - function resolve_user() - { - $filter = $this->resolve_filter; - $ldap = new LDAP("","",$this->connection); - $ldap->cd($this->base); - $ldap->search("(&(objectClass=person)(|(uid=".$filter.")(cn=".$filter.")))"); - $tmp = array(); - while($attrs = $ldap->fetch()){ - $tmp[$attrs['dn']]=$attrs['dn']; - natcasesort($tmp); - } - return($tmp); - } - - - function save_object() - { - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = $_POST[$attr]; - } - } - - if(isset($_POST['resolve_user'])){ - $this->resolve_user = !$this->resolve_user; - } - - if(isset($_POST['resolve_filter'])){ - $this->resolve_filter = $_POST['resolve_filter']; - } - - if(isset($_POST['use_selected_user'])){ - - if(isset($_POST['admin_to_use'])){ - $this->admin = $_POST['admin_to_use']; - $this->resolve_user = false; - } - } - - $this->get_connection_status(); - if($this->bind_id){ - $this->is_completed =TRUE; - }else{ - $this->is_completed =FALSE; - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep5.inc b/setup/class_setupStep5.inc deleted file mode 100644 index 9a7afae5a..000000000 --- a/setup/class_setupStep5.inc +++ /dev/null @@ -1,244 +0,0 @@ - 6, - "pwminlen_active" => FALSE, - "pwdiffer" => 5, - "pwdiffer_active" => FALSE, - "externalpwdhook" => "/path/to/your/script username oldpassword newpassword", - "externalpwdhook_active" => FALSE); - - var $mail_settings = array("vacationdir" => "/etc/gosa/vacation", - "vacationdir_active" => FALSE); - - var $crypt_methods = array(); - var $mail_methods = array(); - - - var $attributes = array("peopleou","groupou","peopledn","uidbase","encryption","mail","theme","errorlvl","cyrusunixstyle", - "base_hook","base_hook_active"); - - function setup_step_5() - { - $this->update_strings(); - - $tmp = @passwordMethod::get_available_methods_if_not_loaded(); - foreach($tmp['name'] as $name){ - $this->crypt_methods[$name] = $name; - } - $tmp = $this->get_available_mail_classes(); - foreach($tmp['name'] as $name){ - $this->mail_methods[$name] = $name; - } - } - - - function update_strings() - { - $this->s_title = _("GOsa settings 1/3"); - $this->s_title_long = _("GOsa generic settings, page 1/3"); - $this->s_info = _("This dialog allows you to setup GOsa behaviour"); - } - - - function execute() - { - $smarty = get_smarty(); - $smarty->assign("peopledns",array("uid","cn")); - $smarty->assign("crypt_methods",$this->crypt_methods); - $smarty->assign("mail_methods",$this->mail_methods); - $smarty->assign("themes",$this->get_themes()); - $smarty->assign("pwd_rules",$this->pwd_rules); - $smarty->assign("mail_settings",$this->mail_settings); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - $smarty->assign("warnings" ,$this->check()); - $smarty->assign("warnings_cnt" ,count($this->check())); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty -> fetch (get_template_path("../setup/setup_step5.tpl"))); - } - - - /* Returns the classnames auf the mail classes */ - function get_available_mail_classes() - { - $dir = opendir( "../include"); - $methods = array(); - $suffix = "class_mail-methods-"; - $lensuf = strlen($suffix); - $prefix = ".inc"; - $lenpre = strlen($prefix); - $i = 0; - while (($file = readdir($dir)) !== false){ - - if(stristr($file,$suffix)) { - $lenfile = strlen($file); - $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); - $methods['file'][$i] = $file; - $methods[$i]['file'] = $file; - $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); - $i++; - } - } - return($methods); - } - - function get_themes() - { - $dir = opendir( "../ihtml/themes/"); - $themes = array(); - while (($file = readdir($dir)) !== false){ - if(is_dir("../ihtml/themes/".$file) && !preg_match("/^\./",$file)){ - $themes[$file] = $file; - } - } - return($themes); - } - - function check() - { - $message = array(); - - if(preg_match("/,$/",$this->peopleou)){ - $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("People storage ou")); - } - - if(preg_match("/,$/",$this->groupou)){ - $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("Group storage ou")); - } - - if(!is_numeric($this->uidbase)){ - $message[] = _("Uid base must be numeric"); - } - - if(($this->pwd_rules['pwminlen_active']) && !is_numeric($this->pwd_rules['pwminlen'])){ - $message[] = _("The given password minimum length is not numeric."); - } - if(($this->pwd_rules['pwdiffer_active']) && !is_numeric($this->pwd_rules['pwdiffer'])){ - $message[] = _("The given password differ value is not numeric."); - } - return($message); - - } - - function save_object() - { - if(isset($_POST['step5_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate($_POST[$attr]); - } - } - - /* Get password settings */ - if(isset($_POST['pwdiffer_active'])){ - $this->pwd_rules['pwdiffer_active'] = TRUE; - if(isset($_POST['pwdiffer'])){ - $this->pwd_rules['pwdiffer'] = $_POST['pwdiffer']; - } - }else{ - $this->pwd_rules['pwdiffer_active'] = FALSE; - } - - /* Get password minimum length posts */ - if(isset($_POST['pwminlen_active'])){ - $this->pwd_rules['pwminlen_active'] = TRUE; - if(isset($_POST['pwminlen'])){ - $this->pwd_rules['pwminlen'] = $_POST['pwminlen']; - } - }else{ - $this->pwd_rules['pwminlen_active'] = FALSE; - } - - /* Mail settings */ - if(isset($_POST['vacationdir_active'])){ - $this->mail_settings['vacationdir_active'] = TRUE; - if(isset($_POST['vacationdir'])){ - $this->mail_settings['vacationdir'] = $_POST['vacationdir']; - } - }else{ - $this->mail_settings['vacationdir_active'] = FALSE; - } - - /* Mail settings */ - if(isset($_POST['externalpwdhook_active'])){ - $this->pwd_rules['externalpwdhook_active'] = TRUE; - if(isset($_POST['externalpwdhook'])){ - $this->pwd_rules['externalpwdhook'] = $_POST['externalpwdhook']; - } - }else{ - $this->pwd_rules['externalpwdhook_active'] = FALSE; - } - - /* Mail settings */ - if(isset($_POST['base_hook_active'])){ - $this->pwd_rules['base_hook_active'] = TRUE; - if(isset($_POST['base_hook'])){ - $this->pwd_rules['base_hook'] = $_POST['base_hook']; - } - }else{ - $this->pwd_rules['base_hook_active'] = FALSE; - } - } - - $tmp = $this->check(); - if(count($tmp) == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - }// if tempalte posted - - - /* Attributes that are interesting for configuration generation */ - function get_attributes() - { - $tmp = setup_step::get_attributes(); - foreach(array("pwd_rules","mail_settings") as $attr){ - $tmp[$attr]= $this->$attr; - } - return($tmp); - } -}// CLass - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep6.inc b/setup/class_setupStep6.inc deleted file mode 100644 index 30dd7f931..000000000 --- a/setup/class_setupStep6.inc +++ /dev/null @@ -1,202 +0,0 @@ - "{%sn}-{%givenName[2-4]}", - "idgen_active" => FALSE, - "minid" => "100", - "minid_active" => FALSE, - "wws_ou" => "ou=winstations", - "wws_ou_active" => FALSE, - "snapshot_active" => FALSE, - "snapshot_base" => "ou=snapshots,%base%", - "snapshot_ldap_base" => "%base%", - "snapshot_user" => "cn=ldapadmin,%base%", - "snapshot_password" => "", - "snapshot_server" => "%connection%"); - - var $samba_settings = array( "samba_sid" => "0-815-4711", - "samba_sid_active" => FALSE, - "samba_rid" => 1000, - "samba_rid_active" => FALSE); - var $attributes = array("strict","governmentmode","sambaidmapping","account_expiration"); - - function setup_step_6() - { - $this->update_strings(); - } - - - function update_strings() - { - $this->s_title = _("GOsa settings 2/3"); - $this->s_title_long = _("GOsa generic settings, page 2/3"); - $this->s_info = _("This dialog allows you to setup GOsa behaviour"); - } - - - function execute() - { - /* Update snapshot values, with already collected values */ - foreach($this->generic_settings as $key => $value){ - foreach(array("snapshot_ldap_base","snapshot_base","snapshot_user","snapshot_server") as $attr){ - foreach($this->parent->captured_values as $replace_name => $replace_value){ - if(is_string($replace_value)) { - $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]); - } - } - } - } - - $smarty = get_smarty(); - $smarty->assign("generic_settings",$this->generic_settings); - $smarty->assign("samba_settings",$this->samba_settings); - $smarty->assign("warnings" ,$this->check()); - $smarty->assign("warnings_cnt" ,count($this->check())); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - return($smarty -> fetch (get_template_path("../setup/setup_step6.tpl"))); - } - - function save_object() - { - if(isset($_POST['step6_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate($_POST[$attr]); - } - } - - if(isset($_POST['minid_active'])){ - $this->generic_settings['minid_active'] = TRUE; - if(isset($_POST['minid'])){ - $this->generic_settings['minid'] = $_POST['minid']; - } - }else{ - $this->generic_settings['minid_active'] = FALSE; - } - - if(isset($_POST['wws_ou_active'])){ - $this->generic_settings['wws_ou_active'] = TRUE; - if(isset($_POST['wws_ou'])){ - $this->generic_settings['wws_ou'] = $_POST['wws_ou']; - } - }else{ - $this->generic_settings['wws_ou_active'] = FALSE; - } - - /* Generic settings */ - if(isset($_POST['idgen_active'])){ - $this->generic_settings['idgen_active'] = TRUE; - if(isset($_POST['idgen'])){ - $this->generic_settings['idgen'] = $_POST['idgen']; - } - }else{ - $this->generic_settings['idgen_active'] = FALSE; - } - if(isset($_POST['snapshot_active'])){ - $this->generic_settings['snapshot_active'] = TRUE; - if(isset($_POST['snapshot_base'])){ - $this->generic_settings['snapshot_base'] = $_POST['snapshot_base']; - } - if(isset($_POST['snapshot_user'])){ - $this->generic_settings['snapshot_user'] = $_POST['snapshot_user']; - } - if(isset($_POST['snapshot_password'])){ - $this->generic_settings['snapshot_password'] = $_POST['snapshot_password']; - } - if(isset($_POST['snapshot_server'])){ - $this->generic_settings['snapshot_server'] = $_POST['snapshot_server']; - } - if(isset($_POST['snapshot_ldap_base'])){ - $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base']; - } - }else{ - $this->generic_settings['snapshot_active'] = FALSE; - } - - /* Samba settings */ - if(isset($_POST['samba_sid_active'])){ - $this->samba_settings['samba_sid_active'] = TRUE; - if(isset($_POST['samba_sid'])){ - $this->samba_settings['samba_sid'] = $_POST['samba_sid']; - } - }else{ - $this->samba_settings['samba_sid_active'] = FALSE; - } - if(isset($_POST['samba_rid_active'])){ - $this->samba_settings['samba_rid_active'] = TRUE; - if(isset($_POST['samba_rid'])){ - $this->samba_settings['samba_rid'] = $_POST['samba_rid']; - } - }else{ - $this->samba_settings['samba_rid_active'] = FALSE; - } - - } - - $tmp = $this->check(); - if(count($tmp) == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - } - - - function check() - { - $message = array(); - - if(isset($this->generic_settings['minid_active']) && !is_numeric($this->generic_settings['minid'])){ - $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id")); - } - - return($message); - } - - - /* Attributes that are interesting for configuration generation */ - function get_attributes() - { - $tmp = setup_step::get_attributes(); - foreach(array("samba_settings","generic_settings") as $attr){ - $tmp[$attr]= $this->$attr; - } - return($tmp); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep6a.inc b/setup/class_setupStep6a.inc deleted file mode 100644 index 728f5808a..000000000 --- a/setup/class_setupStep6a.inc +++ /dev/null @@ -1,195 +0,0 @@ - false, - "forceglobals" => true, - "forcessl" => false, - "warnssl" => true, - "ppd_path" => "/var/spool/ppd/", - "ppd_path_active" => FALSE, - "compile" => "/var/spool/gosa", - "debuglevel" => 0, - "session_lifetime" => 7200, - "max_ldap_query_time" => "5.0", - "max_ldap_query_time_active" => FALSE, - - "mailQueueScriptPath" => "/usr/bin/sudo /usr/local/sbin/mailqueue %action %id %server", - "mailQueueScriptPath_active" => FALSE, - - "auto_network_hook" => "/etc/gosa/net-resolv.sh", - "auto_network_hook_active" => FALSE, - - "notifydir" => "", - "notifydir_active" => FALSE, - - "noprimarygroup" => FALSE, - "smbhash" => 'SMBHASH'); - - - function setup_step_6a() - { - $this->update_strings(); - - /* Look for samba password generation method */ - 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 "print join(q[:], ntlmgen \$ARGV[0]), $/;"'; - } - - $this->optional['smbhash'] = $pwdhash; - } - - - function update_strings() - { - $this->s_title = _("GOsa settings 3/3"); - $this->s_title_long = _("GOsa generic settings, page 3/3"); - $this->s_info = _("This dialog allows you to setup GOsa behaviour"); - } - - - function execute() - { - $smarty = get_smarty(); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - - $smarty->assign("optional", $this->optional); - - foreach($this->attributes as $attr){ - $smarty->assign($attr,$this->$attr); - } - - $smarty->assign("warnings" ,$this->check()); - $smarty->assign("warnings_cnt" ,count($this->check())); - - return($smarty -> fetch (get_template_path("../setup/setup_step6a.tpl"))); - } - - - function save_object() - { - if(isset($_POST['step6a_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate($_POST[$attr]); - } - } - - foreach(array("noprimarygroup","enableCopyPaste","forceglobals","forcessl","warnssl","compile","debuglevel","session_lifetime","smbhash") as $name){ - if(isset($_POST[$name])){ - $this->optional[$name] = stripslashes($_POST[$name]); - } - } - - if(isset($_POST['ppd_path_active'])){ - $this->optional['ppd_path_active'] = TRUE; - if(isset($_POST['ppd_path'])){ - $this->optional['ppd_path'] = $_POST['ppd_path']; - } - }else{ - $this->optional['ppd_path_active'] = FALSE; - } - - if(isset($_POST['max_ldap_query_time_active'])){ - $this->optional['max_ldap_query_time_active'] = TRUE; - if(isset($_POST['max_ldap_query_time'])){ - $this->optional['max_ldap_query_time'] = $_POST['max_ldap_query_time']; - } - }else{ - $this->optional['max_ldap_query_time_active'] = FALSE; - } - - if(isset($_POST['mailQueueScriptPath_active'])){ - $this->optional['mailQueueScriptPath_active'] = TRUE; - if(isset($_POST['mailQueueScriptPath'])){ - $this->optional['mailQueueScriptPath'] = $_POST['mailQueueScriptPath']; - } - }else{ - $this->optional['mailQueueScriptPath_active'] = FALSE; - } - - if(isset($_POST['auto_network_hook_active'])){ - $this->optional['auto_network_hook_active'] = TRUE; - if(isset($_POST['auto_network_hook'])){ - $this->optional['auto_network_hook'] = $_POST['auto_network_hook']; - } - }else{ - $this->optional['auto_network_hook_active'] = FALSE; - } - - if(isset($_POST['notifydir_active'])){ - $this->optional['notifydir_active'] = TRUE; - if(isset($_POST['notifydir'])){ - $this->optional['notifydir'] = $_POST['notifydir']; - } - }else{ - $this->optional['notifydir_active'] = FALSE; - } - } - - $tmp = $this->check(); - if(count($tmp) == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - } - - - function check() - { - $message = array(); - - if(!is_numeric( $this->optional['session_lifetime'])){ - $message[] = _("Session lifetime must be a numeric value."); - } - - if(!is_numeric( $this->optional['max_ldap_query_time'])){ - $message[] = _("Maximal ldap query time must be a numeric value. "); - } - - return($message); - } - - - /* Attributes that are interesting for configuration generation */ - function get_attributes() - { - $tmp = setup_step::get_attributes(); - foreach(array("optional") as $attr){ - $tmp[$attr]= $this->$attr; - } - return($tmp); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep7.inc b/setup/class_setupStep7.inc deleted file mode 100644 index 6dba41c0a..000000000 --- a/setup/class_setupStep7.inc +++ /dev/null @@ -1,226 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("Ldap schema check"); - $this->s_title_long = _("Ldap schema check"); - $this->s_info = _("This dialog checks your ldap schema setup"); - } - - - function execute() - { - $this->check_schema(); - $failed_checks = 0 ; - foreach($this->checked as $val) { - if(!$val['STATUS']){ - $failed_checks ++; - } - } - - if($failed_checks == 0){ - $this->is_completed = TRUE; - }else{ - $this->is_completed = FALSE; - } - - $smarty = get_smarty(); - $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); - $smarty->assign("schema_readable",$this->schema_readable); - $smarty->assign("enable_schema_check",$this->enable_schema_check); - $smarty->assign("checks",$this->checked); - $smarty->assign("not_checked",$this->not_checked); - $smarty->assign("failed_checks",$failed_checks); - return($smarty -> fetch (get_template_path("../setup/setup_step7.tpl"))); - } - - function check_schema_version($description, $version) - { - $desc= preg_replace("/^.* DESC\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $description); - return preg_match("/\(v$version\)/", $desc); - } - - - function save_object() - { - if(isset($_POST['step7_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate($_POST[$attr]); - } - } - } - } - - - function check_schema() - { - $cfg = $this->parent->captured_values; - $messages= array(); - - /* Get objectclasses */ - $ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['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))); - } - - - /* Which samba version do we use? */ - if(isset($objectclasses['sambaSamAccount'])){ - $this->samba_version = 3; - } elseif(isset($objectclasses['sambaAccount'])) { - $this->samba_version = 2; - }else{ - $this->samba_version = 0; - } - - /* This is the default block used for each entry. - * to avoid unset indexes. - */ - $def_check = array("REQUIRED_VERSION" => "0", - "SCHEMA_FILES" => array(), - "CLASSES_REQUIRED" => array(), - "STATUS" => FALSE, - "IS_MUST_HAVE" => FALSE, - "MSG" => "", - "INFO" => "");#_("There is currently no information specified for this schema extension.")); - - - /* The gosa base schema */ - $checks['gosaObject'] = $def_check; - $checks['gosaObject']['REQUIRED_VERSION'] = "2.4"; - $checks['gosaObject']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema"); - $checks['gosaObject']['CLASSES_REQUIRED'] = array("gosaObject"); - $checks['gosaObject']['IS_MUST_HAVE'] = TRUE; - - /* GOsa Account class */ - $checks["gosaAccount"]["REQUIRED_VERSION"]= "2.4"; - $checks["gosaAccount"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema"); - $checks["gosaAccount"]["CLASSES_REQUIRED"]= array("gosaAccount"); - $checks["gosaAccount"]["IS_MUST_HAVE"] = TRUE; - $checks["gosaAccount"]["INFO"] = _("Used to store account specific informations."); - - /* GOsa lock entry, used to mark currently edited objects as 'in use' */ - $checks["gosaLockEntry"]["REQUIRED_VERSION"] = "2.4"; - $checks["gosaLockEntry"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema"); - $checks["gosaLockEntry"]["CLASSES_REQUIRED"] = array("gosaLockEntry"); - $checks["gosaLockEntry"]["IS_MUST_HAVE"] = TRUE; - $checks["gosaLockEntry"]["INFO"] = _("Used to lock currently edited entries to avoid multiple changes at the same time."); - - /* Some other checks */ - foreach(array( - "gosaCacheEntry" => array("version" => "2.4"), - "gosaDepartment" => array("version" => "2.4"), - "goFaxAccount" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"), - "goFaxSBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"), - "goFaxRBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"), - "gosaUserTemplate" => array("version" => "2.4", "class" => "posixAccount","file" => "nis.schema"), - "gosaMailAccount" => array("version" => "2.4", "class" => "mailAccount","file" => "gosa+samba3.schema"), - "gosaProxyAccount" => array("version" => "2.4", "class" => "proxyAccount","file" => "gosa+samba3.schema"), - "gosaApplication" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"), - "gosaApplicationGroup" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.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"), - "goNtpServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"), - "goSyslogServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"), - "goLdapServer" => array("version" => "2.4"), - "goCupsServer" => array("version" => "2.4", "class" => array("posixAccount", "terminals"),), - "goImapServer" => array("version" => "2.4", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3.schema"), - "goKrbServer" => array("version" => "2.4"), - "goFaxServer" => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"), - ) as $name => $values){ - - $checks[$name] = $def_check; - if(isset($values['version'])){ - $checks[$name]["REQUIRED_VERSION"] = $values['version']; - } - if(isset($values['file'])){ - $checks[$name]["SCHEMA_FILES"] = array($values['file']); - } - $checks[$name]["CLASSES_REQUIRED"] = array($name); - } - - foreach($checks as $name => $value){ - foreach($value['CLASSES_REQUIRED'] as $class){ - - if(!isset($objectclasses[$name])){ - $checks[$name]['STATUS'] = FALSE; - if($value['IS_MUST_HAVE']){ - $checks[$name]['MSG'] = sprintf(_("The required objectClass '%s' is not present in your schema setup"),$class); - }else{ - $checks[$name]['MSG'] = sprintf(_("The optional objectClass '%s' is not present in your schema setup"),$class); - } - }elseif(!$this->check_schema_version($objectclasses[$name],$value['REQUIRED_VERSION'])){ - $checks[$name]['STATUS'] = FALSE; - - if($value['IS_MUST_HAVE']){ - $checks[$name]['MSG'] = sprintf(_("The required objectclass '%s' does not have version %s"), $class, $value['REQUIRED_VERSION']); - }else{ - $checks[$name]['MSG'] = sprintf(_("The optional objectclass '%s' does not have version %s"), $class, $value['REQUIRED_VERSION']); - } - }else{ - $checks[$name]['STATUS'] = TRUE; - $checks[$name]['MSG'] = sprintf(_("Class(es) available")); - } - } - } - - $this->checked = $checks; - $tmp = $objectclasses; - $not_checked = array(); - foreach($tmp as $name => $val){ - $desc = "no description."; - if(preg_match("/DESC/",$val)){ - $desc = preg_replace("/^.*DESC[ ]*'/i","",$val) ; - $desc = preg_replace("/'.*$/i","",$desc) ; - } - $not_checked[$name] = $desc; - } - - $this->not_checked = $not_checked; - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep8.inc b/setup/class_setupStep8.inc deleted file mode 100644 index 44eeefcb6..000000000 --- a/setup/class_setupStep8.inc +++ /dev/null @@ -1,229 +0,0 @@ -update_strings(); - } - - - function update_strings() - { - $this->s_title = _("Configuration file"); - $this->s_info = _("In this step the configuration file will be created."); - $this->s_title_long = _("Saving configuration file"); - } - - - function get_conf_data() - { - $smarty = get_smarty(); - $smarty->assign("cv",$this->parent->captured_values); - $str = $smarty->fetch(CONFIG_TEMPLATE_DIR.$this->gosa_conf_contrib); - return($str); - } - - - function execute() - { - - $info= posix_getgrgid(posix_getgid()); - $webgroup = $info['name']; - - - /* Check if there is currently an active gosa.conf - */ - $exists = file_exists(CONFIG_DIR."/".CONFIG_FILE); - - /* Check if existing config file is writeable */ - if($exists){ - $writeable = is_writeable(CONFIG_DIR."/".CONFIG_FILE); - }else{ - $writeable = is_writeable(CONFIG_DIR); - } - - /* Redirect to GOsa login */ - if(isset($_POST['use_gosa'])){ - session_destroy(); - header("Location: index.php"); - exit(); - } - - /* Downlaod config */ - if(isset($_POST['getconf'])){ - - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - header("Cache-Control: no-cache"); - header("Pragma: no-cache"); - header("Cache-Control: post-check=0, pre-check=0"); - header("Content-type: text/plain"); - - if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) || - preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){ - header('Content-Disposition: filename="'.CONFIG_FILE.'"'); - } else { - header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"'); - } - - $str = $this->get_conf_data(); - $str = preg_replace("/\n[ ]*\n/","",$str); - - echo $this->get_conf_data(); - exit(); - } - - - /* Try to save configuration */ - $abort = FALSE; - $err_msg = ""; - if(isset($_POST['saveconf'])){ - if($exists && $this->create_backup){ - if(!$this->create_backup()){ - $abort = TRUE; - $err_msg = _("Could not create requested configuration file backup. Aborted writing config file. Please check folder permission and try again. Or use the manual method if this can not be fixed anyway."); - } - } - - if(!$abort){ - - /* Try to create file handle */ - $fp = @fopen(CONFIG_DIR."/".CONFIG_FILE, "w"); - - if(!$fp){ - $err_msg = sprintf(_("Can not create handle on file '%s', the configuration could not be written. Please check folder permission and try again. Or use the manual method if this can not be fixed anyway."),CONFIG_DIR."/".CONFIG_FILE); - $abort =TRUE; - }else{ - - $data = $this->get_conf_data(); - if(!fwrite($fp,$data)){ - $err_msg = sprintf(_("Can not write file '%s'. Please check folder permission and try again. Or use the manual method if this can not be fixed anyway."),CONFIG_DIR."/".CONFIG_FILE); - $abort =TRUE; - }else{ - - @chgrp(CONFIG_DIR."/".CONFIG_FILE,$webgroup); - @chown(CONFIG_DIR."/".CONFIG_FILE,"root"); - @chmod(CONFIG_DIR."/".CONFIG_FILE,0640); - } - } - } - } - - - if($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){ - $err_msg = _("Your configuration file is currently world readable. This is a big security risk. Please updated the file permissions as shown in the manual configuration part below."); - } - - $smarty = get_smarty(); - $smarty->assign("save_requested", isset($_POST['saveconf'])); - $smarty->assign("err_msg",$err_msg); - $smarty->assign("webgroup", $webgroup); - $smarty->assign("create_backup" , $this->create_backup); - $smarty->assign("CONFIG_DIR",CONFIG_DIR); - $smarty->assign("CONFIG_FILE" , CONFIG_FILE); - $smarty->assign("exists",$exists); - - $smarty->assign("msg1", sprintf(_("If you want the setup routine to write the configuration file, use the 'Save configuration' button below. If you prefer to copy the '%s' manually to '%s' you can download the configuration file by using the 'Download configuration' button."), CONFIG_FILE,CONFIG_DIR)); - - $smarty->assign("msg2", sprintf(_("After placing the file under %s, place make sure that the webserver user is able to read %s, while other users shouldn't. You may want to execute these commands to achieve this requirement"),CONFIG_DIR,CONFIG_FILE)); - - $smarty->assign("last_backup_name",$this->last_backup_name); - $smarty->assign("writeable",$writeable); - $smarty->assign("cv",$this->parent->captured_values); - $smarty->assign("msg_permissions", - sprintf(_("The following file(s), folders(s) must be writeable for the web-user '%s'."),$info['name'])); - return($smarty -> fetch (get_template_path("../setup/setup_step8.tpl"))); - } - - - /* check if given file is world readable */ - function is_world_readable($file) - { - clearstatcache(); - $p = fileperms($file); - $w_r = (decbin($p & 4) == TRUE); - return($w_r); - } - - - /* Create a backup of the currently existing configuration file. - */ - function create_backup() - { - $info= posix_getgrgid(posix_getgid()); - $webgroup = $info['name']; - if(is_writeable(CONFIG_DIR) && is_writeable(CONFIG_DIR."/".CONFIG_FILE)){ - $src = CONFIG_DIR."/".CONFIG_FILE; - $dst = CONFIG_DIR."/".CONFIG_FILE."_".date("Ymd"); - $dst_backup= $dst; - $i = 1; - while(file_exists($dst)){ - $dst = $dst_backup."-".$i; - $i ++; - } - if(copy($src,$dst)){ - $this->last_backup_name = $dst; - @chgrp($dst,$webgroup); - @chown($dst,"root"); - @chmod($dst,0640); - return(TRUE); - }else{ - return(FALSE); - } - }else{ - return(FALSE); - } - } - - - function save_object() - { - if(isset($_POST['step8_posted'])){ - - /* Get attributes */ - foreach($this->attributes as $attr){ - if(isset($_POST[$attr])){ - $this->$attr = validate($_POST[$attr]); - } - } - - /* Backup toggle */ - if(isset($_POST['create_backup_visible'])){ - if(isset($_POST['create_backup'])){ - $this->create_backup = TRUE; - }else{ - $this->create_backup = FALSE; - } - } - } - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/setup/class_setupStep_Checks.inc b/setup/class_setupStep_Checks.inc new file mode 100644 index 000000000..b9bbfbf27 --- /dev/null +++ b/setup/class_setupStep_Checks.inc @@ -0,0 +1,307 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("Installation check"); + $this->s_title_long = _("Basic installation checks"); + $this->s_info = _("Some basic checks for PHP version, ldap extension..."); + } + + + /* Execute and display template */ + function execute() + { + $this->run_checks(); + $smarty = get_smarty(); + $smarty->assign("basic" ,$this->basic_checks); + $smarty->assign("config" ,$this->config_checks); + $smarty->assign("is_writeable",$this->is_writeable); + return($smarty->fetch(get_template_path("setup_step2.tpl",TRUE,dirname(__FILE__)))); + } + + + /* Execute all checks */ + function run_checks() + { + $this->basic_checks = array(); + $this->config_checks = array(); + $this->is_writeable = array(); + + /* PHP version check */ + $N = _("Checking PHP version"); + $D = sprintf(_("PHP must be of version %s or %s or above for some functions."),"4.3.10","5.2.0"); + $S = _("GOsa requires functions that may not be available in older PHP versions, just update to a supported PHP version."); + $R = $this->check_php_version(); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking imap extension */ + $N = _("Checking for ldap module"); + $D = _("This is the main module used by GOsa and therefore really required."); + $S = _("The ldap module (PHP4-ldap/PHP5-ldap) is required to communicate with your ldap server."); + $R = is_callable("ldap_bind"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check for gettext support */ + $N = _("Checking for gettext support"); + $D = _("Gettext support is required for internationalized GOsa."); + $S = _("This should be activated while compiling your PHP. (--with-gettext)"); + $R = is_callable("bindtextdomain"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checing for iconv */ + $N = _("Checking for iconv support"); + $D = _("This module is used by GOsa to convert samba munged dial informations and is therefore required. "); + $S = _("This should be activated while compiling your PHP. (--with-iconv)"); + $R = is_callable("iconv"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check for installed mhash module */ + $N = _("Checking for mhash module"); + $D = _("To use SSHA encryption, you'll need this module. GOsa will run without it."); + $S = _("The mhash module for PHP 4/5 is not available, please install it. (php4-mhash/php5-mhash)"); + $R = is_callable("mhash"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Is imap module available */ + $N = _("Checking for imap module"); + $D = _("The IMAP module is needed to communicate with the IMAP server. It gets status informations, creates and deletes mail users."); + $S = _("This module is used to communicate with your mail server. Please install (PHP4-imap PHP5-imap)"); + $R = is_callable("imap_open"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check getacl in imap module */ + $N = _("Checking for getacl in imap"); + $D = _("The getacl support is needed for shared folder permissions. The standard IMAP module is not capable of reading acl's. You need a recend PHP version for this feature."); + $S = $D; + $R = is_callable("imap_getacl"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Mysql module loaded ? */ + $N = _("Checking for mysql module"); + $D = _("MySQL support is needed for reading GOfax reports from databases."); + $S = _("This module is required to communicate with database servers, for example used in phone and fax addons. Please install (PHP4-mysql PHP5-mysql)"); + $R = is_callable("mysql_query"); + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking for kadm5 module */ + $N = _("Checking for kadm5 module"); + $D = _("Managing users in kerberos requires the kadm5 module which is downloadable via PEAR network."); + $S = _("This module is required to manage user in kerberos, it is downloadable via PEAR network"); + $R = is_callable("kadm5_init_with_password"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Snmp module available ? */ + $N = _("Checking for snmp Module"); + $D = _("Simple Network Management Protocol (SNMP) is required for client monitoring."); + $S = _("This module is required for client monitoring. (PHP4-snmp/PHP5-snmp)"); + $R = is_callable("snmpget"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking for Cups module */ + $N = _("Checking for cups module"); + $D = _("In order to read available printers from IPP protocol instead of printcap files, you've to install the CUPS module."); + $S = $D; + $R = is_callable("cups_get_dest_list"); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking for F ping utility */ + $query= "LC_ALL=C LANG=C fping -v 2>&1"; + $output= shell_exec ($query); + $N = _("Checking for fping utility"); + $D = _("The fping utility is only used if you've got a thin client based terminal environment running."); + $S = _("The fping utility is only used in thin client based terminal environment."); + $R = preg_match("/^fping:/", $output); + $M = FALSE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Checking generate LM/NT password hashes */ + $query= "mkntpwd 2>&1"; + $output= shell_exec ($query); + $have_mkntpwd= preg_match("/^Usage: mkntpwd /", $output); + if (!$have_mkntpwd){ + $query= 'LC_ALL=C LANG=C perl -MCrypt::SmbHash -e "print join(q[:], ntlmgen $ARGV[0]), $/;" &>/dev/null'; + system ($query, $ret); + $have_mkntpwd |= ($ret == 0); + } + + $N = _("Password hashes"); + $D = _("In order to use SAMBA 2/3, you've to install some additional packages to generate password hashes."); + $S = _("In order to use samba 2/3 you've to install some additional packages to generate password hashes. (e.g. libmhash2)"); + $R = $have_mkntpwd; + $M = TRUE; + $this->basic_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + + /* PHP Configuration checks + */ + + /* Register_globals off */ + $N = _("register_globals"." ".""._("Off").""); + $D = _("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."); + $S = _("Search for 'register_globals' in your php.ini and switch it to 'Off'."); + $R = ini_get("register_globals") == 0; + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + + /* session lifetime set to >=86400 seconds ? */ + $N = ("session.gc_maxlifetime"." "." >= 86400"); + $D = _("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."); + $S = _("Search for 'session.gc_maxlifetime' in your php.ini and set it to 86400 or higher."); + $R = ini_get("session.gc_maxlifetime") >= 86400; + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Session auto start must be turned off */ + $session_auto_start = ini_get('session.auto_start'); + $N = _("session.auto_start"." ".""._("Off").""); + $D = _("In Order to use GOsa without any trouble, the session.auto_register option in your php.ini must be set to 'Off'."); + $S = _("Search for 'session.auto_start' in your php.ini and set it to 'Off'."); + $R = !$session_auto_start['local_value']; + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check if memory limit is set to 32 or > */ + $N = _("memory_limit")." "." >= 32"; + $D = _("GOsa needs at least 32MB of memory, less will cause unpredictable errors! Increase it for larger setups."); + $S = _("Search for 'memory_limit' in your php.ini and set it to '32M' or higher."); + $R = ini_get('memory_limit') >= 32 ; + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Implicit Flush disabled can increase performance */ + $N = _("implicit_flush")." ".""._("Off").""; + $D = _("This option influences the Output handling. Turn this Option off, to increase performance."); + $S = _("Search for 'implicit_flush' in your php.ini and set it to 'Off'."); + $R = ini_get('implicit_flush'); + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Check if execution time is set to 30 */ + $N = _("max_execution_time")." "." >= 30"; + $D = _("The Execution time should be at least 30 seconds, because some actions may consume more time."); + $S = _("Search for 'max_execution_time' in your php.ini and set it to '30' or higher."); + $R = ini_get("max_execution_time") >= 30 ; + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Expose php should be set to off */ + $N = _("expose_php")." "._("Off").""; + $D = _("Increase the server security by setting expose_php to 'off'. PHP won't send any Information about the server you are running in this case."); + $S = _("Search for 'expose_php' in your php.ini and set if to 'Off'."); + $R = !ini_get("expose_php"); + $M = FALSE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* Automatic quoting must be turned on */ + $N = _("magic_quotes_gpc")." "._("On").""; + $D = _("Increase your server security by setting magic_quotes_gpc to 'on'. PHP will escape all quotes in strings in this case."); + $S = _("Search for 'magic_quotes_gpc' in your php.ini and set it to 'On'."); + $R = ini_get('magic_quotes_gpc'); + $M = TRUE; + $this->config_checks[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + + /* Configuration file + */ + + /* Check if we can create a config file.*/ + $N = _("Configuration file writeable."); + $D = _("The Configuration file can't be written"); + $S = sprintf(_("The GOsa reads its configuration from a file located in (%s/%s). The setup can write the configuration directly in this file, if it is writeable."),CONFIG_DIR,CONFIG_FILE); + $R = ( file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR."/".CONFIG_FILE)) // is there a config file ? + || (!file_exists(CONFIG_DIR."/".CONFIG_FILE) && is_writeable(CONFIG_DIR)); // There is non, but can we create a file there ? + $M = FALSE; + $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); + + /* If we have writeaccess to the config dir, check if there is already a config file */ +# if($R){ +# +# /* check if there is already a config file. */ +# $N = _("No old configuration file."); +# $D = "";//_(""); +# $S = _("If there is already a configuration file, this file will be overwritten when GOsa setup finishes. Please move your old config file away."); +# $R = !file_exists(CONFIG_DIR."/".CONFIG_FILE); +# $M = FALSE; +# $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); +# } + } + + + function save_object() + { + /* If everything is fine, set this step to completed + * and allow switching to next setup step + */ + $failed = false; + foreach(array("basic_checks","config_checks","is_writeable") as $type){ + foreach($this->$type as $obj){ + + if($obj['MUST'] && !$obj['RESULT']){ + $failed = true; + break; + } + } + } + $this->is_completed = !$failed; + } + + + /* Check if current PHP version is compatible + with the current version of GOsa */ + function check_php_version() + { + if(preg_match("/^5/",phpversion())){ + return(version_compare(phpversion(),"5.2.0",">=")); + }else{ + return(version_compare(phpversion(),"4.3.10",">=")); + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_Config1.inc b/setup/class_setupStep_Config1.inc new file mode 100644 index 000000000..9a7afae5a --- /dev/null +++ b/setup/class_setupStep_Config1.inc @@ -0,0 +1,244 @@ + 6, + "pwminlen_active" => FALSE, + "pwdiffer" => 5, + "pwdiffer_active" => FALSE, + "externalpwdhook" => "/path/to/your/script username oldpassword newpassword", + "externalpwdhook_active" => FALSE); + + var $mail_settings = array("vacationdir" => "/etc/gosa/vacation", + "vacationdir_active" => FALSE); + + var $crypt_methods = array(); + var $mail_methods = array(); + + + var $attributes = array("peopleou","groupou","peopledn","uidbase","encryption","mail","theme","errorlvl","cyrusunixstyle", + "base_hook","base_hook_active"); + + function setup_step_5() + { + $this->update_strings(); + + $tmp = @passwordMethod::get_available_methods_if_not_loaded(); + foreach($tmp['name'] as $name){ + $this->crypt_methods[$name] = $name; + } + $tmp = $this->get_available_mail_classes(); + foreach($tmp['name'] as $name){ + $this->mail_methods[$name] = $name; + } + } + + + function update_strings() + { + $this->s_title = _("GOsa settings 1/3"); + $this->s_title_long = _("GOsa generic settings, page 1/3"); + $this->s_info = _("This dialog allows you to setup GOsa behaviour"); + } + + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("peopledns",array("uid","cn")); + $smarty->assign("crypt_methods",$this->crypt_methods); + $smarty->assign("mail_methods",$this->mail_methods); + $smarty->assign("themes",$this->get_themes()); + $smarty->assign("pwd_rules",$this->pwd_rules); + $smarty->assign("mail_settings",$this->mail_settings); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + $smarty->assign("warnings" ,$this->check()); + $smarty->assign("warnings_cnt" ,count($this->check())); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty -> fetch (get_template_path("../setup/setup_step5.tpl"))); + } + + + /* Returns the classnames auf the mail classes */ + function get_available_mail_classes() + { + $dir = opendir( "../include"); + $methods = array(); + $suffix = "class_mail-methods-"; + $lensuf = strlen($suffix); + $prefix = ".inc"; + $lenpre = strlen($prefix); + $i = 0; + while (($file = readdir($dir)) !== false){ + + if(stristr($file,$suffix)) { + $lenfile = strlen($file); + $methods['name'][$i] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); + $methods['file'][$i] = $file; + $methods[$i]['file'] = $file; + $methods[$i]['name'] = substr($file,$lensuf,($lenfile-$lensuf)-$lenpre); + $i++; + } + } + return($methods); + } + + function get_themes() + { + $dir = opendir( "../ihtml/themes/"); + $themes = array(); + while (($file = readdir($dir)) !== false){ + if(is_dir("../ihtml/themes/".$file) && !preg_match("/^\./",$file)){ + $themes[$file] = $file; + } + } + return($themes); + } + + function check() + { + $message = array(); + + if(preg_match("/,$/",$this->peopleou)){ + $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("People storage ou")); + } + + if(preg_match("/,$/",$this->groupou)){ + $message[] =sprintf(_("Don't add a trailing comma to '%s'."),_("Group storage ou")); + } + + if(!is_numeric($this->uidbase)){ + $message[] = _("Uid base must be numeric"); + } + + if(($this->pwd_rules['pwminlen_active']) && !is_numeric($this->pwd_rules['pwminlen'])){ + $message[] = _("The given password minimum length is not numeric."); + } + if(($this->pwd_rules['pwdiffer_active']) && !is_numeric($this->pwd_rules['pwdiffer'])){ + $message[] = _("The given password differ value is not numeric."); + } + return($message); + + } + + function save_object() + { + if(isset($_POST['step5_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate($_POST[$attr]); + } + } + + /* Get password settings */ + if(isset($_POST['pwdiffer_active'])){ + $this->pwd_rules['pwdiffer_active'] = TRUE; + if(isset($_POST['pwdiffer'])){ + $this->pwd_rules['pwdiffer'] = $_POST['pwdiffer']; + } + }else{ + $this->pwd_rules['pwdiffer_active'] = FALSE; + } + + /* Get password minimum length posts */ + if(isset($_POST['pwminlen_active'])){ + $this->pwd_rules['pwminlen_active'] = TRUE; + if(isset($_POST['pwminlen'])){ + $this->pwd_rules['pwminlen'] = $_POST['pwminlen']; + } + }else{ + $this->pwd_rules['pwminlen_active'] = FALSE; + } + + /* Mail settings */ + if(isset($_POST['vacationdir_active'])){ + $this->mail_settings['vacationdir_active'] = TRUE; + if(isset($_POST['vacationdir'])){ + $this->mail_settings['vacationdir'] = $_POST['vacationdir']; + } + }else{ + $this->mail_settings['vacationdir_active'] = FALSE; + } + + /* Mail settings */ + if(isset($_POST['externalpwdhook_active'])){ + $this->pwd_rules['externalpwdhook_active'] = TRUE; + if(isset($_POST['externalpwdhook'])){ + $this->pwd_rules['externalpwdhook'] = $_POST['externalpwdhook']; + } + }else{ + $this->pwd_rules['externalpwdhook_active'] = FALSE; + } + + /* Mail settings */ + if(isset($_POST['base_hook_active'])){ + $this->pwd_rules['base_hook_active'] = TRUE; + if(isset($_POST['base_hook'])){ + $this->pwd_rules['base_hook'] = $_POST['base_hook']; + } + }else{ + $this->pwd_rules['base_hook_active'] = FALSE; + } + } + + $tmp = $this->check(); + if(count($tmp) == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + }// if tempalte posted + + + /* Attributes that are interesting for configuration generation */ + function get_attributes() + { + $tmp = setup_step::get_attributes(); + foreach(array("pwd_rules","mail_settings") as $attr){ + $tmp[$attr]= $this->$attr; + } + return($tmp); + } +}// CLass + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_Config2.inc b/setup/class_setupStep_Config2.inc new file mode 100644 index 000000000..30dd7f931 --- /dev/null +++ b/setup/class_setupStep_Config2.inc @@ -0,0 +1,202 @@ + "{%sn}-{%givenName[2-4]}", + "idgen_active" => FALSE, + "minid" => "100", + "minid_active" => FALSE, + "wws_ou" => "ou=winstations", + "wws_ou_active" => FALSE, + "snapshot_active" => FALSE, + "snapshot_base" => "ou=snapshots,%base%", + "snapshot_ldap_base" => "%base%", + "snapshot_user" => "cn=ldapadmin,%base%", + "snapshot_password" => "", + "snapshot_server" => "%connection%"); + + var $samba_settings = array( "samba_sid" => "0-815-4711", + "samba_sid_active" => FALSE, + "samba_rid" => 1000, + "samba_rid_active" => FALSE); + var $attributes = array("strict","governmentmode","sambaidmapping","account_expiration"); + + function setup_step_6() + { + $this->update_strings(); + } + + + function update_strings() + { + $this->s_title = _("GOsa settings 2/3"); + $this->s_title_long = _("GOsa generic settings, page 2/3"); + $this->s_info = _("This dialog allows you to setup GOsa behaviour"); + } + + + function execute() + { + /* Update snapshot values, with already collected values */ + foreach($this->generic_settings as $key => $value){ + foreach(array("snapshot_ldap_base","snapshot_base","snapshot_user","snapshot_server") as $attr){ + foreach($this->parent->captured_values as $replace_name => $replace_value){ + if(is_string($replace_value)) { + $this->generic_settings[$attr] = preg_replace("/%".$replace_name."%/",$replace_value,$this->generic_settings[$attr]); + } + } + } + } + + $smarty = get_smarty(); + $smarty->assign("generic_settings",$this->generic_settings); + $smarty->assign("samba_settings",$this->samba_settings); + $smarty->assign("warnings" ,$this->check()); + $smarty->assign("warnings_cnt" ,count($this->check())); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + return($smarty -> fetch (get_template_path("../setup/setup_step6.tpl"))); + } + + function save_object() + { + if(isset($_POST['step6_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate($_POST[$attr]); + } + } + + if(isset($_POST['minid_active'])){ + $this->generic_settings['minid_active'] = TRUE; + if(isset($_POST['minid'])){ + $this->generic_settings['minid'] = $_POST['minid']; + } + }else{ + $this->generic_settings['minid_active'] = FALSE; + } + + if(isset($_POST['wws_ou_active'])){ + $this->generic_settings['wws_ou_active'] = TRUE; + if(isset($_POST['wws_ou'])){ + $this->generic_settings['wws_ou'] = $_POST['wws_ou']; + } + }else{ + $this->generic_settings['wws_ou_active'] = FALSE; + } + + /* Generic settings */ + if(isset($_POST['idgen_active'])){ + $this->generic_settings['idgen_active'] = TRUE; + if(isset($_POST['idgen'])){ + $this->generic_settings['idgen'] = $_POST['idgen']; + } + }else{ + $this->generic_settings['idgen_active'] = FALSE; + } + if(isset($_POST['snapshot_active'])){ + $this->generic_settings['snapshot_active'] = TRUE; + if(isset($_POST['snapshot_base'])){ + $this->generic_settings['snapshot_base'] = $_POST['snapshot_base']; + } + if(isset($_POST['snapshot_user'])){ + $this->generic_settings['snapshot_user'] = $_POST['snapshot_user']; + } + if(isset($_POST['snapshot_password'])){ + $this->generic_settings['snapshot_password'] = $_POST['snapshot_password']; + } + if(isset($_POST['snapshot_server'])){ + $this->generic_settings['snapshot_server'] = $_POST['snapshot_server']; + } + if(isset($_POST['snapshot_ldap_base'])){ + $this->generic_settings['snapshot_ldap_base'] = $_POST['snapshot_ldap_base']; + } + }else{ + $this->generic_settings['snapshot_active'] = FALSE; + } + + /* Samba settings */ + if(isset($_POST['samba_sid_active'])){ + $this->samba_settings['samba_sid_active'] = TRUE; + if(isset($_POST['samba_sid'])){ + $this->samba_settings['samba_sid'] = $_POST['samba_sid']; + } + }else{ + $this->samba_settings['samba_sid_active'] = FALSE; + } + if(isset($_POST['samba_rid_active'])){ + $this->samba_settings['samba_rid_active'] = TRUE; + if(isset($_POST['samba_rid'])){ + $this->samba_settings['samba_rid'] = $_POST['samba_rid']; + } + }else{ + $this->samba_settings['samba_rid_active'] = FALSE; + } + + } + + $tmp = $this->check(); + if(count($tmp) == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + } + + + function check() + { + $message = array(); + + if(isset($this->generic_settings['minid_active']) && !is_numeric($this->generic_settings['minid'])){ + $message[] = sprintf(_("The specified value for '%s' must be a numeric value"),_("GID / UID min id")); + } + + return($message); + } + + + /* Attributes that are interesting for configuration generation */ + function get_attributes() + { + $tmp = setup_step::get_attributes(); + foreach(array("samba_settings","generic_settings") as $attr){ + $tmp[$attr]= $this->$attr; + } + return($tmp); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_Config3.inc b/setup/class_setupStep_Config3.inc new file mode 100644 index 000000000..728f5808a --- /dev/null +++ b/setup/class_setupStep_Config3.inc @@ -0,0 +1,195 @@ + false, + "forceglobals" => true, + "forcessl" => false, + "warnssl" => true, + "ppd_path" => "/var/spool/ppd/", + "ppd_path_active" => FALSE, + "compile" => "/var/spool/gosa", + "debuglevel" => 0, + "session_lifetime" => 7200, + "max_ldap_query_time" => "5.0", + "max_ldap_query_time_active" => FALSE, + + "mailQueueScriptPath" => "/usr/bin/sudo /usr/local/sbin/mailqueue %action %id %server", + "mailQueueScriptPath_active" => FALSE, + + "auto_network_hook" => "/etc/gosa/net-resolv.sh", + "auto_network_hook_active" => FALSE, + + "notifydir" => "", + "notifydir_active" => FALSE, + + "noprimarygroup" => FALSE, + "smbhash" => 'SMBHASH'); + + + function setup_step_6a() + { + $this->update_strings(); + + /* Look for samba password generation method */ + 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 "print join(q[:], ntlmgen \$ARGV[0]), $/;"'; + } + + $this->optional['smbhash'] = $pwdhash; + } + + + function update_strings() + { + $this->s_title = _("GOsa settings 3/3"); + $this->s_title_long = _("GOsa generic settings, page 3/3"); + $this->s_info = _("This dialog allows you to setup GOsa behaviour"); + } + + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + + $smarty->assign("optional", $this->optional); + + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + $smarty->assign("warnings" ,$this->check()); + $smarty->assign("warnings_cnt" ,count($this->check())); + + return($smarty -> fetch (get_template_path("../setup/setup_step6a.tpl"))); + } + + + function save_object() + { + if(isset($_POST['step6a_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate($_POST[$attr]); + } + } + + foreach(array("noprimarygroup","enableCopyPaste","forceglobals","forcessl","warnssl","compile","debuglevel","session_lifetime","smbhash") as $name){ + if(isset($_POST[$name])){ + $this->optional[$name] = stripslashes($_POST[$name]); + } + } + + if(isset($_POST['ppd_path_active'])){ + $this->optional['ppd_path_active'] = TRUE; + if(isset($_POST['ppd_path'])){ + $this->optional['ppd_path'] = $_POST['ppd_path']; + } + }else{ + $this->optional['ppd_path_active'] = FALSE; + } + + if(isset($_POST['max_ldap_query_time_active'])){ + $this->optional['max_ldap_query_time_active'] = TRUE; + if(isset($_POST['max_ldap_query_time'])){ + $this->optional['max_ldap_query_time'] = $_POST['max_ldap_query_time']; + } + }else{ + $this->optional['max_ldap_query_time_active'] = FALSE; + } + + if(isset($_POST['mailQueueScriptPath_active'])){ + $this->optional['mailQueueScriptPath_active'] = TRUE; + if(isset($_POST['mailQueueScriptPath'])){ + $this->optional['mailQueueScriptPath'] = $_POST['mailQueueScriptPath']; + } + }else{ + $this->optional['mailQueueScriptPath_active'] = FALSE; + } + + if(isset($_POST['auto_network_hook_active'])){ + $this->optional['auto_network_hook_active'] = TRUE; + if(isset($_POST['auto_network_hook'])){ + $this->optional['auto_network_hook'] = $_POST['auto_network_hook']; + } + }else{ + $this->optional['auto_network_hook_active'] = FALSE; + } + + if(isset($_POST['notifydir_active'])){ + $this->optional['notifydir_active'] = TRUE; + if(isset($_POST['notifydir'])){ + $this->optional['notifydir'] = $_POST['notifydir']; + } + }else{ + $this->optional['notifydir_active'] = FALSE; + } + } + + $tmp = $this->check(); + if(count($tmp) == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + } + + + function check() + { + $message = array(); + + if(!is_numeric( $this->optional['session_lifetime'])){ + $message[] = _("Session lifetime must be a numeric value."); + } + + if(!is_numeric( $this->optional['max_ldap_query_time'])){ + $message[] = _("Maximal ldap query time must be a numeric value. "); + } + + return($message); + } + + + /* Attributes that are interesting for configuration generation */ + function get_attributes() + { + $tmp = setup_step::get_attributes(); + foreach(array("optional") as $attr){ + $tmp[$attr]= $this->$attr; + } + return($tmp); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_Finish.inc b/setup/class_setupStep_Finish.inc new file mode 100644 index 000000000..44eeefcb6 --- /dev/null +++ b/setup/class_setupStep_Finish.inc @@ -0,0 +1,229 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("Configuration file"); + $this->s_info = _("In this step the configuration file will be created."); + $this->s_title_long = _("Saving configuration file"); + } + + + function get_conf_data() + { + $smarty = get_smarty(); + $smarty->assign("cv",$this->parent->captured_values); + $str = $smarty->fetch(CONFIG_TEMPLATE_DIR.$this->gosa_conf_contrib); + return($str); + } + + + function execute() + { + + $info= posix_getgrgid(posix_getgid()); + $webgroup = $info['name']; + + + /* Check if there is currently an active gosa.conf + */ + $exists = file_exists(CONFIG_DIR."/".CONFIG_FILE); + + /* Check if existing config file is writeable */ + if($exists){ + $writeable = is_writeable(CONFIG_DIR."/".CONFIG_FILE); + }else{ + $writeable = is_writeable(CONFIG_DIR); + } + + /* Redirect to GOsa login */ + if(isset($_POST['use_gosa'])){ + session_destroy(); + header("Location: index.php"); + exit(); + } + + /* Downlaod config */ + if(isset($_POST['getconf'])){ + + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + header("Cache-Control: no-cache"); + header("Pragma: no-cache"); + header("Cache-Control: post-check=0, pre-check=0"); + header("Content-type: text/plain"); + + if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) || + preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){ + header('Content-Disposition: filename="'.CONFIG_FILE.'"'); + } else { + header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"'); + } + + $str = $this->get_conf_data(); + $str = preg_replace("/\n[ ]*\n/","",$str); + + echo $this->get_conf_data(); + exit(); + } + + + /* Try to save configuration */ + $abort = FALSE; + $err_msg = ""; + if(isset($_POST['saveconf'])){ + if($exists && $this->create_backup){ + if(!$this->create_backup()){ + $abort = TRUE; + $err_msg = _("Could not create requested configuration file backup. Aborted writing config file. Please check folder permission and try again. Or use the manual method if this can not be fixed anyway."); + } + } + + if(!$abort){ + + /* Try to create file handle */ + $fp = @fopen(CONFIG_DIR."/".CONFIG_FILE, "w"); + + if(!$fp){ + $err_msg = sprintf(_("Can not create handle on file '%s', the configuration could not be written. Please check folder permission and try again. Or use the manual method if this can not be fixed anyway."),CONFIG_DIR."/".CONFIG_FILE); + $abort =TRUE; + }else{ + + $data = $this->get_conf_data(); + if(!fwrite($fp,$data)){ + $err_msg = sprintf(_("Can not write file '%s'. Please check folder permission and try again. Or use the manual method if this can not be fixed anyway."),CONFIG_DIR."/".CONFIG_FILE); + $abort =TRUE; + }else{ + + @chgrp(CONFIG_DIR."/".CONFIG_FILE,$webgroup); + @chown(CONFIG_DIR."/".CONFIG_FILE,"root"); + @chmod(CONFIG_DIR."/".CONFIG_FILE,0640); + } + } + } + } + + + if($exists && $this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){ + $err_msg = _("Your configuration file is currently world readable. This is a big security risk. Please updated the file permissions as shown in the manual configuration part below."); + } + + $smarty = get_smarty(); + $smarty->assign("save_requested", isset($_POST['saveconf'])); + $smarty->assign("err_msg",$err_msg); + $smarty->assign("webgroup", $webgroup); + $smarty->assign("create_backup" , $this->create_backup); + $smarty->assign("CONFIG_DIR",CONFIG_DIR); + $smarty->assign("CONFIG_FILE" , CONFIG_FILE); + $smarty->assign("exists",$exists); + + $smarty->assign("msg1", sprintf(_("If you want the setup routine to write the configuration file, use the 'Save configuration' button below. If you prefer to copy the '%s' manually to '%s' you can download the configuration file by using the 'Download configuration' button."), CONFIG_FILE,CONFIG_DIR)); + + $smarty->assign("msg2", sprintf(_("After placing the file under %s, place make sure that the webserver user is able to read %s, while other users shouldn't. You may want to execute these commands to achieve this requirement"),CONFIG_DIR,CONFIG_FILE)); + + $smarty->assign("last_backup_name",$this->last_backup_name); + $smarty->assign("writeable",$writeable); + $smarty->assign("cv",$this->parent->captured_values); + $smarty->assign("msg_permissions", + sprintf(_("The following file(s), folders(s) must be writeable for the web-user '%s'."),$info['name'])); + return($smarty -> fetch (get_template_path("../setup/setup_step8.tpl"))); + } + + + /* check if given file is world readable */ + function is_world_readable($file) + { + clearstatcache(); + $p = fileperms($file); + $w_r = (decbin($p & 4) == TRUE); + return($w_r); + } + + + /* Create a backup of the currently existing configuration file. + */ + function create_backup() + { + $info= posix_getgrgid(posix_getgid()); + $webgroup = $info['name']; + if(is_writeable(CONFIG_DIR) && is_writeable(CONFIG_DIR."/".CONFIG_FILE)){ + $src = CONFIG_DIR."/".CONFIG_FILE; + $dst = CONFIG_DIR."/".CONFIG_FILE."_".date("Ymd"); + $dst_backup= $dst; + $i = 1; + while(file_exists($dst)){ + $dst = $dst_backup."-".$i; + $i ++; + } + if(copy($src,$dst)){ + $this->last_backup_name = $dst; + @chgrp($dst,$webgroup); + @chown($dst,"root"); + @chmod($dst,0640); + return(TRUE); + }else{ + return(FALSE); + } + }else{ + return(FALSE); + } + } + + + function save_object() + { + if(isset($_POST['step8_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate($_POST[$attr]); + } + } + + /* Backup toggle */ + if(isset($_POST['create_backup_visible'])){ + if(isset($_POST['create_backup'])){ + $this->create_backup = TRUE; + }else{ + $this->create_backup = FALSE; + } + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_Language.inc b/setup/class_setupStep_Language.inc new file mode 100644 index 000000000..d7a759383 --- /dev/null +++ b/setup/class_setupStep_Language.inc @@ -0,0 +1,78 @@ +lang = get_browser_language(); + $this->lang_selected = ""; + $this->is_enabled = TRUE; + $this->is_active = TRUE; + $this->update_strings(); + } + + function update_strings() + { + $this->s_title = _("Language setup"); + $this->s_title_long = _("Language setup"); + $this->s_info = _("This step is allows you to select your prefered language."); + } + + function execute() + { + $this->languages = array("" => _("Automatic"), + "de_DE" => _("German"), + "fr_FR" => _("French"), + "en_EN" => _("English"), + "ru_RU" => _("Russian")); + + $smarty = get_smarty(); + $smarty->assign("languages", $this->languages); + $smarty->assign("lang", $this->lang); + $smarty->assign("lang_selected",$this->lang_selected); + return($smarty->fetch(get_template_path("setup_step1.tpl",TRUE,dirname(__FILE__)))); + } + + function save_object() + { + if((isset($_POST['lang_selected'])) && isset($this->languages[$_POST['lang_selected']])) { + $this->lang_selected = $_POST['lang_selected']; + $this->is_completed = TRUE; + + if($this->lang_selected != ""){ + $_SESSION['lang'] = $this->lang_selected; + }else{ + $_SESSION['lang'] = $this->lang; + } + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_Ldap.inc b/setup/class_setupStep_Ldap.inc new file mode 100644 index 000000000..3e3bc899a --- /dev/null +++ b/setup/class_setupStep_Ldap.inc @@ -0,0 +1,161 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("Ldap settings"); + $this->s_title_long = _("Ldap connection setup"); + $this->s_info = _("This dialog allows the basic configuration of GOsa's behaviour and properties in your main configuration."); + } + + + function execute() + { + $smarty = get_smarty(); + foreach($this->attributes as $attr){ + $smarty->assign($attr,$this->$attr); + } + + /* Assign connection status */ + $smarty->assign("connection_status",$this->get_connection_status()); + + /* Handle namingContext detection */ + $attr = @LDAP::get_naming_contexts($this->connection); + unset($attr['count']); + $smarty->assign("namingContexts",$attr); + $smarty->assign("namingContextsCount",count($attr)); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + + /* Addign resolved users */ + $smarty->assign("resolve_user",$this->resolve_user); + if($this->resolve_user){ + $tmp = $this->resolve_user(); + $smarty->assign("resolved_users",$tmp); + $smarty->assign("resolved_users_count",count($tmp)); + $smarty->assign("resolve_filter",$this->resolve_filter); + } + return($smarty -> fetch (get_template_path("../setup/setup_step4.tpl"))); + } + + function get_connection_status() + { + $this->connect_id = FALSE; + $this->bind_id = FALSE; + + @ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); + $this->connect_id = @ldap_connect($this->connection); + + @ldap_set_option($this->connect_id, LDAP_OPT_PROTOCOL_VERSION, 3); + $this->bind_id = @ldap_bind($this->connect_id, $this->admin, $this->password); + + if(!$this->bind_id){ + $str = sprintf(_("Anonymous bind failed on server '%s'."),$this->connection); + if(!empty($this->admin)){ + $str = sprintf(_("Bind as user '%s' failed on server '%s'."),$this->admin,$this->connection); + } + return("".$str.""); + }else{ + if(empty($this->admin)){ + $str = sprintf(_("Anonymous bind successful on server '%s'. Please specify user and password."),$this->connection); + return("".$str.""); + }else{ + $str = sprintf(_("Bind as user '%s' successful on server '%s'."),$this->admin,$this->connection); + return("".$str.""); + } + } + } + + + function resolve_user() + { + $filter = $this->resolve_filter; + $ldap = new LDAP("","",$this->connection); + $ldap->cd($this->base); + $ldap->search("(&(objectClass=person)(|(uid=".$filter.")(cn=".$filter.")))"); + $tmp = array(); + while($attrs = $ldap->fetch()){ + $tmp[$attrs['dn']]=$attrs['dn']; + natcasesort($tmp); + } + return($tmp); + } + + + function save_object() + { + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = $_POST[$attr]; + } + } + + if(isset($_POST['resolve_user'])){ + $this->resolve_user = !$this->resolve_user; + } + + if(isset($_POST['resolve_filter'])){ + $this->resolve_filter = $_POST['resolve_filter']; + } + + if(isset($_POST['use_selected_user'])){ + + if(isset($_POST['admin_to_use'])){ + $this->admin = $_POST['admin_to_use']; + $this->resolve_user = false; + } + } + + $this->get_connection_status(); + if($this->bind_id){ + $this->is_completed =TRUE; + }else{ + $this->is_completed =FALSE; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_License.inc b/setup/class_setupStep_License.inc new file mode 100644 index 000000000..db861f868 --- /dev/null +++ b/setup/class_setupStep_License.inc @@ -0,0 +1,81 @@ +update_strings(); + } + + + function load_license() + { + if(!file_exists("../setup/license.txt")){ + $this->License = "License not found. Setup stops here."; + $this->license_found = false; + }else{ + $fp = fopen("../setup/license.txt","r"); + $this->License = ""; + while (!feof($fp)){ + $this->License .= fread($fp, 255); + } + $this->license_found = true; + } + } + + + function update_strings() + { + $this->s_title = _("License"); + $this->s_title_long = _("GNU / GPL-License"); + $this->s_info = _("GNU / GPL-License"); + } + + + function execute() + { + $this->load_license(); + + $smarty = get_smarty(); + $smarty -> assign("License",nl2br($this->License)); + $smarty -> assign("license_found",$this->license_found); + + return($smarty -> fetch (get_template_path("../setup/setup_step3.tpl"))); + } + + + function save_object() + { + if($this->license_found){ + $this->is_completed = true; + }else{ + $this->is_completed = false; + } + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/setup/class_setupStep_Schema.inc b/setup/class_setupStep_Schema.inc new file mode 100644 index 000000000..6dba41c0a --- /dev/null +++ b/setup/class_setupStep_Schema.inc @@ -0,0 +1,226 @@ +update_strings(); + } + + + function update_strings() + { + $this->s_title = _("Ldap schema check"); + $this->s_title_long = _("Ldap schema check"); + $this->s_info = _("This dialog checks your ldap schema setup"); + } + + + function execute() + { + $this->check_schema(); + $failed_checks = 0 ; + foreach($this->checked as $val) { + if(!$val['STATUS']){ + $failed_checks ++; + } + } + + if($failed_checks == 0){ + $this->is_completed = TRUE; + }else{ + $this->is_completed = FALSE; + } + + $smarty = get_smarty(); + $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes"))); + $smarty->assign("schema_readable",$this->schema_readable); + $smarty->assign("enable_schema_check",$this->enable_schema_check); + $smarty->assign("checks",$this->checked); + $smarty->assign("not_checked",$this->not_checked); + $smarty->assign("failed_checks",$failed_checks); + return($smarty -> fetch (get_template_path("../setup/setup_step7.tpl"))); + } + + function check_schema_version($description, $version) + { + $desc= preg_replace("/^.* DESC\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $description); + return preg_match("/\(v$version\)/", $desc); + } + + + function save_object() + { + if(isset($_POST['step7_posted'])){ + + /* Get attributes */ + foreach($this->attributes as $attr){ + if(isset($_POST[$attr])){ + $this->$attr = validate($_POST[$attr]); + } + } + } + } + + + function check_schema() + { + $cfg = $this->parent->captured_values; + $messages= array(); + + /* Get objectclasses */ + $ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['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))); + } + + + /* Which samba version do we use? */ + if(isset($objectclasses['sambaSamAccount'])){ + $this->samba_version = 3; + } elseif(isset($objectclasses['sambaAccount'])) { + $this->samba_version = 2; + }else{ + $this->samba_version = 0; + } + + /* This is the default block used for each entry. + * to avoid unset indexes. + */ + $def_check = array("REQUIRED_VERSION" => "0", + "SCHEMA_FILES" => array(), + "CLASSES_REQUIRED" => array(), + "STATUS" => FALSE, + "IS_MUST_HAVE" => FALSE, + "MSG" => "", + "INFO" => "");#_("There is currently no information specified for this schema extension.")); + + + /* The gosa base schema */ + $checks['gosaObject'] = $def_check; + $checks['gosaObject']['REQUIRED_VERSION'] = "2.4"; + $checks['gosaObject']['SCHEMA_FILES'] = array("gosa+samba3.schema","gosa.schema"); + $checks['gosaObject']['CLASSES_REQUIRED'] = array("gosaObject"); + $checks['gosaObject']['IS_MUST_HAVE'] = TRUE; + + /* GOsa Account class */ + $checks["gosaAccount"]["REQUIRED_VERSION"]= "2.4"; + $checks["gosaAccount"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema"); + $checks["gosaAccount"]["CLASSES_REQUIRED"]= array("gosaAccount"); + $checks["gosaAccount"]["IS_MUST_HAVE"] = TRUE; + $checks["gosaAccount"]["INFO"] = _("Used to store account specific informations."); + + /* GOsa lock entry, used to mark currently edited objects as 'in use' */ + $checks["gosaLockEntry"]["REQUIRED_VERSION"] = "2.4"; + $checks["gosaLockEntry"]["SCHEMA_FILES"] = array("gosa+samba3.schema","gosa.schema"); + $checks["gosaLockEntry"]["CLASSES_REQUIRED"] = array("gosaLockEntry"); + $checks["gosaLockEntry"]["IS_MUST_HAVE"] = TRUE; + $checks["gosaLockEntry"]["INFO"] = _("Used to lock currently edited entries to avoid multiple changes at the same time."); + + /* Some other checks */ + foreach(array( + "gosaCacheEntry" => array("version" => "2.4"), + "gosaDepartment" => array("version" => "2.4"), + "goFaxAccount" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"), + "goFaxSBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"), + "goFaxRBlock" => array("version" => "1.0.4", "class" => "gofaxAccount","file" => "gofax.schema"), + "gosaUserTemplate" => array("version" => "2.4", "class" => "posixAccount","file" => "nis.schema"), + "gosaMailAccount" => array("version" => "2.4", "class" => "mailAccount","file" => "gosa+samba3.schema"), + "gosaProxyAccount" => array("version" => "2.4", "class" => "proxyAccount","file" => "gosa+samba3.schema"), + "gosaApplication" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.schema"), + "gosaApplicationGroup" => array("version" => "2.4", "class" => "appgroup","file" => "gosa.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"), + "goNtpServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"), + "goSyslogServer" => array("version" => "2.4", "class" => "terminals","file" => "goto.schema"), + "goLdapServer" => array("version" => "2.4"), + "goCupsServer" => array("version" => "2.4", "class" => array("posixAccount", "terminals"),), + "goImapServer" => array("version" => "2.4", "class" => array("mailAccount", "mailgroup"),"file" => "gosa+samba3.schema"), + "goKrbServer" => array("version" => "2.4"), + "goFaxServer" => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"), + ) as $name => $values){ + + $checks[$name] = $def_check; + if(isset($values['version'])){ + $checks[$name]["REQUIRED_VERSION"] = $values['version']; + } + if(isset($values['file'])){ + $checks[$name]["SCHEMA_FILES"] = array($values['file']); + } + $checks[$name]["CLASSES_REQUIRED"] = array($name); + } + + foreach($checks as $name => $value){ + foreach($value['CLASSES_REQUIRED'] as $class){ + + if(!isset($objectclasses[$name])){ + $checks[$name]['STATUS'] = FALSE; + if($value['IS_MUST_HAVE']){ + $checks[$name]['MSG'] = sprintf(_("The required objectClass '%s' is not present in your schema setup"),$class); + }else{ + $checks[$name]['MSG'] = sprintf(_("The optional objectClass '%s' is not present in your schema setup"),$class); + } + }elseif(!$this->check_schema_version($objectclasses[$name],$value['REQUIRED_VERSION'])){ + $checks[$name]['STATUS'] = FALSE; + + if($value['IS_MUST_HAVE']){ + $checks[$name]['MSG'] = sprintf(_("The required objectclass '%s' does not have version %s"), $class, $value['REQUIRED_VERSION']); + }else{ + $checks[$name]['MSG'] = sprintf(_("The optional objectclass '%s' does not have version %s"), $class, $value['REQUIRED_VERSION']); + } + }else{ + $checks[$name]['STATUS'] = TRUE; + $checks[$name]['MSG'] = sprintf(_("Class(es) available")); + } + } + } + + $this->checked = $checks; + $tmp = $objectclasses; + $not_checked = array(); + foreach($tmp as $name => $val){ + $desc = "no description."; + if(preg_match("/DESC/",$val)){ + $desc = preg_replace("/^.*DESC[ ]*'/i","",$val) ; + $desc = preg_replace("/'.*$/i","",$desc) ; + } + $not_checked[$name] = $desc; + } + + $this->not_checked = $not_checked; + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?>