[comp.unix.wizards] Tar broken on 4.3BSD?

ted@braggvax.arpa (12/18/87)

Try this on 4.3BSD:

		cd /tmp
		tar cf /dev/rmt8 /usr

Get the error:

tar: cannot change back?: /tmp//usr: No such file or directory


Sun tar and all the other tars I have used have no problem with this,
but 4.3 tar seems to handle absolute path names incorrectly.  Is this
a known bug, with a fix?  If not, I'll fix it and post the diffs.

				Thanks,

				Ted Nolan
				ted@braggvax.arpa

rbj@icst-cmr.arpa (Root Boy Jim) (12/30/87)

   Try this on 4.3BSD:

		   cd /tmp
		   tar cf /dev/rmt8 /usr

   Get the error:

   tar: cannot change back?: /tmp//usr: No such file or directory


   Sun tar and all the other tars I have used have no problem with this,
   but 4.3 tar seems to handle absolute path names incorrectly.  Is this
   a known bug, with a fix?  If not, I'll fix it and post the diffs.

Only a novice or a fool would use absolute pathnames in a tar command.

				   Ted Nolan
				   ted@braggvax.arpa


	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
My CODE of ETHICS is vacationing at famed SCHROON LAKE in upstate New York!!

stpeters@dawn.steinmetz (Dick St.Peters) (12/30/87)

In article <11036@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
>Only a novice or a fool would use absolute pathnames in a tar command.

"fool" is much too kind a description.

>	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
>	National Bureau of Standards
>	Flamer's Hotline: (301) 975-5688
>My CODE of ETHICS is vacationing at famed SCHROON LAKE in upstate New York!!

This time of year?  Your ETHICS.c has a bug in it.
--
Dick St.Peters                        
GE Corporate R&D, Schenectady, NY
stpeters@ge-crd.arpa              
uunet!steinmetz!stpeters

mark@omepd (Mark Aitken) (01/01/88)

In article <11036@brl-adm.ARPA< rbj@icst-cmr.arpa (Root Boy Jim) writes:
< ...
<
<Only a novice or a fool would use absolute pathnames in a tar command.
<
<
<	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
<	National Bureau of Standards
<	Flamer's Hotline: (301) 975-5688

Granted, but tar should not enforce that, e.g. it really is a bug in my
opinion.  

They say that goto's in programming languages are bad, but I'm glad C has 
them (it is MY responsibility to avoid using goto, not the language designer's).

Mark Aitken
mark@omepd.intel.com

ted@braggvax.arpa (01/04/88)

While I enjoy being called a fool and a novice as well as the next guy,
and so deeply appreciate all the helpful responses from the net, the fact
remains that 4.3 tar is BROKEN.

I never implied that using absolute pathnames in tar is a politically
correct or generally nice thing to do.  In fact, when I found the bug,
I was just using tar to generate some test traffic on a tape drive, not
for anything 'useful'.  However, there have been rare times when I have used
absolute pathnames with tar ON PURPOSE for reasons I considered good
and sufficient.  The fact that a behavior I have seen from v7 onwards
(and one still consistent with the manual page) no longer works I
consider a BUG.

(Deep breath)
Now, does anyone have a fix?

				Ted Nolan
				ted@braggvax.arpa

dce@mips.UUCP (01/11/88)

In article <11091@brl-adm.ARPA> ted@braggvax.arpa writes:
>While I enjoy being called a fool and a novice as well as the next guy,
>and so deeply appreciate all the helpful responses from the net, the fact
>remains that 4.3 tar is BROKEN.
>
>Now, does anyone have a fix?

Try this (use patch; my line numbers will be different from yours):

*** tar.c.old
--- tar.c
***************
*** 514,520 ****
  			sprintf(dblock.dbuf.chksum, "%6o", checksum());
  			(void) writetape((char *)&dblock);
  		}
! 		sprintf(newparent, "%s/%s", parent, shortname);
  		if (chdir(shortname) < 0) {
  			fflush(stderr);
  			perror(shortname);
--- 514,524 ----
  			sprintf(dblock.dbuf.chksum, "%6o", checksum());
  			(void) writetape((char *)&dblock);
  		}
! 		if (*shortname == '/') {
! 			strcpy(newparent, shortname);
! 		} else {
! 			sprintf(newparent, "%s/%s", parent, shortname);
! 		}
  		if (chdir(shortname) < 0) {
  			fflush(stderr);
  			perror(shortname);

-- 
David Elliott		dce@mips.com  or  {ames,prls,pyramid,decwrl}!mips!dce

adamm@encore.UUCP (Adam S. Moskowitz) (01/26/88)

Some time back, ted@braggvax posted a query about 4.3BSD tar & absolute path
names.  Did this issue ever get resolved (other than by telling Ted he was a
fool for using absolute pathnames)?  If so, would someone please post the fix
or the diffs or something?  If not, would someone please send me a good
explaination of why it isn't broken (and therefore shouldn't be fixed :-))?

Thanx in advance.
-- 
Adam S. Moskowitz	...!{decvax,ihnp4,linus,necntc,talcott}!encore!adamm

    "Bon-hommy," went on Eeyore gloomily.  "French word meaning
     bonhommy," he explained.  "I'm not complaining, but There It Is."