Skip to content

Commit

Permalink
3.0.1
Browse files Browse the repository at this point in the history
Fix several inconsistencies in install/upgrade processes
  • Loading branch information
nilsteampassnet committed Mar 25, 2023
1 parent 27f0701 commit 1983379
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 43 deletions.
2 changes: 1 addition & 1 deletion install/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function checkPage()
} else {
jsonValues = {"absolute_path":$("#absolute_path").val(), "url_path":$("#url_path").val()};
dataToUse = JSON.stringify(jsonValues);
tasks = ["folder*install", "folder*includes", "folder*includes/config", "folder*includes/avatars", "folder*includes/libraries/csrfp/libs", "folder*includes/libraries/csrfp/js", "folder*includes/libraries/csrfp/log", "extension*mbstring", "extension*openssl", "extension*bcmath", "extension*iconv", "extension*gd", "extension*xml", "extension*curl", "version*php", "ini*max_execution_time", "extension*gmp"];
tasks = ["folder*install", "folder*includes", "folder*includes/config", "folder*includes/avatars", "folder*includes/libraries/csrfp/libs", "folder*includes/libraries/csrfp/js", "folder*includes/libraries/csrfp/log", "extension*mbstring", "extension*openssl", "extension*bcmath", "extension*iconv", "extension*gd", "extension*xml", "extension*curl", "version*php", "ini*max_execution_time", "extension*gmp", "folder*files", "folder*upload"];
multiple = true;
$("#hid_absolute_path").val($("#absolute_path").val());
$("#hid_url_path").val($("#url_path").val());
Expand Down
8 changes: 3 additions & 5 deletions install/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@
<li>Directory "/includes/libraries/csrfp/libs/" is writable&nbsp;<span id="res2_check4"></span></li>
<li>Directory "/includes/libraries/csrfp/js/" is writable&nbsp;<span id="res2_check5"></span></li>
<li>Directory "/includes/libraries/csrfp/log/" is writable&nbsp;<span id="res2_check6"></span></li>
<li>Directory "/files/" is writable&nbsp;<span id="res2_check17"></span></li>
<li>Directory "/upload/" is writable&nbsp;<span id="res2_check18"></span></li>
<li>PHP extension "mbstring" is loaded&nbsp;<span id="res2_check7"></span></li>
<li>PHP extension "openssl" is loaded&nbsp;<span id="res2_check8"></span></li>
<li>PHP extension "bcmath" is loaded&nbsp;<span id="res2_check9"></span></li>
Expand Down Expand Up @@ -345,11 +347,7 @@
<li>Chmod some folders and files <span id="res6_check1"></span></li>
<li>Create settings files <span id="res6_check2"></span></li>
<li>Initiate CSRF protection <span id="res6_check3"></span></li>
<li>Add new cron job <span id="res6_check5"></span></li>
<div class="form-group">
<label>Teampass Administrator password</label>
<input type="password" class="form-control" id="admin_pwd" class="ui-widget" value=""><span id="res4_check10"></span>
</div
<li>Add new cron job <span id="res6_check5"></span></li>
<li>Clean temporary installation data <span id="res6_check4"></span></li>
</ul>
</div>
Expand Down
5 changes: 2 additions & 3 deletions install/install.queries.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ function encryptFollowingDefuse($message, $ascii_key)
array('admin', 'duo_skey', ''),
array('admin', 'duo_host', ''),
array('admin', 'duo_failmode', 'secure'),
array('admin', 'teampass_version', ''),
array('admin', 'roles_allowed_to_print_select', ''),
array('admin', 'clipboard_life_duration', '30'),
array('admin', 'mfa_for_roles', ''),
Expand All @@ -639,7 +638,7 @@ function encryptFollowingDefuse($message, $ascii_key)
array('admin', 'ldap_username', ''),
array('admin', 'api_token_duration', '60'),
array('timestamp', 'last_folder_change', ''),
array('admin', 'enable_tasks_manager', '0'),
array('admin', 'enable_tasks_manager', '1'),
array('admin', 'task_maximum_run_time', '300'),
array('admin', 'tasks_manager_refreshing_period', '20'),
array('admin', 'maximum_number_of_items_to_treat', '100'),
Expand Down Expand Up @@ -789,7 +788,7 @@ function encryptFollowingDefuse($message, $ascii_key)
if ($tmp === 0) {
$mysqli_result = mysqli_query(
$dbTmp,
"INSERT INTO `" . $var['tbl_prefix'] . "users` (`id`, `login`, `pw`, `admin`, `gestionnaire`, `personal_folder`, `groupes_visibles`, `email`, `encrypted_psk`, `last_pw_change`, `name`, `lastname`, `can_create_root_folder`, `public_key`, `private_key`) VALUES ('1', 'admin', '" . bCrypt($var['admin_pwd'], '13') . "', '1', '0', '0', '0', '" . $var['admin_email'] . "', '', '" . time() . "', '" . $var['admin_name'] . "', '" . $var['admin_lastname'] . "', '1', 'none', 'none')"
"INSERT INTO `" . $var['tbl_prefix'] . "users` (`id`, `login`, `pw`, `admin`, `gestionnaire`, `personal_folder`, `groupes_visibles`, `email`, `encrypted_psk`, `last_pw_change`, `name`, `lastname`, `can_create_root_folder`, `public_key`, `private_key`, `is_ready_for_usage`, `otp_provided`) VALUES ('1', 'admin', '" . bCrypt($var['admin_pwd'], '13') . "', '1', '0', '0', '0', '" . $var['admin_email'] . "', '', '" . time() . "', '" . $var['admin_name'] . "', '" . $var['admin_lastname'] . "', '1', 'none', 'none', '1', '1')"
);
} else {
$mysqli_result = mysqli_query($dbTmp, 'UPDATE `' . $var['tbl_prefix'] . "users` SET `pw` = '" . bCrypt($var['admin_pwd'], '13') . "' WHERE login = 'admin' AND id = '1'");
Expand Down
18 changes: 2 additions & 16 deletions install/upgrade_run_3.0.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
exit();
}




// Load libraries
require_once '../includes/libraries/protect/SuperGlobal/SuperGlobal.php';
$superGlobal = new protect\SuperGlobal\SuperGlobal();
Expand Down Expand Up @@ -1945,19 +1942,8 @@

//---<END 3.0.0.23

// Save timestamp
$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `" . $pre . "misc` WHERE type = 'admin' AND intitule = 'upgrade_timestamp'"));
if (intval($tmp) === 0) {
mysqli_query(
$db_link,
"INSERT INTO `" . $pre . "misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'upgrade_timestamp', ".time().")"
);
} else {
mysqli_query(
$db_link,
"UPDATE `" . $pre . "misc` SET valeur = ".time()." WHERE type = 'admin' AND intitule = 'upgrade_timestamp'"
);
}
// Close connection
mysqli_close($db_link);

// Finished
echo '[{"finish":"1" , "next":"", "error":""}]';
120 changes: 120 additions & 0 deletions install/upgrade_run_3.0.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php
/**
* Teampass - a collaborative passwords manager.
* ---
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* ---
* @project Teampass
* @version 3.0.1
* @file upgrade_run_3.0.php
* ---
* @author Nils Laumaillé ([email protected])
* @copyright 2009-2023 Teampass.net
* @license https://spdx.org/licenses/GPL-3.0-only.html#licenseText GPL-3.0
* ---
* @see https://www.teampass.net
*/

set_time_limit(600);


require_once '../sources/SecureHandler.php';
session_name('teampass_session');
session_start();
error_reporting(E_ERROR | E_PARSE);
$_SESSION['CPM'] = 1;

//include librairies
require_once '../includes/language/english.php';
require_once '../includes/config/include.php';
require_once '../includes/config/settings.php';
require_once '../sources/main.functions.php';
require_once '../includes/libraries/Tree/NestedTree/NestedTree.php';
require_once 'tp.functions.php';
require_once 'libs/aesctr.php';
require_once '../includes/config/tp.config.php';

// Get the encrypted password
define('DB_PASSWD_CLEAR', defuse_return_decrypted(DB_PASSWD));

/*
//Build tree
$tree = new Tree\NestedTree\NestedTree(
$pre . 'nested_tree',
'id',
'parent_id',
'title'
);
*/

// DataBase
// Test DB connexion
$pass = DB_PASSWD_CLEAR;
$server = DB_HOST;
$pre = DB_PREFIX;
$database = DB_NAME;
$port = DB_PORT;
$user = DB_USER;

if (mysqli_connect(
$server,
$user,
$pass,
$database,
$port
)) {
$db_link = mysqli_connect(
$server,
$user,
$pass,
$database,
$port
);
} else {
$res = 'Impossible to get connected to server. Error is: ' . addslashes(mysqli_connect_error());
echo '[{"finish":"1", "msg":"", "error":"Impossible to get connected to server. Error is: ' . addslashes(mysqli_connect_error()) . '!"}]';
mysqli_close($db_link);
exit();
}

// Load libraries
require_once '../includes/libraries/protect/SuperGlobal/SuperGlobal.php';
$superGlobal = new protect\SuperGlobal\SuperGlobal();


//--->BEGIN 3.0.1

// Ensure admin user is ready
mysqli_query(
$db_link,
"UPDATE ".$pre."users
SET is_ready_for_usage = 1, otp_provided = 1
WHERE id = 1"
);

//---<END 3.0.1


// Save timestamp
$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `" . $pre . "misc` WHERE type = 'admin' AND intitule = 'upgrade_timestamp'"));
if (intval($tmp) === 0) {
mysqli_query(
$db_link,
"INSERT INTO `" . $pre . "misc` (`type`, `intitule`, `valeur`) VALUES ('admin', 'upgrade_timestamp', ".time().")"
);
} else {
mysqli_query(
$db_link,
"UPDATE `" . $pre . "misc` SET valeur = ".time()." WHERE type = 'admin' AND intitule = 'upgrade_timestamp'"
);
}

//---< END 3.0.X upgrade steps

// Close connection
mysqli_close($db_link);

// Finished
echo '[{"finish":"1" , "next":"", "error":""}]';
1 change: 1 addition & 0 deletions install/upgrade_scripts_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
array('upgrade_run_3.0.0_fields.php', 'user_id'),
array('upgrade_run_3.0.0_suggestions.php', 'user_id'),
array('upgrade_run_3.0.0_files.php', 'user_id'),
array('upgrade_run_3.0.php', 'user_id'),
);
$param = '';

Expand Down
99 changes: 83 additions & 16 deletions pages/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@
<div class="card">
<div class="card-body">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#settings" aria-controls="settings" aria-selected="false"><?php echo langHdl('settings'); ?></a>
</li>
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#jobs" aria-controls="jobs" aria-selected="true"><?php echo langHdl('tasks'); ?></a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#in_progress" aria-controls="in_progress" aria-selected="true"><?php echo langHdl('in_progress'); ?></a>
<a class="nav-link" data-toggle="tab" href="#in_progress" aria-controls="in_progress" aria-selected="false"><?php echo langHdl('in_progress'); ?></a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#finished" role="tab" aria-controls="done" aria-selected="false"><?php echo langHdl('done'); ?></a>
Expand All @@ -93,6 +96,83 @@


<div class="tab-content mt-1" id="myTabContent">
<!-- TAB SETTINGS -->
<div class="tab-pane fade show" id="settings" role="tabpanel" aria-labelledby="settings-tab">
<div class="card-body">
<!--
<div class='row mb-2 option' data-keywords="server setting cron job task"></h5>
<div class='col-10'>
<?php echo langHdl('enable_tasks_manager'); ?>
<small id='passwordHelpBlock' class='form-text text-muted'>
<?php echo langHdl('enable_tasks_manager_tip'); ?>
</small>
</div>
<div class='col-2'>
<div class='toggle toggle-modern disabled' id='enable_tasks_manager' data-toggle-on='<?php echo isset($SETTINGS['enable_tasks_manager']) && (int) $SETTINGS['enable_tasks_manager'] === 1 ? 'true' : 'false'; ?>'></div><input type='hidden' id='enable_tasks_manager_input' value='<?php echo isset($SETTINGS['enable_tasks_manager']) && (int) $SETTINGS['enable_tasks_manager'] === 1 ? '1' : '0'; ?>' />
</div>
</div>

<div class='row mb-3 option'>
<div class='col-10'>
<h5><i class="fa-solid fa-envelopes-bulk mr-2"></i><?php echo langHdl('enable_backlog_mail'); ?></h5>
</div>
<div class='col-2'>
<div class='toggle toggle-modern' id='enable_backlog_mail' data-toggle-on='<?php echo isset($SETTINGS['enable_backlog_mail']) && (int) $SETTINGS['enable_backlog_mail'] === 1 ? 'true' : 'false'; ?>'></div><input type='hidden' id='enable_backlog_mail_input' value='<?php echo isset($SETTINGS['enable_backlog_mail']) && (int) $SETTINGS['enable_backlog_mail'] === 1 ? '1' : '0'; ?>' />
</div>
</div>
-->

<div class='row mb-3 option'>
<div class='col-10'>
<h5><i class="fa-solid fa-rss mr-2"></i><?php echo langHdl('enable_tasks_log'); ?></h5>
<small class='form-text text-muted'>
<?php echo langHdl('enable_tasks_log_tip'); ?>
</small>
</div>
<div class='col-2'>
<div class='toggle toggle-modern' id='enable_tasks_log' data-toggle-on='<?php echo isset($SETTINGS['enable_tasks_log']) === true && (int) $SETTINGS['enable_tasks_log'] === 1 ? 'true' : 'false'; ?>'></div><input type='hidden' id='enable_tasks_log_input' value='<?php echo isset($SETTINGS['enable_tasks_log']) && (int) $SETTINGS['enable_tasks_log'] === 1 ? 1 : 0; ?>' />
</div>
</div>

<div class='row mb-3 option'>
<div class='col-10'>
<h5><i class="fa-solid fa-hourglass-start mr-2"></i><?php echo langHdl('maximum_time_script_allowed_to_run'); ?></h5>
<small id='passwordHelpBlock' class='form-text text-muted'>
<?php echo langHdl('maximum_time_script_allowed_to_run_tip'); ?>
</small>
</div>
<div class='col-2'>
<input type='text' class='form-control form-control-sm' id='task_maximum_run_time' value='<?php echo isset($SETTINGS['task_maximum_run_time']) === true ? $SETTINGS['task_maximum_run_time'] : 600; ?>'>
</div>
</div>

<div class='row mb-3 option'>
<div class='col-10'>
<h5><i class="fa-solid fa-object-group mr-2"></i><?php echo langHdl('maximum_number_of_items_to_treat'); ?></h5>
<small id='passwordHelpBlock' class='form-text text-muted'>
<?php echo langHdl('maximum_number_of_items_to_treat_tip'); ?>
</small>
</div>
<div class='col-2'>
<input type='text' class='form-control form-control-sm' id='maximum_number_of_items_to_treat' value='<?php echo isset($SETTINGS['maximum_number_of_items_to_treat']) === true ? $SETTINGS['maximum_number_of_items_to_treat'] : NUMBER_ITEMS_IN_BATCH; ?>'>
</div>
</div>

<div class='row mb-3 option'>
<div class='col-10'>
<h5><i class="fa-solid fa-stopwatch-20 mr-2"></i><?php echo langHdl('refresh_data_every_on_screen'); ?></h5>
<small id='passwordHelpBlock' class='form-text text-muted'>
<?php echo langHdl('refresh_data_every_on_screen_tip'); ?>
</small>
</div>
<div class='col-2'>
<input type='text' class='form-control form-control-sm' id='tasks_manager_refreshing_period' value='<?php echo isset($SETTINGS['tasks_manager_refreshing_period']) === true ? $SETTINGS['tasks_manager_refreshing_period'] : 20; ?>'>
</div>
</div>
</div>
</div>

<!-- TAB JOBS -->
<div class="tab-pane fade show active" id="jobs" role="tabpanel" aria-labelledby="jobs-tab">
<div class="card-body p-0">

Expand All @@ -101,7 +181,7 @@
<?php echo str_replace("#teampass_path#", $SETTINGS['cpassman_dir'], langHdl('tasks_information')); ?>

<div class="">
<?php if (defined('WIP') === true && WIP === true) {
<?php
require_once __DIR__.'/../includes/libraries/TiBeN/CrontabManager/CrontabAdapter.php';
require_once __DIR__.'/../includes/libraries/TiBeN/CrontabManager/CrontabJob.php';
require_once __DIR__.'/../includes/libraries/TiBeN/CrontabManager/CrontabRepository.php';
Expand Down Expand Up @@ -130,20 +210,7 @@
}
catch (Exception $e) {
echo $e->getMessage();
}
} ?>
</div>

<div class='row mt-4 option'>
<div class='col-10'>
<h5><i class="fa-solid fa-rss mr-2"></i><?php echo langHdl('enable_tasks_log'); ?></h5>
<small class='form-text text-muted'>
<?php echo langHdl('enable_tasks_log_tip'); ?>
</small>
</div>
<div class='col-2'>
<div class='toggle toggle-modern' id='enable_tasks_log' data-toggle-on='<?php echo isset($SETTINGS['enable_tasks_log']) === true && (int) $SETTINGS['enable_tasks_log'] === 1 ? 'true' : 'false'; ?>'></div><input type='hidden' id='enable_tasks_log_input' value='<?php echo isset($SETTINGS['enable_tasks_log']) && (int) $SETTINGS['enable_tasks_log'] === 1 ? 1 : 0; ?>' />
</div>
}?>
</div>
</div>

Expand Down
Loading

0 comments on commit 1983379

Please sign in to comment.