NetBSD Problem Report #36381
From hf@spg.tu-darmstadt.de Wed May 23 16:52:21 2007
Return-Path: <hf@spg.tu-darmstadt.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id A276B63B880
for <gnats-bugs@gnats.NetBSD.org>; Wed, 23 May 2007 16:52:21 +0000 (UTC)
Message-Id: <200705231651.l4NGprDw025494@Hochstuhl.nt.e-technik.tu-darmstadt.de>
Date: Wed, 23 May 2007 18:51:53 +0200 (CEST)
From: Hauke Fath <hf@spg.tu-darmstadt.de>
Reply-To: Hauke Fath <hf@spg.tu-darmstadt.de>
To: gnats-bugs@NetBSD.org
Cc: Hauke Fath <hf@spg.tu-darmstadt.de>
Subject: No accounting in lpd(8) for remote printing
X-Send-Pr-Version: 3.95
>Number: 36381
>Category: bin
>Synopsis: No accounting in lpd(8) for remote printing
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed May 23 16:55:00 +0000 2007
>Last-Modified: Thu Sep 10 18:30:01 +0000 2015
>Originator: Hauke Fath <hf@spg.tu-darmstadt.de>
>Release: NetBSD 3.1_STABLE
>Organization:
>Environment:
System: NetBSD Hochstuhl 3.1_STABLE NetBSD 3.1_STABLE (HOCHSTUHL) #0: Thu Mar 1 20:15:48 CET 2007 hf@Hochstuhl:/var/obj/netbsd-builds/3/i386/sys/arch/i386/compile/HOCHSTUHL i386
Architecture: i386
Machine: i386
>Description:
Some time ago, lpd(8) learned to optionally run filters for
remote (networked) printers, as well. Unfortunately, this
support doesn't go all the way, and filters are not provided
with the data in the printjob description - you cannot do
accounting. The fact is undocumented, which is why I file this
as a software bug.
Looking through usr.sbin/lpr/lpd/printjob.c, we see that
the job description is parsed in printit(), which is only
called for locally attached printers, whereas sendit() is used
for remote printers.
>How-To-Repeat:
Set up a printcap entry with accounting for a networked
printer. Find that /usr/libexec/lpr/lpf as well as any
homebaked filter scripts are not provided with any user
information.
>Fix:
Factor out the jobfile parser. Have sendit() call it as well,
and set the static variables that print() later feeds to the
filters.
>Audit-Trail:
From: Aran.Clauson@wwu.edu
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: bin/36381
Date: Thu, 10 Sep 2015 11:24:24 -0700 (PDT)
Gnats,
This isn't an elegant solution, but works for my purposes.
Aran
Index: usr.sbin/lpr/lpd/printjob.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/lpr/lpd/printjob.c,v
retrieving revision 1.56
diff -u -r1.56 printjob.c
--- usr.sbin/lpr/lpd/printjob.c 30 Aug 2011 19:27:37 -0000 1.56
+++ usr.sbin/lpr/lpd/printjob.c 9 Sep 2015 23:12:32 -0000
@@ -798,6 +798,7 @@
sendit(char *file)
{
int i, err = OK;
+ extern int rflag;
char *cp, last[BUFSIZ];
/*
@@ -812,6 +813,9 @@
* rest of the line is the argument.
* commands of interest are:
*
+ * H -- "host name" of machine where lpr was done
+ * J -- "job name" on banner page
+ * P -- "person" user's login name
* a-z -- "file name" name of file to print
* U -- "unlink" name of file to remove
* (after we print it. (Pass 2 only)).
@@ -822,6 +826,20 @@
*/
while (get_line(cfp)) {
again:
+ if (rflag) {
+ switch(line[0]) {
+ case 'H':
+ strlcpy(fromhost, line+1, sizeof(fromhost));
+ break;
+ case 'J':
+ strlcpy(jobname, line+1, sizeof(jobname));
+ break;
+ case 'P':
+ strlcpy(logname, line+1, sizeof(logname));
+ break;
+ }
+ }
+
if (line[0] == 'S') {
cp = line+1;
i = 0;
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.