Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jun 1999 11:03:46 +0800
From:      Peter Wemm <peter@netplex.com.au>
To:        "Brian F. Feldman" <green@unixhelp.org>
Cc:        Kris Kennaway <kkennawa@physics.adelaide.edu.au>, Jean-Marc Zucconi <jmz@FreeBSD.org>, hoek@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/kern imgact_gzip.c 
Message-ID:  <19990622030346.622EA75@overcee.netplex.com.au>
In-Reply-To: Your message of "Mon, 21 Jun 1999 22:27:11 -0400." <Pine.BSF.4.10.9906212226070.57661-100000@janus.syracuse.net> 

next in thread | previous in thread | raw e-mail | index | archive | help
"Brian F. Feldman" wrote:
> On Tue, 22 Jun 1999, Peter Wemm wrote:
> 
> > Kris Kennaway wrote:
> > > On Tue, 22 Jun 1999, Jean-Marc Zucconi wrote:
> > > 
> > > >  > Use gzexe. I recently fixed some filename guessing weaknesses in the
     scr
> >     ipt,
> > > >  > so it should be quite safe to use.
> > > > 
> > > > gzexe is not an option when you boot from a floppy and when all must
> > > > fit in 1.44MB :-) 
> > > 
> > > Why not? gzexe is a once-off compression step which encapsulates the
> > > executable into a shell script, and has no other space overheads other th
    an
> > > decompression space on /tmp at run-time.
> > 
> > Yes, but you don't *have* /tmp at that time for the boot floppies..  You
> > have memory etc but not disk space.
> > 
> > > Kris
> > 
> > Cheers,
> > -Peter
> > 
> 
> AHEM!
> /tmp is part of an MFS, so how is that disk space?

Ahh yes, I forgot that / was read-write for MFS boots.  However:

#!/bin/sh
skip=18
if /usr/bin/tail +$skip $0 | gzip -cd > /tmp/gztmp$$; then
  chmod 700 /tmp/gztmp$$
  prog="`echo $0 | sed 's|^.*/||'`"
  if /bin/ln /tmp/gztmp$$ "/tmp/$prog" 2>/dev/null; then
    trap '/bin/rm -f /tmp/gztmp$$ "/tmp/$prog"; exit $res' 0
    (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$ "/tmp/$prog") 2>/dev/null &
    /tmp/"$prog" ${1+"$@"}; res=$?
  else
    trap '/bin/rm -f /tmp/gztmp$$; exit $res' 0
    (/bin/sleep 5; /bin/rm -f /tmp/gztmp$$) 2>/dev/null &
    /tmp/gztmp$$ ${1+"$@"}; res=$?
  fi
else
  echo Cannot decompress $0; exit 1
fi; exit $res

Now, if tail, sh, gzip, chmod, ln, sleep, rm, etc are all in the gzexe'd
crunched linked binary, how is it supposed to decompress itself?  "sh" itself
is part of the crunched binary, so what is going to decode sh when sh itself
is a shell script?

[..]
1152 -r-xr-xr-x  19 root  bin    1167360 Feb 23  1998 sh*
1152 -r-xr-xr-x  19 root  bin    1167360 Feb 23  1998 slattach*
1152 -r-xr-xr-x  19 root  bin    1167360 Feb 23  1998 sysinstall*
1152 -r-xr-xr-x  19 root  bin    1167360 Feb 23  1998 zcat*
[..]             ^^

Cheers,
-Peter




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990622030346.622EA75>