From owner-freebsd-bugs Wed Aug 15 7:38:58 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 4709737B40F; Wed, 15 Aug 2001 07:38:48 -0700 (PDT) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f7FEcOt21907; Wed, 15 Aug 2001 17:38:24 +0300 (EEST) (envelope-from ru) Date: Wed, 15 Aug 2001 17:38:24 +0300 From: Ruslan Ermilov To: Andre Albsmeier Cc: bugs@FreeBSD.org, Bruce Evans Subject: bug in install(1) (was: Re: conf/29699: Setting NO_MAILWRAPPER results in a system without working MTA) Message-ID: <20010815173824.D93566@sunbay.com> References: <200108141850.f7EIo1l18432@freefall.freebsd.org> <20010815150818.B93566@sunbay.com> <20010815150746.A10827@curry.mchp.siemens.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="R3G7APHDIzY6R/pk" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010815150746.A10827@curry.mchp.siemens.de>; from andre.albsmeier@mchp.siemens.de on Wed, Aug 15, 2001 at 03:07:46PM +0200 Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --R3G7APHDIzY6R/pk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Yes, I found the bug in install(1). It is only reproduceable if the symlink's target doesn't exist, i.e.: $ rm -f target $ ln -sf target link $ touch source $ install source link This will create `target'. I have introduced this bug when I added the `target' paramater to the create_newfile() function. The old (uncommitted) version was based on OpenBSD, and doesn't have this problem because create_newfile() always unlink(2)s or rename(2)s the `path'. Adding of the `target' parameter was an optimization, and this bug sneaked in accidentally. The attached patch fixes this. Bruce, could you please review the patch? Thanks for finding a bug, Andre! Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --R3G7APHDIzY6R/pk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p Index: xinstall.c =================================================================== RCS file: /home/ncvs/src/usr.bin/xinstall/xinstall.c,v retrieving revision 1.44 diff -u -p -r1.44 xinstall.c --- xinstall.c 2001/07/09 09:23:56 1.44 +++ xinstall.c 2001/08/15 14:29:52 @@ -299,12 +299,18 @@ install(from_name, to_name, fset, flags) } target = stat(to_name, &to_sb) == 0; - - /* Only install to regular files. */ - if (target && !S_ISREG(to_sb.st_mode)) { - errno = EFTYPE; - warn("%s", to_name); - return; + if (target) { + /* Only install to regular files. */ + if (!S_ISREG(to_sb.st_mode)) { + errno = EFTYPE; + warn("%s", to_name); + return; + } + } else { + /* We may still have a dead symlink. */ + serrno = errno; + (void)unlink(to_name); + errno = serrno; } /* Only copy safe if the target exists. */ --R3G7APHDIzY6R/pk-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message