From 48a95410dbdb33a95e639cc64e6b3e917ae603ac Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 14 Nov 2005 14:51:58 +0000 Subject: [PATCH] added enhanced validation hooks for: - tmp-dir (writable) - files- & backup-dir (writable, not in docroot) - mailserver configuration (also syncs the values with emailadmin) --- setup/config.php | 9 ++- setup/inc/functions.inc.php | 44 +++++++++++ setup/inc/hook_config_validate.inc.php | 55 ++++++++----- setup/index.php | 82 ++++++-------------- setup/lang/phpgw_de.lang | 8 +- setup/lang/phpgw_en.lang | 8 +- setup/templates/default/config.tpl | 102 +++++++++++++------------ 7 files changed, 177 insertions(+), 131 deletions(-) diff --git a/setup/config.php b/setup/config.php index 0a965e00c9..445aa0fbae 100644 --- a/setup/config.php +++ b/setup/config.php @@ -78,14 +78,15 @@ { if($GLOBALS['egw_info']['server']['found_validation_hook'] && @function_exists($setting)) { - call_user_func($setting,$newsettings); + $setting($newsettings); if($GLOBALS['config_error']) { - $GLOBALS['error'] .= '
' . lang($GLOBALS['config_error']) . ' '; + $GLOBALS['error'] .= ''.$GLOBALS['config_error'] ."
\n"; $GLOBALS['config_error'] = ''; /* Bail out, stop writing config data */ break; } + $value = $newsettings[$setting]; // it might be changed by the validation hook } /* Don't erase passwords, since we also do not print them below */ if(empty($value) && !(stristr($setting,'passwd') || stristr($setting,'password') || stristr($setting,'root_pw'))) @@ -153,7 +154,7 @@ $vars = $t->get_undefined('body'); $GLOBALS['egw_setup']->hook('config','setup'); - while(list($null,$value) = each($vars)) + foreach($vars as $value) { $valarray = explode('_',$value); $type = $valarray[0]; @@ -222,7 +223,7 @@ .'please check your LDAP server configuration') . '.'); } - $GLOBALS['egw_setup']->html->show_alert_msg('Error',$GLOBALS['error']); + $GLOBALS['egw_setup']->html->show_alert_msg('Error',$GLOBALS['error'].'

'); } $t->pfp('out','body'); diff --git a/setup/inc/functions.inc.php b/setup/inc/functions.inc.php index b735aa1b21..ad9ff28a19 100644 --- a/setup/inc/functions.inc.php +++ b/setup/inc/functions.inc.php @@ -48,6 +48,50 @@ define('SEP',filesystem_separator()); + /** + * Checks if a directory exists, is writable by the webserver and optionaly is in the docroot + * + * @param string $dir path + * @param string &$msg error-msg: 'does not exist', 'is not writeable by the webserver' or 'is in the webservers docroot' (run through lang) + * @param boolean $check_in_docroot=false run an optional in docroot check + * @return boolean + */ + function check_dir($dir,&$msg,$check_in_docroot=false) + { + if (!@is_dir($dir) && !(@is_writeable(dirname($dir)) && @mkdir($dir,0700,true))) + { + $msg = lang('does not exist'); + return false; + } + if (!@is_writeable($dir)) + { + $msg = lang('is not writeable by the webserver'); + return false; + } + if ($check_in_docroot) + { + $docroots = array(EGW_SERVER_ROOT,$_SERVER['DOCUMENT_ROOT']); + $dir = realpath($dir); + + foreach ($docroots as $docroot) + { + $len = strlen($docroot); + + if ($docroot == substr($dir,0,$len)) + { + $rest = substr($dir,$len); + + if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR) + { + $msg = lang('is in the webservers docroot'); + return false; + } + } + } + } + return true; + } + /** * function to handle multilanguage support * diff --git a/setup/inc/hook_config_validate.inc.php b/setup/inc/hook_config_validate.inc.php index 15fbb2dd78..7ba11302de 100644 --- a/setup/inc/hook_config_validate.inc.php +++ b/setup/inc/hook_config_validate.inc.php @@ -18,32 +18,49 @@ */ $GLOBALS['egw_info']['server']['found_validation_hook'] = True; - function in_docroot($path='') + function mail_server($settings) { - $docroots = array(EGW_SERVER_ROOT,$_SERVER['DOCUMENT_ROOT']); - - foreach($docroots as $docroot) + if (!$settings['mail_server'] || !$settings['mail_server_type'] || !$settings['smtp_server']) { - $len = strlen($docroot); - - if($docroot == substr($path,0,$len)) - { - $rest = substr($path,$len); - - if(!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR) - { - return True; - } - } + $GLOBALS['config_error'] = lang('Missing or uncomplete mailserver configuration'); } - return False; + if (@file_exists('../emailadmin/inc/class.bo.inc.php') && $GLOBALS['egw_setup']->table_exist(array('egw_emailadmin'))) + { + $emailadmin =& CreateObject('emailadmin.bo',-1,false); // false=no session stuff + if (is_object($emailadmin)) + { + $emailadmin->setDefaultProfile($settings); + } + else { echo "cant instaciate"; exit; } + } + else { echo "no emailadmin"; exit; } } + function temp_dir($settings) + { + if (!check_dir($settings['temp_dir'],$error_msg)) + { + $GLOBALS['config_error'] = lang("Your temporary directory '%1' %2",$settings['temp_dir'],$error_msg); + } + } + function files_dir($settings) { - if(in_docroot($settings['files_dir'])) + if (!check_dir($settings['files_dir'],$error_msg,true)) { - $GLOBALS['config_error'] = 'Path to user and group files HAS TO BE OUTSIDE of the webservers document-root!!!'; + $GLOBALS['config_error'] = lang("Your files directory '%1' %2",$settings['files_dir'],$error_msg); + } + } + + function backup_dir(&$settings) + { + if (@is_writeable($settings['files_dir']) && !$settings['backup_dir'] && $settings['file_store_contents'] == 'filesystem') + { + $settings['backup_dir'] = $settings['files_dir'].'/db_backup'; + } + if (!check_dir($settings['backup_dir'],$error_msg,true)) + { + $GLOBALS['config_error'] = lang("Your backup directory '%1' %2",$settings['backup_dir'],$error_msg); } } @@ -129,7 +146,7 @@ mcrypt_check_sanity(); if(!@$GLOBALS['ciphers'][$settings['mcrypt_algo']][$settings['mcrypt_mode']]) { - $GLOBALS['config_error'] = 'Invalid Mcrypt Algorithm/Mode combination'; + $GLOBALS['config_error'] = lang('Invalid Mcrypt Algorithm/Mode combination'); } } } diff --git a/setup/index.php b/setup/index.php index 8204e07667..d3483df0c5 100644 --- a/setup/index.php +++ b/setup/index.php @@ -371,7 +371,7 @@ $setup_tpl->set_var('V_db_filled_block',$db_filled_block); break; case 10: - $setup_tpl->set_var('tablescurrent',lang('Your applications are current')); + $setup_tpl->set_var('tablescurrent',lang('Your eGroupWare API is current')); $setup_tpl->set_var('uninstall_all_applications',lang('Uninstall all applications')); $setup_tpl->set_var('insanity',lang('Insanity')); $setup_tpl->set_var('dropwarn',lang('Your tables will be dropped and you will lose data')); @@ -388,42 +388,6 @@ break; } -function check_dir($dir,&$msg,$check_in_docroot=false) -{ - if (!@is_dir($dir) && !(@is_writeable(dirname($dir)) && @mkdir($dir,0700,true))) - { - $msg = lang('does not exist'); - return false; - } - if (!@is_writeable($dir)) - { - $msg = lang('is not writeable by the webserver'); - return false; - } - if ($check_in_docroot) - { - $docroots = array(EGW_SERVER_ROOT,$_SERVER['DOCUMENT_ROOT']); - $dir = realpath($dir); - - foreach ($docroots as $docroot) - { - $len = strlen($docroot); - - if ($docroot == substr($dir,0,$len)) - { - $rest = substr($dir,$len); - - if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR) - { - $msg = lang('is in the webservers docroot'); - return false; - } - } - } - } - return true; -} - // Config Section $setup_tpl->set_var('config_step_text',lang('Step %1 - Configuration',2)); $GLOBALS['egw_info']['setup']['stage']['config'] = $GLOBALS['egw_setup']->detection->check_config(); @@ -456,6 +420,10 @@ function check_dir($dir,&$msg,$check_in_docroot=false) { $config_msg = lang("Your temporary directory '%1' %2",$config['temp_dir'],$error_msg); } + if (!check_dir($config['files_dir'],$error_msg,true)) + { + $config_msg .= ($config_msg?"
\n":'').lang("Your files directory '%1' %2",$config['files_dir'],$error_msg); + } // set and create the default backup_dir if (@is_writeable($config['files_dir']) && !isset($config['backup_dir']) && $config['file_store_contents'] == 'filesystem') { @@ -470,13 +438,14 @@ function check_dir($dir,&$msg,$check_in_docroot=false) ),__LINE__,__FILE__); } } - if (!check_dir($config['files_dir'],$error_msg,true)) - { - $config_msg .= ($config_msg?"
\n":'').lang("Your files directory '%1' %2",$config['files_dir'],$error_msg); - } if (!check_dir($config['backup_dir'],$error_msg,true)) { - $config_msg .= ($config_msg?"
\n":'').lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg); + $no_backup_dir = lang("Your backup directory '%1' %2",$config['backup_dir'],$error_msg); + $config_msg .= ($config_msg?"
\n":'').$no_backup_dir; + } + if (!$config['mail_server'] || !$config['mail_server_type'] || !$config['smtp_server']) + { + $config_msg .= ($config_msg?"
\n":'').lang('Missing or uncomplete mailserver configuration'); } if (!$config_msg) { @@ -621,22 +590,21 @@ function check_dir($dir,&$msg,$check_in_docroot=false) } // Backup and restore section $setup_tpl->set_var('backup_step_text',lang('Step %1 - DB backup and restore',6)); - switch($GLOBALS['egw_info']['setup']['stage']['db']) + if ($GLOBALS['egw_info']['setup']['stage']['db'] == 10 && !$no_backup_dir) { - case 10: - $setup_tpl->set_var('backup_status_img',$completed); - $setup_tpl->set_var('backup_status_alt',lang('completed')); - $setup_tpl->set_var('backup_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple( - ''/*lang('This stage is completed
')*/, - 'post','db_backup.php', - 'submit',lang('backup and restore'), - '')); - break; - default: - $setup_tpl->set_var('backup_status_img',$incomplete); - $setup_tpl->set_var('backup_status_alt',lang('not completed')); - $setup_tpl->set_var('backup_table_data',lang('Not ready for this stage yet')); - break; + $setup_tpl->set_var('backup_status_img',$completed); + $setup_tpl->set_var('backup_status_alt',lang('completed')); + $setup_tpl->set_var('backup_table_data',$GLOBALS['egw_setup']->html->make_frm_btn_simple( + ''/*lang('This stage is completed
')*/, + 'post','db_backup.php', + 'submit',lang('backup and restore'), + '')); + } + else + { + $setup_tpl->set_var('backup_status_img',$incomplete); + $setup_tpl->set_var('backup_status_alt',lang('not completed')); + $setup_tpl->set_var('backup_table_data',$no_backup_dir ? $no_backup_dir : lang('Not ready for this stage yet')); } $setup_tpl->pparse('out','T_setup_main'); diff --git a/setup/lang/phpgw_de.lang b/setup/lang/phpgw_de.lang index fe5f6c311c..3183fad472 100644 --- a/setup/lang/phpgw_de.lang +++ b/setup/lang/phpgw_de.lang @@ -218,7 +218,6 @@ if the application has no defined tables, selecting upgrade should remedy the pr if using ads (active directory) authentication setup de Wenn Sie ADS (Active Directory) Authentifizierung benutzen if using ldap setup de Wenn Sie LDAP verwenden if using ldap, do you want to manage homedirectory and loginshell attributes? setup de Wenn Sie LDAP verwenden, wollen Sie Benutzerverzeichnisse und Komandointerpreter verwalten ? -if using mail authentication setup de Wenn Sie Mail Authentifizierung verwenden if you did not receive any errors, your applications have been setup de Wenn Sie keine Fehlermeldungen erhalten, wurden Ihre Anwendungen if you did not receive any errors, your tables have been setup de Wenn Sie keine Fehlermeldungen erhalten, wurden Ihre Tabellen if you running this the first time, don't forget to manualy %1 !!! setup de Wenn Sie das zum ersten Mal ausführen, vergessen Sie nicht manuell die %1 !!! @@ -281,6 +280,7 @@ mcrypt version setup de MCrypt-Version memory_limit is set to less than 16m: some applications of egroupware need more than the recommend 8m, expect occasional failures setup de memory_limit (maximale Speicher für ein Skript) ist auf weniger als 16M gesetzt: einige eGroupWare Anwendungen benötigen mehr als die empfohlenen 8M. Sie müssen mit gelegentlichen Fehlern rechnen. minimum account id (e.g. 500 or 100, etc.) setup de Minimum für Benutzer-ID (z.B. 500 oder 100) minute setup de Minute +missing or uncomplete mailserver configuration setup de Fehlende oder nicht komplette Mailserver Konfiguration modifications have been completed! setup de Änderung ist abgeschlossen! modify setup de Ändern modify an existing ldap account store for use with egroupware (for a new install using ldap accounts) setup de Bestehende LDAP-Benutzerkonten für die Benutzung durch eGroupWare anpassen (für eine neue Installation mit LDAP-Konten) @@ -316,6 +316,7 @@ or %1continue to the header admin%2 setup de oder %1mit der Headerverwaltung wei or http://webdav.domain.com (webdav) setup de oder http://webdav.domain.com (für WebDAV) or we can attempt to create the database for you: setup de Oder wir können versuchen die Datenbank für Sie anzulegen: or you can install a previous backup. setup de Oder Sie können eine vorherige Datensicherung installieren. +password for smtp-authentication setup de Passwort für SMTP Authentifizierung password needed for configuration setup de Passwort wird für die Konfiguration benötgt password of db user setup de Passwort des Datenbank Benutzers passwords did not match, please re-enter setup de Passworte stimmten nicht überein, bitte nocheinmal eingeben @@ -407,9 +408,12 @@ setup the database setup de Datenbank einzurichten setup/config admin login setup de Setup-/Konfigurationsadmin-Login show 'powered by' logo on setup de Zeige "powered by" Logo size setup de Größe +smtp server hostname or ip address setup de SMTP Server Hostname oder IP Adresse +smtp server port setup de SMTP Server Port some or all of its tables are missing setup de Einige oder alle Tabellen fehlen sql encryption type setup de SQL-Verschlüsselungstyp für das Passwort (Vorgabe MD5) standard (login-name identical to egroupware user-name) setup de Standard (Loginname identisch zu eGroupWare Benutzername) +standard mailserver settings (used for mail authentication too) setup de Standard Mailserver Einstellungen (werden auch für die Mail Authentifizierung benutzt) start the postmaster setup de Starten Sie den postmaster status setup de Status step %1 - admin account setup de Schrit %1 - Administrator-Konto @@ -472,6 +476,7 @@ uploads a backup to the backup-dir, from where you can restore it setup de L use cookies to pass sessionid setup de SitzungsId in einem Cookie speichern use pure html compliant code (not fully working yet) setup de Vollständig HTML kompatiblen Code verwenden (nicht vollständig implementiert) user account prefix setup de Präfix für Benutzernamen +user for smtp-authentication (leave it empty if no auth required) setup de Benutzer für SMTP-Authentifizierung (leer lassen wenn keine notwendig ist) usernames are casesensitive setup de Benutzername mit Unterscheidung zwischen Groß- und Kleinschreibung users choice setup de Benutzerauswahl utf-8 (unicode) setup de utf-8 (Unicode) @@ -523,6 +528,7 @@ your backup directory '%1' %2 setup de Ihr Datensicherungsverzeichnis '%1' %2 your database does not exist setup de Ihre Datenbank existiert nicht your database is not working! setup de Ihre Datenbank funktioniert nicht! your database is working, but you dont have any applications installed setup de Ihre Datenbank arbeitet, aber Sie haben keine Anwendungen installiert! +your egroupware api is current setup de Ihre eGroupWare API ist aktuell your files directory '%1' %2 setup de Ihr Dateiverzeichnis '%1' %2 your header admin password is not set. please set it now! setup de Ihr Headerverwaltungspasswort wurde NICHT gesetzt. Bitte setzen Sie es jetzt! your header.inc.php needs upgrading. setup de Ihre header.inc.php muss aktualisiert werden. diff --git a/setup/lang/phpgw_en.lang b/setup/lang/phpgw_en.lang index 0f333d0d93..c5d54058ee 100644 --- a/setup/lang/phpgw_en.lang +++ b/setup/lang/phpgw_en.lang @@ -218,7 +218,6 @@ if the application has no defined tables, selecting upgrade should remedy the pr if using ads (active directory) authentication setup en If using ADS (Active Directory) authentication if using ldap setup en If using LDAP if using ldap, do you want to manage homedirectory and loginshell attributes? setup en If using LDAP, do you want to manage homedirectory and loginshell attributes? -if using mail authentication setup en If using Mail authentication if you did not receive any errors, your applications have been setup en If you did not receive any errors, your applications have been if you did not receive any errors, your tables have been setup en If you did not receive any errors, your tables have been if you running this the first time, don't forget to manualy %1 !!! setup en If you running this the first time, don't forget to manualy %1 !!! @@ -281,6 +280,7 @@ mcrypt version setup en MCrypt version memory_limit is set to less than 16m: some applications of egroupware need more than the recommend 8m, expect occasional failures setup en memory_limit is set to less than 16M: some applications of eGroupWare need more than the recommend 8M, expect occasional failures minimum account id (e.g. 500 or 100, etc.) setup en Minimum account id (e.g. 500 or 100, etc.) minute setup en minute +missing or uncomplete mailserver configuration setup en Missing or uncomplete mailserver configuration modifications have been completed! setup en Modifications have been completed! modify setup en Modify modify an existing ldap account store for use with egroupware (for a new install using ldap accounts) setup en Modify an existing LDAP account store for use with eGroupWare (for a new install using LDAP accounts) @@ -316,6 +316,7 @@ or %1continue to the header admin%2 setup en or %1Continue to the Header Admin%2 or http://webdav.domain.com (webdav) setup en or http://webdav.domain.com (WebDAV) or we can attempt to create the database for you: setup en Or we can attempt to create the database for you: or you can install a previous backup. setup en Or you can install a previous backup. +password for smtp-authentication setup en Password for SMTP-authentication password needed for configuration setup en Password needed for configuration password of db user setup en Password of db user passwords did not match, please re-enter setup en Passwords did not match, please re-enter @@ -407,9 +408,12 @@ setup the database setup en Setup the database setup/config admin login setup en Setup/Config Admin Login show 'powered by' logo on setup en Show 'powered by' logo on size setup en size +smtp server hostname or ip address setup en SMTP server hostname or IP address +smtp server port setup en SMTP server port some or all of its tables are missing setup en Some or all of its tables are missing sql encryption type setup en SQL encryption type for passwords (default - md5) standard (login-name identical to egroupware user-name) setup en standard (login-name identical to eGroupWare user-name) +standard mailserver settings (used for mail authentication too) setup en Standard mailserver settings (used for Mail authentication too) start the postmaster setup en Start the postmaster status setup en Status step %1 - admin account setup en Step %1 - Admin Account @@ -472,6 +476,7 @@ uploads a backup to the backup-dir, from where you can restore it setup en uploa use cookies to pass sessionid setup en Use cookies to pass sessionid use pure html compliant code (not fully working yet) setup en Use pure HTML compliant code (not fully working yet) user account prefix setup en User account prefix +user for smtp-authentication (leave it empty if no auth required) setup en User for SMTP-authentication (leave it empty if no auth required) usernames are casesensitive setup en Usernames are casesensitive users choice setup en Users Choice utf-8 (unicode) setup en utf-8 (Unicode) @@ -523,6 +528,7 @@ your backup directory '%1' %2 setup en Your backup directory '%1' %2 your database does not exist setup en Your database does not exist your database is not working! setup en Your Database is not working! your database is working, but you dont have any applications installed setup en Your database is working, but you dont have any applications installed +your egroupware api is current setup en Your eGroupWare API is current your files directory '%1' %2 setup en Your files directory '%1' %2 your header admin password is not set. please set it now! setup en Your header admin password is NOT set. Please set it now! your header.inc.php needs upgrading. setup en Your header.inc.php needs upgrading. diff --git a/setup/templates/default/config.tpl b/setup/templates/default/config.tpl index 387b1ba588..8d121b337f 100644 --- a/setup/templates/default/config.tpl +++ b/setup/templates/default/config.tpl @@ -45,18 +45,7 @@ - - +   @@ -131,6 +120,57 @@   + + {lang_Standard_mailserver_settings_(used_for_Mail_authentication_too)}: + + + {lang_POP/IMAP_mail_server_hostname_or_IP_address}: + + + + {lang_Mail_server_protocol}: + + + + + + {lang_Mail_server_login_type}: + + + + + + {lang_Mail_domain_(for_Virtual_mail_manager)}: + + + + {lang_SMTP_server_hostname_or_IP_address}: + + + + {lang_SMTP_server_port}: + + + + {lang_User_for_SMTP-authentication_(leave_it_empty_if_no_auth_required)}: + + + + {lang_Password_for_SMTP-authentication}: + + + +   + + @@ -342,7 +382,7 @@ - +   @@ -362,42 +402,6 @@   - - {lang_If_using_Mail_authentication}: - - - {lang_POP/IMAP_mail_server_hostname_or_IP_address}: - - - - {lang_Mail_server_protocol}: - - - - - - {lang_Mail_server_login_type}: - - - - - - {lang_Mail_domain_(for_Virtual_mail_manager)}: - - - - -   - - {lang_Mcrypt_settings_(requires_mcrypt_PHP_extension)}