From owner-freebsd-hackers Thu Oct 8 08:40:16 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA19007 for freebsd-hackers-outgoing; Thu, 8 Oct 1998 08:40:16 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from relay.ucb.crimea.ua (relay.ucb.crimea.ua [194.93.177.113]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA18613; Thu, 8 Oct 1998 08:38:25 -0700 (PDT) (envelope-from ru@ucb.crimea.ua) Received: (from ru@localhost) by relay.ucb.crimea.ua (8.8.8/8.8.8) id SAA09826; Thu, 8 Oct 1998 18:37:55 +0300 (EEST) (envelope-from ru) Date: Thu, 8 Oct 1998 18:37:55 +0300 From: Ruslan Ermilov To: Satoshi Asami , Ruslan Ermilov Cc: FreeBSD Hackers Subject: Difficulty of symbolic links management in Ports (PATCH attached) Message-ID: <19981008183755.A9419@relay.ucb.crimea.ua> Mail-Followup-To: Satoshi Asami , FreeBSD Hackers Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=Q68bSM7Ycu6FN28Q X-Mailer: Mutt 0.94.8i X-Operating-System: FreeBSD 2.2.7-STABLE i386 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Hi! Please see the PR "Portlint of net/bb" I just sent for an example of the problem described here. Suppose, the port creates a symbolic link. Then its Makefile (or [pre|post]install script) has a line like: ${LN} -fs ${PREFIX}/FROM_PATH ${PREFIX}/TO_PATH Now there are two ways to specify PLIST for this package. The 1st (lines in pkg/PLIST): @exec ln -fs %D/FROM_PATH %D/TO_PATH @unexec rm %D/TO_PATH The 2nd (line in pkg/PLIST): TO_PATH With the second approach: - there is no need to double ${LN} command in both Makefile and PLIST; - there is no need to specify @exec and @unexec because this link will be added automatically in the port's tarball; - the created tarball will be less in size than in the first approach ;-) - the second way is simpler. But there is one problem here. If the FROM_PATH is a file, then everything works fine. But if the FROM_PATH is a directory, then pkg_delete(1) will fail with "attempting to delete directory `TO_PATH' as a file". The actual problem lies in the src/usr.sbin/pkg_install/lib/file.c, in function isdir(). It uses stat() to answer the question, but should use lstat() instead to make the second approach work. It seems that it is safe to change stat() to lstat() here, since this doesn't change the logic of other code that uses isdir(). Patch is attached, it will apply against both -stable and -current. Best regards, -- Ruslan Ermilov Sysadmin and DBA of the ru@ucb.crimea.ua United Commercial Bank +380.652.247.647 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Index: file.c =================================================================== RCS file: /usr/FreeBSD-CVS/src/usr.sbin/pkg_install/lib/file.c,v retrieving revision 1.24.2.6 diff -u -r1.24.2.6 file.c --- file.c 1998/09/11 07:27:18 1.24.2.6 +++ file.c 1998/10/08 15:27:29 @@ -47,7 +47,7 @@ { struct stat sb; - if (stat(fname, &sb) != FAIL && S_ISDIR(sb.st_mode)) + if (lstat(fname, &sb) != FAIL && S_ISDIR(sb.st_mode)) return TRUE; else return FALSE; --Q68bSM7Ycu6FN28Q-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message