Skip to content

Commit

Permalink
More restorecon-related fixes
Browse files Browse the repository at this point in the history
This is yet another continuation to PR #1973 and #1960.

This fixes the tar ball and MD5 paths (which *were* caught by
unit test 5.2, except that I was asleep at the wheel).

It also adds /usr/sbin to the PATH: when the script is executed
under cron, that is not (always?) part of the inherited PATH
and the script complains that restorecon cannot be found.
  • Loading branch information
ndokos committed Nov 18, 2020
1 parent a01f1b4 commit dd96370
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions server/bin/gold/test-5.2.txt
Expand Up @@ -1103,10 +1103,10 @@ run-1970-01-01T00:00:42-UTC: pbench-satellite-cleanup ends: Total 3 tarballs cle
---- pbench-satellite-local/logs
--- pbench log file contents
+++ test-execution.log file contents
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-b-with-prefixes/tarball-0_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-b-with-prefixes/tarball-0_1970.01.01T00.42.00.tar.xz.md5
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-b-with-prefixes/tarball-w-dot-prefix_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-b-with-prefixes/tarball-w-dot-prefix_1970.01.01T00.42.00.tar.xz.md5
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-b-with-prefixes/tarball-w-prefix-dot_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-b-with-prefixes/tarball-w-prefix-dot_1970.01.01T00.42.00.tar.xz.md5
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-g-normal//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-g-normal/tarball-normal_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-g-normal//var/tmp/pbench-test-server/test-5.2/pbench-local/pbench-move-results-receive/fs-version-002/controller-g-normal/tarball-normal_1970.01.01T00.42.00.tar.xz.md5
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes/tarball-0_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes/tarball-0_1970.01.01T00.42.00.tar.xz.md5
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes/tarball-w-dot-prefix_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes/tarball-w-dot-prefix_1970.01.01T00.42.00.tar.xz.md5
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes/tarball-w-prefix-dot_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-b-with-prefixes/tarball-w-prefix-dot_1970.01.01T00.42.00.tar.xz.md5
restorecon /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-g-normal/tarball-normal_1970.01.01T00.42.00.tar.xz /var/tmp/pbench-test-server/test-5.2/pbench/archive/fs-version-001/controller-g-normal/tarball-normal_1970.01.01T00.42.00.tar.xz.md5
ssh pbench-satellite.example.com /var/tmp/pbench-test-server/test-5.2/opt/pbench-server-satellite/bin/pbench-sync-package-tarballs
ssh pbench-satellite.example.com /var/tmp/pbench-test-server/test-5.2/opt/pbench-server-satellite/bin/pbench-satellite-state-change /var/tmp/pbench-test-server/test-5.2/pbench-satellite/archive/fs-version-001
--- test-execution.log file contents
11 changes: 9 additions & 2 deletions server/bin/pbench-server-prep-shim-002.sh
Expand Up @@ -11,6 +11,11 @@
# load common things
. $dir/pbench-base.sh

# need /usr/sbin in the PATH for restorecon
if [[ ! ":$PATH:" =~ ":/usr/sbin:" ]]; then
PATH=$PATH:/usr/sbin; export PATH
fi

test -d $ARCHIVE || doexit "Bad ARCHIVE=$ARCHIVE"

errlog=$LOGSDIR/$PROG/$PROG.error
Expand Down Expand Up @@ -187,12 +192,14 @@ while read tbmd5 ;do
(( nerrs++ ))
continue
fi

# mv, as well as cp -a, does not restore the SELinux context properly, so we do it by hand
restorecon ${dest}/${tb} ${dest}/${tb}.md5
tbname=${resultname}.tar.xz
restorecon ${dest}/${tbname} ${dest}/${tbname}.md5
sts=${?}
if [[ ${sts} -ne 0 ]]; then
# log it but do not abort
log_error "${TS}: Error: \"restorecon ${dest}/${tb} ${dest}/${tb}.md5\", status ${sts}" "${status}"
log_error "${TS}: Error: \"restorecon ${dest}/${tbname} ${dest}/${tbname}.md5\", status ${sts}" "${status}"
fi

# Now that we have successfully moved the tar ball and its .md5 to the
Expand Down

0 comments on commit dd96370

Please sign in to comment.