cloudera-scripts-for-log4j icon indicating copy to clipboard operation
cloudera-scripts-for-log4j copied to clipboard

code to backup for tar.gz is invalid

Open starkjs opened this issue 4 years ago • 3 comments

The code here is not working (cm_cdp_cdh_log4j_jndi_removal.sh line 139)

  local backupdir=${2:-/opt/cloudera/log4shell-backup}
  mkdir -p "$backupdir/$(dirname $tarfile)"
  targetbackup="$backupdir/$tarfile.backup"
  if [ ! -f "$targetbackup" ]; then
    echo "Backing up to '$targetbackup'"
    cp -f "$tarfile" "$targetbackup"
  fi

You do a mkdir for a path and then don't use it.

I can't see any backups for the *.tar.gz in the location of the backupdir

There is something wrong with this block of code

Also the function is always creating a new tar.gz, even if there is nothing to "patch" thus touching files which don't need to be altered - this is bad.....

starkjs avatar Dec 16 '21 02:12 starkjs

Related https://github.com/cloudera/cloudera-scripts-for-log4j/issues/27

lhoss avatar Dec 20 '21 10:12 lhoss

This is fixed now, it was related to data leaking due to reused variable names from function to function. I have made all variables within functions local now

starkjs avatar Dec 20 '21 10:12 starkjs

@starkjs Pertaining to this issue has the script been corrected by any chance or it is still the same in cm_cdp_cdh_log4j_jndi_removal.sh.

You do a mkdir for a path and then don't use it.

I can't see any backups for the *.tar.gz in the location of the backupdir

There is something wrong with this block of code

Also the function is always creating a new tar.gz, even if there is nothing to "patch" thus touching files which don't need to be altered - this is bad.....

abiboakye avatar Oct 24 '23 14:10 abiboakye