Commit 159eb3fd authored by Côme Bernigaud's avatar Côme Bernigaud Committed by Benoit Mortier
Browse files

Fixes: #2753 Inserting complete config into LDAP at the end of the setup

parent f4efd1c2
......@@ -133,19 +133,7 @@ textdomain($domain);
/* Prepare plugin list */
if (!session::global_is_set('plist')) {
/* Initially load all classes */
$class_list = get_declared_classes();
foreach ($class_mapping as $class => $path) {
if (!in_array($class, $class_list)) {
if (is_readable("$BASE_DIR/$path")) {
require_once("$BASE_DIR/$path");
} else {
msg_dialog::display(_("Fatal error"),
sprintf(_("Cannot locate file '%s' - please run '%s' to fix this"),
"$BASE_DIR/$path", "<b>fusiondirectory-setup</b>"), FATAL_ERROR_DIALOG);
exit;
}
}
}
load_all_classes();
$plist = new pluglist($config, $ui);
session::global_set('plist', $plist);
......
......@@ -3660,4 +3660,22 @@ function fix_dos_linebreaks($str)
{
return preg_replace('/\\r\\n/', "\n", $str);
}
function load_all_classes() {
global $BASE_DIR, $class_list, $class_mapping;
/* Initially load all classes */
$class_list = get_declared_classes();
foreach ($class_mapping as $class => $path) {
if (!in_array($class, $class_list)) {
if (is_readable("$BASE_DIR/$path")) {
require_once("$BASE_DIR/$path");
} else {
msg_dialog::display(_("Fatal error"),
sprintf(_("Cannot locate file '%s' - please run '%s' to fix this"),
"$BASE_DIR/$path", "<b>fusiondirectory-setup</b>"), FATAL_ERROR_DIALOG);
exit;
}
}
}
}
?>
......@@ -47,6 +47,33 @@ class Step_Finish extends setup_step
return $smarty->fetch(CONFIG_TEMPLATE_DIR.CONFIG_FILE);
}
function insertConfigDefaults()
{
/* Insert default config values, even for installed plugin */
global $config, $ui, $plist, $BASE_DIR;
$cv = $this->parent->captured_values;
/* Create config object */
$config = new config(CONFIG_DIR."/".CONFIG_FILE, $BASE_DIR);
$config->set_current($config->data['MAIN']['DEFAULT']);
/* Create ui object */
/* got user dn, fill acl's */
$ui = new userinfo($config, $cv['valid_admin']);
$ui->username = 'fd-admin';
/* Username is set, load subtreeACL's now */
$ui->loadACL();
/* We need the pluglist object */
load_all_classes();
$plist = new pluglist($config, $ui);
/* Now we can save LDAP config */
$config->loadPlist($plist);
$config->checkLdapConfig();
}
function execute()
{
......@@ -67,10 +94,8 @@ class Step_Finish extends setup_step
* - Permisssion are set correctly
*/
if (isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)) {
$config = new config(CONFIG_DIR."/".CONFIG_FILE, $BASE_DIR);
$config->set_current($config->data['MAIN']['DEFAULT']);
$config->checkLdapConfig();
if(isset($_POST['next']) && $exists && !$this->is_world_readable(CONFIG_DIR."/".CONFIG_FILE)){
$this->insertConfigDefaults();
session::destroy();
header("Location: index.php");
exit();
......
......@@ -48,7 +48,7 @@ array_to_ldif - Create ldif output of an ldap result array
class Step_Migrate extends setup_step
{
var $languages = array();
var $attributes = array();
var $attributes = array('valid_admin');
var $header_image = "images/setup/migrate.png";
var $checks = array();
......@@ -109,7 +109,10 @@ class Step_Migrate extends setup_step
var $rootOC_migrate_dialog = FALSE;
var $rootOC_details = array();
function __construct()
/* One valid admin dn */
var $valid_admin = FALSE;
function Step_Migrate()
{
$this->update_strings();
}
......@@ -780,6 +783,7 @@ class Step_Migrate extends setup_step
$this->migrate_users = array();
$this->acl_migrate_dialog = FALSE;
$this->migrate_acl_base_entry = "";
$valid_admin = FALSE;
/* Establish ldap connection */
$cv = $this->parent->captured_values;
......@@ -834,6 +838,9 @@ class Step_Migrate extends setup_step
$member = base64_decode($member);
if (isset($users[$member])) {
if (preg_match("/all;cmdrw/i", $tmp[3])) {
if (!$valid_admin) {
$valid_admin = $member;
}
$valid_users .= $users[$member].", ";
$GOsa_26_found = TRUE;
}
......@@ -846,6 +853,9 @@ class Step_Migrate extends setup_step
if (isset($group_attrs['memberUid'])) {
for ($e = 0; $e < $group_attrs['memberUid']['count']; $e++) {
if (isset($rusers[$group_attrs['memberUid'][$e]])) {
if (!$valid_admin) {
$valid_admin = $rusers[$group_attrs['memberUid'][$e]];
}
$val_users .= $group_attrs['memberUid'][$e].", ";
}
}
......@@ -875,6 +885,9 @@ class Step_Migrate extends setup_step
$member = base64_decode($member);
if (isset($users[$member])) {
if (!$valid_admin) {
$valid_admin = $member;
}
$valid_users .= $users[$member].", ";
$GOsa_26_found = TRUE;
}
......@@ -885,6 +898,9 @@ class Step_Migrate extends setup_step
if (isset($group_attrs['memberUid'])) {
for ($e = 0; $e < $group_attrs['memberUid']['count']; $e ++) {
if (isset($rusers[$group_attrs['memberUid'][$e]])) {
if (!$valid_admin) {
$valid_admin = $rusers[$group_attrs['memberUid'][$e]];
}
$val_users .= $group_attrs['memberUid'][$e].", ";
}
}
......@@ -913,6 +929,9 @@ class Step_Migrate extends setup_step
for ($e = 0; $e < $p_group['memberUid']['count']; $e ++ ) {
$user = $p_group['memberUid'][$e];
if (isset($rusers[$user])) {
if (!$valid_admin) {
$valid_admin = $rusers[$user];
}
$val_users .= $user.", ";
}
}
......@@ -946,6 +965,7 @@ class Step_Migrate extends setup_step
$this->checks['acls']['STATUS'] = TRUE;
$this->checks['acls']['STATUS_MSG'] = _("Ok");
$this->checks['acls']['ERROR_MSG'] = $str;
$this->valid_admin = $valid_admin;
} else {
$this->checks['acls']['STATUS'] = FALSE;
$this->checks['acls']['STATUS_MSG'] = _("Failed");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment