From owner-freebsd-bugs Tue Dec 17 5:10:10 2002 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 600D937B401 for ; Tue, 17 Dec 2002 05:10:07 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8D0EF43ED1 for ; Tue, 17 Dec 2002 05:10:06 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gBHDA6x3086906 for ; Tue, 17 Dec 2002 05:10:06 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gBHDA6lD086903; Tue, 17 Dec 2002 05:10:06 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 62E4A37B401 for ; Tue, 17 Dec 2002 05:04:45 -0800 (PST) Received: from ccduty.csie.nctu.edu.tw (ccduty.csie.nctu.edu.tw [140.113.209.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7C5AB43ED1 for ; Tue, 17 Dec 2002 05:04:44 -0800 (PST) (envelope-from wkwu@ccduty.csie.nctu.edu.tw) Received: from ccduty.csie.nctu.edu.tw (wkwu@localhost [127.0.0.1]) by ccduty.csie.nctu.edu.tw (8.12.6/8.12.3) with ESMTP id gBHD4hHB033550 for ; Tue, 17 Dec 2002 21:04:43 +0800 (CST) Received: (from wkwu@localhost) by ccduty.csie.nctu.edu.tw (8.12.6/8.12.6/Submit) id gBHD4hTh033549; Tue, 17 Dec 2002 21:04:43 +0800 (CST) Message-Id: <200212171304.gBHD4hTh033549@ccduty.csie.nctu.edu.tw> Date: Tue, 17 Dec 2002 21:04:43 +0800 (CST) From: Wei-Kai Wu Reply-To: Wei-Kai Wu To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: misc/46328: patch for lpd Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 46328 >Category: misc >Synopsis: patch for lpd >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Dec 17 05:10:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Wei-Kai Wu >Release: FreeBSD 4.7-STABLE i386 >Organization: Kavalan >Environment: >Description: I need to log the printed job for security reason. The man page of 'printcap' told me that when I specify the 'if' (input filter), it will invoke with arguments: if [-c] -wwidth -llength -iindent -n login -h host acct-file so I think it will be better if adding an additional argument: -j jobname I modify the usr.sbin/lpr/lpd/printjob.c as below: >How-To-Repeat: >Fix: --- usr.sbin/lpr/lpd/printjob.c Thu Jun 20 16:27:38 2002 +++ usr.sbin/lpr/lpd/printjob.c.new Tue Dec 17 20:50:50 2002 @@ -882,6 +882,24 @@ int dfcopies, err, i; char *cp, last[BUFSIZ]; + /* + * FreeBSD's cf files may put the 'N'(or 'J') after the 'f' line + * open control file for Parsing the jobname first + */ + if ((cfp = fopen(file, "r")) == NULL) + return (OK); + + while (getline(cfp)) { + if (line[0] == 'J' || line[0] == 'N') { + if (line[1] != '\0') { + strlcpy(jobname, line + 1, sizeof(jobname)); + } else + strcpy(jobname, "(standard in)"); + break; + } + } + fclose(cfp); + /* * open control file */ @@ -988,8 +1006,8 @@ { int i, amt; struct stat stb; - char *av[15], *filtcmd; - char buf[BUFSIZ], opt_c[4], opt_h[4], opt_n[4]; + char *av[17], *filtcmd; + char buf[BUFSIZ], opt_c[4], opt_h[4], opt_j[4], opt_n[4]; int copycnt, filtstat, narg, resp, sfd, sfres, sizerr, statrc; statrc = lstat(file, &stb); @@ -1048,6 +1066,7 @@ narg = 0; strcpy(opt_c, "-c"); strcpy(opt_h, "-h"); + strcpy(opt_j, "-j"); strcpy(opt_n, "-n"); if (format == 'l') av[++narg] = opt_c; @@ -1058,6 +1077,8 @@ av[++narg] = logname; av[++narg] = opt_h; av[++narg] = origin_host; + av[++narg] = opt_j; + av[++narg] = jobname; av[++narg] = pp->acct_file; av[++narg] = NULL; } else if (pp->filters[LPF_OUTPUT]) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message