From owner-freebsd-bugs@FreeBSD.ORG Sun Apr 30 09:10:16 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9A9AB16A404 for ; Sun, 30 Apr 2006 09:10:16 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CE2043D58 for ; Sun, 30 Apr 2006 09:10:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k3U9AFuF016289 for ; Sun, 30 Apr 2006 09:10:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k3U9AF5l016288; Sun, 30 Apr 2006 09:10:15 GMT (envelope-from gnats) Resent-Date: Sun, 30 Apr 2006 09:10:15 GMT Resent-Message-Id: <200604300910.k3U9AF5l016288@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Helge Oldach Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 95ABC16A406 for ; Sun, 30 Apr 2006 09:05:47 +0000 (UTC) (envelope-from hmo@sep.oldach.net) Received: from rigel.oldach.net (rigel.oldach.net [194.8.96.250]) by mx1.FreeBSD.org (Postfix) with ESMTP id C921443D75 for ; Sun, 30 Apr 2006 09:05:34 +0000 (GMT) (envelope-from hmo@sep.oldach.net) Received: from sep.oldach.net (p548FA8B1.dip0.t-ipconnect.de [84.143.168.177]) by rigel.oldach.net (8.13.6/8.13.6/hmo30jul04) with ESMTP id k3U95ULG024919 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 30 Apr 2006 11:05:31 +0200 (CEST) (envelope-from hmo@sep.oldach.net) Received: from sep.oldach.net (localhost [127.0.0.1]) by sep.oldach.net (8.13.6/8.13.6/hmo26jun05) with ESMTP id k3U95TI3077576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 30 Apr 2006 11:05:29 +0200 (CEST) (envelope-from hmo@sep.oldach.net) Received: (from hmo@localhost) by sep.oldach.net (8.13.6/8.13.6/Submit/hmo26jun05) id k3U95S4N077575; Sun, 30 Apr 2006 11:05:28 +0200 (CEST) (envelope-from hmo) Message-Id: <200604300905.k3U95S4N077575@sep.oldach.net> Date: Sun, 30 Apr 2006 11:05:28 +0200 (CEST) From: Helge Oldach To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/96540: catman does not deal correctly with hard-linked files X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Helge Oldach List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Apr 2006 09:10:18 -0000 >Number: 96540 >Category: bin >Synopsis: catman does not deal correctly with hard-linked files >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Apr 30 09:10:13 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Helge Oldach >Release: FreeBSD 5.5-PRERELEASE i386 >Organization: >Environment: System: FreeBSD localhost 5.5-PRERELEASE FreeBSD 5.5-PRERELEASE #684: Thu Apr 27 00:38:13 CEST 2006 toor@localhost:/usr/obj/usr/src/sys/HMO i386 >Description: (Although this bug has been found on 5.5, it is present in all releases.) catman(1) does not correctly deal with hard links. This relates to the situation where the manpage source is a bunch of linked files, which is the case for example with the builtins to sh(1): man directory /usr/share/man section man1 format man1/alloc.1.gz -> cat1/alloc.1.gz link cat1/bg.1.gz -> cat1/alloc.1.gz link cat1/bind.1.gz -> cat1/alloc.1.gz link cat1/bindkey.1.gz -> cat1/alloc.1.gz link cat1/break.1.gz -> cat1/alloc.1.gz link cat1/breaksw.1.gz -> cat1/alloc.1.gz link cat1/builtin.1.gz -> cat1/alloc.1.gz link cat1/builtins.1.gz -> cat1/alloc.1.gz ...etc. The problem occurs if cat1/bg.1.gz already exists. In that case catman(1) just executes a link(cat1/alloc.1.gz, cat1/bg.1.gz), which fails with EEXIST. As a result, an old version of cat1/bg.1.gz remains. As a further complication, some catpages may already exist that are up to date, but are not hardlinked in the same fashion as the manpage sources. This might happen if a catman(1) without this fix had created them already. >How-To-Repeat: /etc/periodic/weekly/330.catman >Fix: Unconditionally remove a catpage link before checking whether it is up to date. The links will be installed shortly after. Note that this will take effect only if the first catpage of the linked set of catpages had been updated already. --- /usr/src/usr.bin/catman/catman.c.ctm Thu Jan 13 07:44:17 2005 +++ /usr/src/usr.bin/catman/catman.c Sun Apr 30 10:49:06 2006 @@ -416,6 +416,14 @@ } src_dev = test_st.st_dev; src_ino = test_st.st_ino; + if ((link_name = find_hashtable(links, src_ino, src_dev)) != NULL) { + if (verbose || pretend) { + fprintf(stderr, "%sunlink %s\n", + verbose ? "\t" : "", cat); + } + if (!pretend) + unlink(cat); + } cat_test = test_path(cat, &cat_mtime); if (cat_test & (TEST_FILE|TEST_READABLE)) { if (!force && cat_mtime >= src_mtime) { >Release-Note: >Audit-Trail: >Unformatted: