From ben@scientia.demon.co.uk  Thu Feb 17 15:27:21 2000
Return-Path: <ben@scientia.demon.co.uk>
Received: from scientia.demon.co.uk (scientia.demon.co.uk [212.228.14.13])
	by hub.freebsd.org (Postfix) with ESMTP id A56A137B871
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 17 Feb 2000 15:27:11 -0800 (PST)
	(envelope-from ben@scientia.demon.co.uk)
Received: from platinum.scientia.demon.co.uk ([192.168.91.38] ident=exim)
	by scientia.demon.co.uk with esmtp (Exim 3.12 #1)
	id 12LYju-000NWn-00 for FreeBSD-gnats-submit@freebsd.org;
	Thu, 17 Feb 2000 21:45:34 +0000
Received: (from ben) by platinum.scientia.demon.co.uk (Exim 3.12 #7)
	id 12LYju-000Cwk-00 for FreeBSD-gnats-submit@freebsd.org;
	Thu, 17 Feb 2000 21:45:34 +0000
Message-Id: <E12LYju-000Cwk-00@platinum.scientia.demon.co.uk>
Date: Thu, 17 Feb 2000 21:45:34 +0000
From: Ben Smithurst <ben@scientia.demon.co.uk>
Reply-To: ben@scientia.demon.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Subject: pkg_add (maybe other pkg_*) fails when /var is symlink
X-Send-Pr-Version: 3.2

>Number:         16795
>Category:       bin
>Synopsis:       pkg_add (maybe other pkg_*) fails when /var is symlink
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 17 15:30:02 PST 2000
>Closed-Date:    Sat Feb 19 11:21:49 PST 2000
>Last-Modified:  Sat Feb 19 11:23:02 PST 2000
>Originator:     Ben Smithurst
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

>Description:

If /var is a symlink (e.g., to /usr/var to keep /var off the root partition
when there are just / and /usr partitions), pkg_add will fail to record data
into /var/db/pkg. This is because isdir(), called by make_hierarchy() uses
lstat() to determine if a path is a directory without checking if it is a
symlink or not.

>How-To-Repeat:

mv /var /var.old && ln -s /var.old /var
pkg_add <something>

(I'm not guaranteeing this will show the failure, but it certainly fails
in my case (it should), and doing this is probably easier for people to
check than moving all of /var to another filesystem.)

>Fix:

(apply in src/usr.sbin/pkg_install/lib, sorry about this not being a
proper "cvs diff" type thing.)

--- file.c.orig	Thu Feb 17 21:36:42 2000
+++ file.c	Thu Feb 17 21:39:12 2000
@@ -47,7 +47,7 @@
 {
     struct stat sb;
 
-    if (lstat(fname, &sb) != FAIL && S_ISDIR(sb.st_mode))
+    if (stat(fname, &sb) != FAIL && S_ISDIR(sb.st_mode))
 	return TRUE;
     else
 	return FALSE;

this may have other effects somewhere else, though it shouldn't (why should
anything in pkg_* care if something is a directory as opposed to a symlink
to one?).

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Sat Feb 19 11:21:49 PST 2000 
State-Changed-Why:  
Already fixed 
>Unformatted:
