Skip to content

bscrypto: fix and update code, and move CLI parsing to cli11, add systemtests#1734

Merged
BareosBot merged 22 commits intomasterfrom
dev/alaaeddineelamri/master/bscsicrypto-to-CLI11
Aug 29, 2024
Merged

bscrypto: fix and update code, and move CLI parsing to cli11, add systemtests#1734
BareosBot merged 22 commits intomasterfrom
dev/alaaeddineelamri/master/bscsicrypto-to-CLI11

Conversation

@bruno-at-bareos
Copy link
Contributor

@bruno-at-bareos bruno-at-bareos commented Mar 12, 2024

bscrypto

This PR moves CLI parsing of bscrypto to CLI11, along with some code updates and refactoring.
We also add a specific systemtest
and review the related documentation

It will certainly need a backport to 23.

this is based on the old #1350

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Required backport PRs have been created
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

@bruno-at-bareos bruno-at-bareos self-assigned this Mar 12, 2024
@sebsura sebsura force-pushed the dev/alaaeddineelamri/master/bscsicrypto-to-CLI11 branch from 4fa2675 to d4fed3d Compare March 13, 2024 12:58
@bruno-at-bareos bruno-at-bareos force-pushed the dev/alaaeddineelamri/master/bscsicrypto-to-CLI11 branch 2 times, most recently from 1862889 to 6268389 Compare May 27, 2024 08:45
@arogge arogge added this to the 24.0.0 milestone Jun 25, 2024
@bruno-at-bareos bruno-at-bareos force-pushed the dev/alaaeddineelamri/master/bscsicrypto-to-CLI11 branch from 6268389 to da9dd99 Compare July 8, 2024 13:21
@bruno-at-bareos bruno-at-bareos force-pushed the dev/alaaeddineelamri/master/bscsicrypto-to-CLI11 branch 2 times, most recently from c4c3f7b to 9301b0d Compare July 23, 2024 11:48
@sebsura sebsura removed their request for review August 14, 2024 06:52
Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit disappointed that the -w option didn't work together with -s so I added that feature. I also fixed a memory-leak when the key wasn't unwrappable.

I checked that the key semantics do not change when compared with master and also made sure I can read a tape written by Bareos with dd after utilizing bscrypto or stenc (the latter is a bit weird to setup, as it needs the key as hex-string).

All in all I'm pretty happy with the changes, even though that tool could use a lot of re-factoring.

Comment on lines +343 to 412
option(scsi-crypto "Enable scsi-crypto" ON)
option(ndmp "Enable NDMP support" ON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we want to mark these two (i.e. scsi-crypto and ndmp) as advanced, too?


static void usage()

static void TerminateBscrypto(int exitcode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static void TerminateBscrypto(int exitcode)
[[noreturn]] static void TerminateBscrypto(int exitcode)

Comment on lines +1 to +6
# bareos testing with mhvtl
# bareos env_keep += "MHVTL_HOME_PATH"
build ALL = (root) NOPASSWD:/usr/bin/systemctl start mhvtl.target
build ALL = (root) NOPASSWD:/usr/bin/systemctl stop mhvtl.target
build ALL = (root) NOPASSWD:/usr/bin/rm -rf /var/lib/mhvtl/*
build ALL = (root) NOPASSWD:/usr/bin/make_vtl_media --config-dir /etc/mhvtl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this? I think the setcap part if sufficient, don't you think so?

@arogge arogge force-pushed the dev/alaaeddineelamri/master/bscsicrypto-to-CLI11 branch from 365ac87 to b529b39 Compare August 20, 2024 16:04
Alaa Eddine Elamri and others added 16 commits August 26, 2024 09:31
`bstrncpy` makes sure the destination string is always null
terminated, which results in the last character of the string
being replaced with `0` which in turn makes the passphrase string
missing its last character.
Remove the hardcoded 1 to explicit STDOUT_FILENO
to redirect job messages to stdout
passphrase is not a cstring (no null terminator) so it cannot be
printed with %s; bstrncpy can copy length + 1 bytes but only length
bytes were allocated; etc.
- cmake scsi-crypto option can be ON by default, it is only
  triggered if tapes device are present.
- systemtests: cleanup cryptoc cache file.

Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
- Fix ScsicryptoSd call in bareos-config
- developerFAQ: quote tapedevice list
  Without the quote example in copy and paste call the second
  and beyond tape drives are called by sh (due to ; separator)

Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
Those tests will be activated with cmake autochanger and tapes drives
flag is present in cojunction with -Dscsi-crypto=ON.
We use quadstore-vtl to test and design the tests.

- add vtl functions to global scripts
- systemtests: remove obsolete plugin option values
this enables -w to work together with -s.
@bruno-at-bareos bruno-at-bareos force-pushed the dev/alaaeddineelamri/master/bscsicrypto-to-CLI11 branch from b529b39 to 8714eea Compare August 26, 2024 07:31
arogge and others added 5 commits August 28, 2024 10:02
in ctest there is no way to permanently hold a resource lock while a
fixture is set up.
Thus there could be cases where the different autochanger tests, even
though there is a lock in place, would run intermixed which doesn't
work. This now adds simple dependencies to make sure the next test using
an autochanger waits for the cleanup of another one.
the test's cleanup script now removes key material and encryption
settings from the tape drives when it is done.
@BareosBot BareosBot merged commit 756984d into master Aug 29, 2024
@BareosBot BareosBot deleted the dev/alaaeddineelamri/master/bscsicrypto-to-CLI11 branch August 29, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants