From owner-cvs-all Mon Jun 21 22: 8:40 1999 Delivered-To: cvs-all@freebsd.org Received: from janus.syracuse.net (janus.syracuse.net [205.232.47.15]) by hub.freebsd.org (Postfix) with ESMTP id BCCD715089; Mon, 21 Jun 1999 22:08:32 -0700 (PDT) (envelope-from green@unixhelp.org) Received: from localhost (green@localhost) by janus.syracuse.net (8.9.2/8.8.7) with ESMTP id BAA60310; Tue, 22 Jun 1999 01:08:04 -0400 (EDT) Date: Tue, 22 Jun 1999 01:08:04 -0400 (EDT) From: "Brian F. Feldman" X-Sender: green@janus.syracuse.net To: Kris Kennaway Cc: Peter Wemm , Jean-Marc Zucconi , hoek@freebsd.org, cvs-committers@freebsd.org, cvs-all@freebsd.org Subject: Re: cvs commit: src/sys/kern imgact_gzip.c In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-1974609729-930028084=:60297" Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-1974609729-930028084=:60297 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 22 Jun 1999, Kris Kennaway wrote: > On Tue, 22 Jun 1999, Peter Wemm wrote: > > > 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 > > This is the unpatched (insecure) version of gzexe (all the /tmp/gztmp$$'s), > but it's functionally the same. > > > 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? > > Yes, that seems to be a problem - gzexe depends on those executables. However > it shouldn't be too hard to recode this decompressor in C to perform the same > job without any external dependencies. The question is whether that would be > easier than fixing the kernel to handle gzipped ELF binaries transparently - > almost certainly it would be. How's what I attached? > > Kris > > > Cheers, > > -Peter > > ----- > "Never criticize anybody until you have walked a mile in their shoes, > because by that time you will be a mile away and have their shoes." > -- Unknown > > Brian Fundakowski Feldman _ __ ___ ____ ___ ___ ___ green@FreeBSD.org _ __ ___ | _ ) __| \ FreeBSD: The Power to Serve! _ __ | _ \._ \ |) | http://www.FreeBSD.org/ _ |___/___/___/ --0-1974609729-930028084=:60297 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=zexe Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=zexe IyEvYmluL3NoDQpvZj1gYmFzZW5hbWUgJDFgX3oNCmNzPSRvZi5jDQpjYXQg PiAkY3MgPDwgLg0KI2luY2x1ZGUgPHN5cy90eXBlcy5oPg0KI2luY2x1ZGUg PHN5cy9tbWFuLmg+DQojaW5jbHVkZSA8c3lzL3dhaXQuaD4NCiNpbmNsdWRl IDxzeXMvc3RhdC5oPg0KDQojaW5jbHVkZSA8emxpYi5oPg0KI2luY2x1ZGUg PGVyci5oPg0KI2luY2x1ZGUgPHVuaXN0ZC5oPg0KI2luY2x1ZGUgPHN0ZGlv Lmg+DQoNCiQoZGVmbGF0ZSA8ICQxIHwgZmlsZTJjICd1X2NoYXIgcHJvZ3Jh bVtdID0geyAnICcgfTsnKQ0KDQppbnQNCm1haW4oaW50IGF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aXRjaCAoZm9yaygpKSB7DQoJCWNhc2UgMDoN CgkJCWV4ZWN2KG91dHB1dG5hbWUsIGFyZ3YpOw0KCQljYXNlIC0xOg0KCQkJ ZXJyKDEsICJmb3JrIik7DQoJCWRlZmF1bHQ6DQoJCQl3YWl0KCZzdGF0dXMp Ow0KCX0NCgl1bmxpbmsob3V0cHV0bmFtZSk7DQoJZXhpdChzdGF0dXMpOw0K fQ0KLg0KY2MgLWx6IC1PIC1XYWxsICRjcyAtbyAkb2YNCnJtICRjcw0K --0-1974609729-930028084=:60297-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message