From owner-freebsd-bugs@FreeBSD.ORG Tue Oct 19 01:00:25 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41536106564A for ; Tue, 19 Oct 2010 01:00:25 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E25968FC21 for ; Tue, 19 Oct 2010 01:00:24 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o9J10OcB092257 for ; Tue, 19 Oct 2010 01:00:24 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o9J10OSt092234; Tue, 19 Oct 2010 01:00:24 GMT (envelope-from gnats) Resent-Date: Tue, 19 Oct 2010 01:00:24 GMT Resent-Message-Id: <201010190100.o9J10OSt092234@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, Peter Jeremy Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0381B106566B for ; Tue, 19 Oct 2010 00:54:44 +0000 (UTC) (envelope-from Peter.Jeremy@alcatel-lucent.com) Received: from ihemail3.lucent.com (ihemail3.lucent.com [135.245.0.37]) by mx1.freebsd.org (Postfix) with ESMTP id C2D208FC08 for ; Tue, 19 Oct 2010 00:54:43 +0000 (UTC) Received: from usnavsmail1.ndc.alcatel-lucent.com (usnavsmail1.ndc.alcatel-lucent.com [135.3.39.9]) by ihemail3.lucent.com (8.13.8/IER-o) with ESMTP id o9J0c0Ir018237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Oct 2010 19:38:00 -0500 (CDT) Received: from unixmail.au.alcatel-lucent.com (unixmail.au.alcatel-lucent.com [139.188.42.130]) by usnavsmail1.ndc.alcatel-lucent.com (8.14.3/8.14.3/GMO) with ESMTP id o9J0btn4030480 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 18 Oct 2010 19:37:59 -0500 Received: from insmb.au.alcatel-lucent.com (insmb.au.alcatel-lucent.com [139.188.42.184]) by unixmail.au.alcatel-lucent.com (8.13.8+Sun/8.13.3) with ESMTP id o9J0brlt020967 for ; Tue, 19 Oct 2010 11:37:53 +1100 (EST) Received: from pjdesk.au.alcatel-lucent.com (pjdesk.au.alcatel-lucent.com [139.188.12.19]) by insmb.au.alcatel-lucent.com (8.13.8+Sun/8.13.8) with ESMTP id o9J0UMop022566 for ; Tue, 19 Oct 2010 11:30:23 +1100 (EST) Received: from pjdesk.au.alcatel-lucent.com (localhost [127.0.0.1]) by pjdesk.au.alcatel-lucent.com (8.14.4/8.14.4) with ESMTP id o9J0UGRK049402; Tue, 19 Oct 2010 11:30:16 +1100 (EST) (envelope-from pjeremy@pjdesk.au.alcatel-lucent.com) Received: (from pjeremy@localhost) by pjdesk.au.alcatel-lucent.com (8.14.4/8.14.4/Submit) id o9J0UGAt049401; Tue, 19 Oct 2010 11:30:16 +1100 (EST) (envelope-from pjeremy) Message-Id: <201010190030.o9J0UGAt049401@pjdesk.au.alcatel-lucent.com> Date: Tue, 19 Oct 2010 11:30:16 +1100 (EST) From: Peter Jeremy To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/151567: [patch] lp(1) fails on ZFS filesystem X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Peter Jeremy List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2010 01:00:25 -0000 >Number: 151567 >Category: bin >Synopsis: [patch] lp(1) fails on ZFS filesystem >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Oct 19 01:00:24 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Peter Jeremy >Release: FreeBSD 8.1-PRERELEASE amd64 >Organization: Alcatel-Lucent Australia >Environment: System: FreeBSD pjdesk.au.alcatel-lucent.com 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #19: Wed Jul 14 07:24:18 EST 2010 root@pjdesk.au.alcatel-lucent.com:/var/obj/usr/src/sys/pjdesk amd64 The code is identical in -current. >Description: Printing from a ZFS filesystem using 'lp' fails and returns an email reporting "Your printer job was not printed because it was not linked to the original file". In order to protect against files being switched when files are printed using 'lp' or 'lpr -s', the st_dev and st_ino values for the original file are saved by lpr and verified by lpd before the file is printed. Unfortunately, lpr prints both values using '%d' (although both fields are unsigned) and lpd(8) assumes a string of decimal digits. ZFS (at least) generates st_dev values greater than 2^31-1, resulting in negative values being printed - which lpd cannot parse, leading it to report that the file has been switched. A similar problem would occur with large inode numbers. >How-To-Repeat: Find a file with either st_dev or st_ino greater than 2^31-1 (stat(1) will report both numbers) and print it with 'lpq -s'. This should generate an email reporting that the file could not be printed because it was not linked to the original file >Fix: Index: lpr/lpr.c =================================================================== RCS file: /usr/ncvs/src/usr.sbin/lpr/lpr/lpr.c,v retrieving revision 1.44.32.1 diff -u -r1.44.32.1 lpr.c --- lpr/lpr.c 3 Aug 2009 08:13:06 -0000 1.44.32.1 +++ lpr/lpr.c 19 Oct 2010 00:16:00 -0000 @@ -386,7 +386,7 @@ continue; /* file unreasonable */ if (sflag && (cp = linked(arg)) != NULL) { - (void) snprintf(buf, sizeof(buf), "%d %d", statb.st_dev, + (void) snprintf(buf, sizeof(buf), "%u %u", statb.st_dev, statb.st_ino); card('S', buf); if (format == 'p') >Release-Note: >Audit-Trail: >Unformatted: