Skip to content

Commit

Permalink
Merge pull request #965
Browse files Browse the repository at this point in the history
director: fix crash in status scheduler when client is not set
  • Loading branch information
arogge committed Nov 26, 2021
2 parents a099212 + 0aaea07 commit 895ac87
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- Fixed libdroplet xattr.h include issue by using sys/xattr.h [PR #985]
- Fixed crash on bconsole when using autcomplete with tab [PR #969]
- [Issue #1374] Include zero-file incremental backups in always-incremental consolidation [PR #995]
- fix crash in "status scheduler" command when job->client is unset [PR #965]

### Added
- systemtests: make database credentials configurable [PR #950]
Expand Down
13 changes: 9 additions & 4 deletions core/src/dird/ua_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,10 @@ static void DoSchedulerStatus(UaContext* ua)
if (client || job) {
// List specific schedule.
if (job) {
if (job->schedule && job->schedule->enabled && job->enabled
&& job->client->enabled) {
if (job->schedule && job->schedule->enabled && job->enabled) {
// skip if client is set but not enabled
if (job->client && !job->client->enabled) { break; }

if (!show_scheduled_preview(ua, job->schedule, overview,
&max_date_len, time_to_check)) {
goto start_again;
Expand All @@ -673,8 +675,11 @@ static void DoSchedulerStatus(UaContext* ua)
foreach_res (job, R_JOB) {
if (!ua->AclAccessOk(Job_ACL, job->resource_name_)) { continue; }

if (job->schedule && job->schedule->enabled && job->enabled
&& job->client == client && job->client->enabled) {
if (job->schedule && job->schedule->enabled && job->enabled) {
// skip if client is set but not enabled
if (job->client && job->client == client && !job->client->enabled) {
continue;
}
if (!show_scheduled_preview(ua, job->schedule, overview,
&max_date_len, time_to_check)) {
job = NULL;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Job {
Name = "copy"
Type = Copy
Pool = Full
Selection Type = Volume
Selection Pattern = "."
Client = "bareos-fd"
Messages = Standard
Schedule = TestCycle
}
40 changes: 40 additions & 0 deletions systemtests/tests/scheduler-backup/test-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2021-2021 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
# License as published by the Free Software Foundation and included
# in the file LICENSE.
#
# This program 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. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

set -e
set -o pipefail
set -u

#shellcheck source=../environment.in
. ./environment

#shellcheck source=../scripts/functions
. "${rscripts}"/functions
"${rscripts}"/cleanup
"${rscripts}"/setup

# Fill ${BackupDirectory} with data.
setup_data

bin/bareos start

# make sure, director is up and running.
print_debug "$(bin/bconsole <<< "status dir")"
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,16 @@ export TestName

#shellcheck source=../scripts/functions
. "${rscripts}"/functions
"${rscripts}"/cleanup
"${rscripts}"/setup


# Fill ${BackupDirectory} with data.
setup_data

start_test

cat <<END_OF_DATA >$tmp/bconcmds
@$out /dev/null
messages
@$out $tmp/log1.out
setdebug level=100 storage=File
label volume=TestVolume001 storage=File pool=Full
setdebug level=100 storage=File trace=1
setdebug level=100 director trace=1
setdebug level=100 client trace=1
status director
status client
status storage=File
Expand All @@ -46,9 +41,8 @@ messages
quit
END_OF_DATA

run_bareos "$@"
run_bconsole
check_for_zombie_jobs storage=File
stop_bareos

check_two_logs
check_restore_diff ${BackupDirectory}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
set -e
set -o pipefail
set -u

TestName="$(basename "$(pwd)")"
export TestName

#shellcheck source=../environment.in
. ./environment

#shellcheck source=../scripts/functions
. "${rscripts}"/functions

#
# Run test to check correct output of #`status scheduler job=...`
# of a copy job whose client is disabled
#

start_test

cat <<END_OF_DATA >$tmp/bconcmds
messages
@$out $tmp/log3.out w
enable client=bareos-fd
status scheduler job=copy
@$out $tmp/log4.out w
disable client=bareos-fd
status scheduler job=copy
wait
messages
quit
END_OF_DATA

run_bconsole

#check that `status scheduler job=...` returns scheduled copy jobs
if ! grep "TestCycle Level=Full" "$tmp"/log3.out; then
echo "No scheduled job was found in $tmp/log3.out, which should contain all scheduled jobs" >&2
estat=1
fi

#check that `status scheduler job=...` returns nothing when we disable the client
if grep "TestCycle Level=Full" "$tmp"/log4.out; then
echo "a scheduled job was listed in $tmp/log4.out, which shouldn't happen" >&2
estat=1
fi

end_test

0 comments on commit 895ac87

Please sign in to comment.