Subject: install/24457: metalog contains incorrect information for hard links
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <apb@cequrux.com>
List: netbsd-bugs
Date: 02/17/2004 16:34:14
>Number: 24457
>Category: install
>Synopsis: metalog contains incorrect information for hard links
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: install-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Feb 17 14:35:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Alan Barrett
>Release: NetBSD 1.6ZK
>Organization:
Not much
>Environment:
NetBSD 1.6ZK
Architecture: i386
Machine: i386
>Description:
Hard-linked files can end up with incorrect information in
${DESTDIR}/METALOG during a build; this incorrect information
also appears in /etc/mtree/set.* after an installation.
>How-To-Repeat:
$ build.sh -U [more options] release
$ tar -z -tvf ${RELEASEDIR}/${MACHINE}/binary/sets/base.tgz | grep 'sys*stat'
-r-xr-sr-x 1 root kmem 94915 Feb 16 17:23 ./usr/bin/systat
-r-xr-xr-x 2 root wheel 0 Feb 16 17:23 ./usr/bin/sysstat == ./usr/bin/systat
$ mkdir ${TEMPROOT}
$ tar -z -xpf ${RELEASEDIR}/${MACHINE}/binary/sets/base.tgz -C ${TEMPROOT}
$ ( cd ${TEMPROOT}/usr/bin ; ls -l sys*tat )
-r-xr-sr-x 2 root kmem 94915 Feb 16 17:23 sysstat
-r-xr-sr-x 2 root kmem 94915 Feb 16 17:23 systat
$ # note that sysstat is a hard link to systat
$ mtree -p ${TEMPROOT} -f ${TEMPROOT}/etc/mtree/base.set -e | grep -A 2 sysstat
usr/bin/sysstat:
gid (0, 2)
permissions (0555, 02555)
$ # note that mtree thinks sysstat should have had a different group and mode
$ grep 'bin/sys*stat' ${DESTDIR}/METALOG
./usr/bin/systat type=file mode=02555 uname=root gname=kmem time=1076945030.477119 size=94915 sha1=c4c7d795fbce718cdd955a312491259c8abbedce
./usr/bin/sysstat type=file mode=0555 size=94915 sha1=c4c7d795fbce718cdd955a312491259c8abbedce
$ grep 'bin/sys*stat' ${TEMPROOT}/etc/mtree/set.base
./usr/bin/systat type=file uname=root gname=kmem mode=02555 size=94915 time=1076945030.477119 sha1=c4c7d795fbce718cdd955a312491259c8abbedce
./usr/bin/sysstat type=file mode=0555 size=94915 sha1=c4c7d795fbce718cdd955a312491259c8abbedce
$ # note the incorrect modes for sysstat, but correct modes for systat
>Fix:
I don't see an easy fix. When a build is performed in unprivileged mode
using a metalog, bsd.links.mk doesn't know the correct uname/gname/mode,
and install(1) can't just guess it by stat(2)ing the target (because the
target will have different permissions as a result of the unprivileged
build).
The correct uname/gname/mode for the about-to-be-installed link (e.g.
usr/bin/sysstat) should already be recorded in the metalog's entry
for the previously-installed file (e.g. usr/bin/systat), so I suppose
bsd.links.mk could grep for it and pass it to install(1).
Or the mtree(1) syntax (and the metalog) could be extended to explicitly
record information like "sysstat should be a hard link to systat".
>Release-Note:
>Audit-Trail:
>Unformatted: