Date: Wed, 15 Aug 2001 17:38:24 +0300 From: Ruslan Ermilov <ru@FreeBSD.org> To: Andre Albsmeier <andre.albsmeier@mchp.siemens.de> Cc: bugs@FreeBSD.org, Bruce Evans <bde@FreeBSD.org> 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> In-Reply-To: <20010815150746.A10827@curry.mchp.siemens.de>; from andre.albsmeier@mchp.siemens.de on Wed, Aug 15, 2001 at 03:07:46PM %2B0200 References: <200108141850.f7EIo1l18432@freefall.freebsd.org> <20010815150818.B93566@sunbay.com> <20010815150746.A10827@curry.mchp.siemens.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010815173824.D93566>