Date: Thu, 8 Oct 1998 18:37:55 +0300 From: Ruslan Ermilov <ru@ucb.crimea.ua> To: Satoshi Asami <asami@FreeBSD.ORG>, Ruslan Ermilov <ru@ucb.crimea.ua> Cc: FreeBSD Hackers <hackers@FreeBSD.ORG> Subject: Difficulty of symbolic links management in Ports (PATCH attached) Message-ID: <19981008183755.A9419@relay.ucb.crimea.ua>
next in thread | raw e-mail | index | archive | help
--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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19981008183755.A9419>