Say one has a tar file called test.tar and wants to append some newfile
This works
*tar rvf test.tar newfile*
But what if one accidentally types (note the extra '/' in front of the
tar file name) and they don't have '/' permissions?
*tar rvf /test.tar newfile*
What gets *incorrectly *reported is:
tar: /test.tar: Cannot read: Bad file descriptor
tar: At beginning of tape, quitting now
tar: Error is not recoverable: exiting now
I tracked down the source of the problem in the 1.26 code and made a fix
to my local version to verify the correct results
tar: /test.tar: Cannot open: Permission denied
tar: Error is not recoverable: exiting now
The problem is in buffer.c line 753 after the call to rmtopen.
The switch statement on that line is called despite the /archive /file
descriptor being negative.
This is incorrect as no archive was opened and now the errno will get
changed by other calls.
L753 switch(check_compressed_archive(NULL))
The simple fix is to add an '/if/' statement prior to the switch as so:
archive = rmtopen( archive_name_array[0],
O_RDWR | O_CREAT | O_BINARY,
MODE_RW, rsh_command_option );
if( archive > 0)
{
switch( check_compressed_archive( NULL ) )
{
case ct_none:
case ct_tar:
break;
default:
FATAL_ERROR ((0, 0,
_("Cannot update compressed
archives")));
}
}
Now the code falls thru to intended /archive /file descriptor check.
Hope that helps.
Jeff