<?php
-/**
- * Bacula® - The Network Backup Solution
- * Baculum - Bacula web interface
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
*
- * Copyright (C) 2013-2014 Marcin Haba
+ * Copyright (C) 2013-2016 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
- * The main author of Bacula is Kern Sibbald, with contributions from many
- * others, a complete list can be found in the file AUTHORS.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
*
* You may use this file and others of this release according to the
* license defined in the LICENSE file, which includes the Affero General
* Public License, v3.0 ("AGPLv3") and some additional permissions and
* terms pursuant to its AGPLv3 Section 7.
*
- * Bacula® is a registered trademark of Kern Sibbald.
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
*/
Prado::using('System.Web.UI.ActiveControls.TActiveDropDownList');
{
public $firstRun;
public $applicationConfig;
+ public $userPattern;
const DEFAULT_DB_NAME = 'bacula';
const DEFAULT_DB_LOGIN = 'bacula';
const DEFAULT_BCONSOLE_BIN = '/usr/sbin/bconsole';
const DEFAULT_BCONSOLE_CONF = '/etc/bacula/bconsole.conf';
+ const DEFAULT_BCONSOLE_CONF_CUSTOM = '/etc/bacula/bconsole-{user}.conf';
public function onInit($param) {
parent::onInit($param);
- $this->Lang->SelectedValue = $this->Session['language'];
- $this->firstRun = !$this->getModule('configuration')->isApplicationConfig();
- $this->applicationConfig = $this->getModule('configuration')->getApplicationConfig();
+ $this->Lang->SelectedValue = $_SESSION['language'];
+ $config = $this->getModule('configuration');
+ $this->firstRun = !$config->isApplicationConfig();
+ $this->applicationConfig = $config->getApplicationConfig();
+ $this->userPattern = $config->getUserPattern();
+ if($this->firstRun === false && $this->User->getIsAdmin() === false) {
+ die('Access denied.');
+ }
}
public function onLoad($param) {
$this->Login->Text = self::DEFAULT_DB_LOGIN;
$this->BconsolePath->Text = self::DEFAULT_BCONSOLE_BIN;
$this->BconsoleConfigPath->Text = self::DEFAULT_BCONSOLE_CONF;
+ $this->BconsoleConfigCustomPath->Text = self::DEFAULT_BCONSOLE_CONF_CUSTOM;
} else {
$this->DBType->SelectedValue = $this->getPage()->applicationConfig['db']['type'];
$this->DBName->Text = $this->applicationConfig['db']['name'];
$this->DBPath->Text = $this->applicationConfig['db']['path'];
$this->BconsolePath->Text = $this->applicationConfig['bconsole']['bin_path'];
$this->BconsoleConfigPath->Text = $this->applicationConfig['bconsole']['cfg_path'];
+ $this->BconsoleConfigCustomPath->Text = array_key_exists('cfg_custom_path', $this->applicationConfig['bconsole']) ? $this->applicationConfig['bconsole']['cfg_custom_path'] : self::DEFAULT_BCONSOLE_CONF_CUSTOM;
$this->UseSudo->Checked = $this->getPage()->applicationConfig['bconsole']['use_sudo'] == 1;
$this->PanelLogin->Text = $this->applicationConfig['baculum']['login'];
$this->PanelPassword->Text = $this->applicationConfig['baculum']['password'];
$cfgData['db']['path'] = $this->Application->getModule('configuration')->isSQLiteType($cfgData['db']['type']) ? $this->DBPath->Text : '';
$cfgData['bconsole']['bin_path'] = $this->BconsolePath->Text;
$cfgData['bconsole']['cfg_path'] = $this->BconsoleConfigPath->Text;
+ $cfgData['bconsole']['cfg_custom_path'] = $this->BconsoleConfigCustomPath->Text;
$cfgData['bconsole']['use_sudo'] = (integer)($this->UseSudo->Checked === true);
$cfgData['baculum']['login'] = $this->PanelLogin->Text;
$cfgData['baculum']['password'] = $this->PanelPassword->Text;
$cfgData['baculum']['debug'] = isset($this->applicationConfig['baculum']['debug']) ? $this->applicationConfig['baculum']['debug'] : "0";
+ $cfgData['baculum']['lang'] = $_SESSION['language'];
$ret = $this->getModule('configuration')->setApplicationConfig($cfgData);
if($ret === true) {
- $this->goToDefaultPage();
+ if($this->getModule('configuration')->isUsersConfig() === true) { // version with users config file, so next is try to auto-login
+ $previousUser = ($this->firstRun === false) ? $this->applicationConfig['baculum']['login'] : null;
+ $this->getModule('configuration')->setUsersConfig($cfgData['baculum']['login'], $cfgData['baculum']['password'], $this->firstRun, $previousUser);
+
+ // Automatic login after finish wizard.
+ $http_protocol = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https' : 'http';
+ $this->getModule('configuration')->switchToUser($http_protocol, $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $cfgData['baculum']['login'], $cfgData['baculum']['password']);
+ exit();
+ } else { // standard version (user defined auth method)
+ $this->goToDefaultPage();
+ }
}
}
}
public function setLang($sender, $param) {
- $this->Session['language'] = $sender->SelectedValue;
+ $_SESSION['language'] = $sender->SelectedValue;
$this->goToPage('ConfigurationWizard');
}
$isValidate = ($result === 0);
$this->BconsoleTestResultOk->Display = ($isValidate === true) ? 'Dynamic' : 'None';
$this->BconsoleTestResultErr->Display = ($isValidate === false) ? 'Dynamic' : 'None';
- $this->Step4Content->render($param->NewWriter);
}
}
-?>
\ No newline at end of file
+?>