Skip to content

Commit

Permalink
MT#58014 encrypt: Avoid remove leading / messages from tar
Browse files Browse the repository at this point in the history
We are prepending an extra / to the pathnames passed to tar, and
calling tar from a directory other than the root directory while
not telling it to use absolute names so it complains about these
two things with the following messages:

  ,---
  tar: Removing leading `/' from member names
  tar: Removing leading `/' from hard link targets
  tar: Removing leading `//' from member names
  tar: Removing leading `//' from hard link targets
  `---

which is something the user cannot do much about, and it's rather
annoying.

Change-Id: I9e9c853f26363e451b8883d3c74c5508ba3049dc
  • Loading branch information
guillemj committed Nov 21, 2023
1 parent dbd7bb3 commit 02055b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions scripts/decrypt
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ if ! gpg -d "${TARGZ}".gpg > "${TARGZ}" ; then
log_error "Error while decrypting ${TARGZ}.gpg"
RC=1
else
cd / # important to extract files at according place
if tar zxf "${TARGZ}" ; then
# For backwards compatibility we switch to the root directory, for old
# encrypted tarballs that stripped the leading /.
cd /
if tar zxPf "${TARGZ}" ; then
log_info "Successfully restored configuration archive ${TARGZ}.gpg"
log_info "Now you should be able to run 'ngcpcfg apply' again."
else
Expand Down
6 changes: 3 additions & 3 deletions scripts/encrypt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ get_config_file_list() {
# if the file does not exist (e.g. because "ngcpcfg apply"
# hasn't been executed yet for whatever reason, then don't
# report missing files, otherwise tar will complain
if [ -r "/${y}" ] ; then
echo "/${y}"
if [ -r "${y}" ] ; then
echo "${y}"
fi
done
done
Expand Down Expand Up @@ -61,7 +61,7 @@ fi

TARGZ=/etc/ngcp-config-crypted.tgz

tar zcf "${TARGZ}" /etc/ngcp-config/ "${FILES[@]}" /etc/.git
tar zcPf "${TARGZ}" /etc/ngcp-config/ "${FILES[@]}" /etc/.git
if gpg --symmetric "${TARGZ}" ; then
log_info "Successfully created encrypted ngcpcfg configuration archive ${TARGZ}.gpg"
# ensure we don't leave the unencrypted version behind
Expand Down

0 comments on commit 02055b8

Please sign in to comment.