From 96919a5fd47e32c6c51ed1a9004ba24921fd7104 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 12 Apr 2007 05:41:34 +0000 Subject: [PATCH] Added new constant named CONFIG_FILE. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6016 594d385d-05f5-0310-b6e9-bd551577e9d8 --- html/index.php | 10 +++++----- include/functions.inc | 1 + setup/class_setup.inc | 4 ++-- setup/class_setupStep1.inc | 5 +++-- setup/class_setupStep2.inc | 8 ++++---- setup/class_setupStep5.inc | 2 +- setup/class_setupStep8.inc | 39 +++++++++++++++++++++----------------- setup/setup_step8.tpl | 10 +++++----- 8 files changed, 43 insertions(+), 36 deletions(-) diff --git a/html/index.php b/html/index.php index 1fdcf4bb3..2c882c202 100644 --- a/html/index.php +++ b/html/index.php @@ -101,7 +101,7 @@ $_SESSION['errorsAlreadyPosted']= array(); $_SESSION['LastError'] = ""; /* Check if we need to run setup */ -if (!file_exists(CONFIG_DIR."/gosa.conf-trunk")){ +if (!file_exists(CONFIG_DIR."/".CONFIG_FILE)){ header("location:setup.php"); exit(); } @@ -116,14 +116,14 @@ if(isset($_POST['javascript']) && $_POST['javascript'] == "true") { $_SESSION['js']= FALSE; } -/* Check if gosa.conf is accessible */ -if (!is_readable(CONFIG_DIR."/gosa.conf")){ - echo sprintf(_("GOsa configuration %s/gosa.conf is not readable. Aborted."), CONFIG_DIR); +/* Check if gosa.conf (.CONFIG_FILE) is accessible */ +if (!is_readable(CONFIG_DIR."/".CONFIG_FILE)){ + echo sprintf(_("GOsa configuration %s/%s is not readable. Aborted."), CONFIG_DIR,CONFIG_FILE); exit(); } /* Parse configuration file */ -$config= new config(CONFIG_DIR."/gosa.conf-trunk", $BASE_DIR); +$config= new config(CONFIG_DIR."/".CONFIG_FILE, $BASE_DIR); $_SESSION['DEBUGLEVEL']= $config->data['MAIN']['DEBUGLEVEL']; if ($_SERVER["REQUEST_METHOD"] != "POST"){ @DEBUG (DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, "config"); diff --git a/include/functions.inc b/include/functions.inc index 7d9185482..4acc2419e 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -20,6 +20,7 @@ /* Configuration file location */ define ("CONFIG_DIR", "/etc/gosa"); +define ("CONFIG_FILE", "gosa.conf-trunk"); define ("CONFIG_TEMPLATE_DIR", "../contrib/"); define ("HELP_BASEDIR", "/var/www/doc/"); diff --git a/setup/class_setup.inc b/setup/class_setup.inc index d93bc4b67..83311ed2f 100644 --- a/setup/class_setup.inc +++ b/setup/class_setup.inc @@ -41,8 +41,8 @@ class setup $this->o_steps[8] = new setup_step_7(); $this->o_steps[9] = new setup_step_8(); - /* Ensure that setup is not reachable if gosa.conf */ - if(file_exists(CONFIG_DIR."/gosa.conf")){ + /* Ensure that setup is not reachable if gosa.conf (CONFIG_FILE) */ + if(file_exists(CONFIG_DIR."/".CONFIG_FILE)){ session_destroy(); header("Location: index.php") ; exit(); diff --git a/setup/class_setupStep1.inc b/setup/class_setupStep1.inc index 0b0466c74..a940e5efa 100644 --- a/setup/class_setupStep1.inc +++ b/setup/class_setupStep1.inc @@ -22,7 +22,7 @@ class setup_step_1 extends setup_step { - var $lang = "en_EN"; + var $lang = ""; var $languages = array(); var $attributes = array("lang","force_global_lang"); var $force_global_lang = FALSE; @@ -46,7 +46,8 @@ class setup_step_1 extends setup_step function execute() { - $this->languages = array("de_DE" => _("German"), + $this->languages = array("" => _("Automatic detection"), + "de_DE" => _("German"), "fr_FR" => _("French"), "en_EN" => _("English"), "ru_RU" => _("Russian")); diff --git a/setup/class_setupStep2.inc b/setup/class_setupStep2.inc index 9a06f0ef9..c9eba18c4 100644 --- a/setup/class_setupStep2.inc +++ b/setup/class_setupStep2.inc @@ -252,9 +252,9 @@ class setup_step_2 extends setup_step /* Check if we can create a config file.*/ $N = _("Configuration file writeable."); $D = _("The Configuration file can't be written"); - $S = _("The GOsa reads its configuration from a file located in (/etc/gosa/gosa.conf). The setup can write the configuration directly in this file, if it is writeable."); - $R = ( file_exists("/etc/gosa/gosa.conf") && is_writeable("/etc/gosa/gosa.conf")) // is there a config file ? - || (!file_exists("/etc/gosa/gosa.conf") && is_writeable("/etc/gosa")); // There is non, but can we create a file there ? + $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 ); @@ -265,7 +265,7 @@ class setup_step_2 extends setup_step # $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("/etc/gosa/gosa.conf"); +# $R = !file_exists(CONFIG_DIR."/".CONFIG_FILE); # $M = FALSE; # $this->is_writeable[] = array("NAME" => $N , "DESC" => $D , "RESULT" => $R , "SOLUTION" => $S , "MUST" => $M ); # } diff --git a/setup/class_setupStep5.inc b/setup/class_setupStep5.inc index 575c8b0a1..9a7afae5a 100644 --- a/setup/class_setupStep5.inc +++ b/setup/class_setupStep5.inc @@ -41,7 +41,7 @@ class setup_step_5 extends setup_step "pwminlen_active" => FALSE, "pwdiffer" => 5, "pwdiffer_active" => FALSE, - "externalpwdhook" => "/usr/bin/sudo myscript", + "externalpwdhook" => "/path/to/your/script username oldpassword newpassword", "externalpwdhook_active" => FALSE); var $mail_settings = array("vacationdir" => "/etc/gosa/vacation", diff --git a/setup/class_setupStep8.inc b/setup/class_setupStep8.inc index 72b6dffbb..338c72c05 100644 --- a/setup/class_setupStep8.inc +++ b/setup/class_setupStep8.inc @@ -23,7 +23,7 @@ class setup_step_8 extends setup_step { var $create_backup = TRUE; - var $gosa_conf_name = "/gosa.conf"; + var $gosa_conf_contrib = "/gosa.conf"; var $cfg_file_written = FALSE; var $last_backup_name = ""; @@ -45,7 +45,7 @@ class setup_step_8 extends setup_step { $smarty = get_smarty(); $smarty->assign("cv",$this->parent->captured_values); - $str = $smarty->fetch(CONFIG_TEMPLATE_DIR.$this->gosa_conf_name); + $str = $smarty->fetch(CONFIG_TEMPLATE_DIR.$this->gosa_conf_contrib); return($str); } @@ -59,11 +59,11 @@ class setup_step_8 extends setup_step /* Check if there is currently an active gosa.conf */ - $exists = file_exists(CONFIG_DIR.$this->gosa_conf_name); + $exists = file_exists(CONFIG_DIR."/".CONFIG_FILE); /* Check if existing config file is writeable */ if($exists){ - $writeable = is_writeable(CONFIG_DIR.$this->gosa_conf_name); + $writeable = is_writeable(CONFIG_DIR."/".CONFIG_FILE); }else{ $writeable = is_writeable(CONFIG_DIR); } @@ -87,9 +87,9 @@ class setup_step_8 extends setup_step if (preg_match('/MSIE 5.5/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/MSIE 6.0/', $_SERVER['HTTP_USER_AGENT'])){ - header('Content-Disposition: filename="gosa.conf"'); + header('Content-Disposition: filename="'.CONFIG_FILE.'"'); } else { - header('Content-Disposition: attachment; filename="gosa.conf"'); + header('Content-Disposition: attachment; filename="'.CONFIG_FILE.'"'); } $str = $this->get_conf_data(); @@ -114,29 +114,29 @@ class setup_step_8 extends setup_step if(!$abort){ /* Try to create file handle */ - $fp = @fopen(CONFIG_DIR.$this->gosa_conf_name, "w"); + $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.$this->gosa_conf_name); + $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.$this->gosa_conf_name); + $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.$this->gosa_conf_name,$webgroup); - @chown(CONFIG_DIR.$this->gosa_conf_name,"root"); - @chmod(CONFIG_DIR.$this->gosa_conf_name,0640); + @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.$this->gosa_conf_name)){ + 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."); } @@ -145,10 +145,15 @@ class setup_step_8 extends setup_step $smarty->assign("save_requested", isset($_POST['saveconf'])); $smarty->assign("err_msg",$err_msg); $smarty->assign("webgroup", $webgroup); - $smarty->assign("gosa_conf_name" , $this->gosa_conf_name); $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); @@ -174,9 +179,9 @@ class setup_step_8 extends setup_step { $info= posix_getgrgid(posix_getgid()); $webgroup = $info['name']; - if(is_writeable(CONFIG_DIR) && is_writeable(CONFIG_DIR.$this->gosa_conf_name)){ - $src = CONFIG_DIR.$this->gosa_conf_name; - $dst = CONFIG_DIR.$this->gosa_conf_name."_".date("Ymd"); + 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)){ diff --git a/setup/setup_step8.tpl b/setup/setup_step8.tpl index 83636f754..0e82254eb 100644 --- a/setup/setup_step8.tpl +++ b/setup/setup_step8.tpl @@ -5,7 +5,7 @@ {t}GOsa setup has collected all data needed to create an initial configuration file.{/t}

- {t}If you want the setup routine to write the configuration file, use the 'Save configuration' button below. If you prefer to copy the 'gosa.conf' manually to '/etc/gosa/' you can download the configuration file by using the 'Download configuration' button.{/t} + {$msg1}

{t}Automatically write configuration{/t} @@ -50,7 +50,7 @@

 {$msg_permissions}
 	{$CONFIG_DIR} 
-	{$CONFIG_DIR}{$gosa_conf_name}
+	{$CONFIG_DIR}/{$CONFIG_FILE}
 			
{/if}

@@ -63,11 +63,11 @@

- {t}After placing the file under /etc/gosa, place make sure that the webserver user is able to read gosa.conf, while other users shouldn't. You may want to execute these commands to achieve this requirement:{/t} + {$msg2}

-	# chown root.{$webgroup} /etc/gosa/gosa.conf
-	# chmod 640 /etc/gosa/gosa.conf
+	# chown root.{$webgroup} {$CONFIG_DIR}/{$CONFIG_FILE}
+	# chmod 640 {$CONFIG_DIR}/{$CONFIG_FILE}
 	

-- 2.30.2