From owner-freebsd-bugs Fri Mar 7 15:40: 6 2003 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 2F36B37B401 for ; Fri, 7 Mar 2003 15:40:03 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 18ADE43FD7 for ; Fri, 7 Mar 2003 15:40:02 -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 h27Ne1NS096559 for ; Fri, 7 Mar 2003 15:40:01 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h27Ne1e1096558; Fri, 7 Mar 2003 15:40:01 -0800 (PST) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B9B1437B401 for ; Fri, 7 Mar 2003 15:36:42 -0800 (PST) Received: from dutton3.it.siu.edu (dutton3.it.siu.edu [131.230.6.142]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0EF9843FBF for ; Fri, 7 Mar 2003 15:36:42 -0800 (PST) (envelope-from jimd@dutton3.it.siu.edu) Received: from dutton3.it.siu.edu (localhost [127.0.0.1]) by dutton3.it.siu.edu (8.12.7/8.12.7) with ESMTP id h27Ni9bW042658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 7 Mar 2003 17:44:09 -0600 (CST) Received: (from root@localhost) by dutton3.it.siu.edu (8.12.7/8.12.7/Submit) id h27Ni82b042657; Fri, 7 Mar 2003 17:44:08 -0600 (CST) Message-Id: <200303072344.h27Ni82b042657@dutton3.it.siu.edu> Date: Fri, 7 Mar 2003 17:44:08 -0600 (CST) From: jimd@siu.edu Reply-To: jimd@siu.edu To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: i386/49023: Mod to LPD (printjob.c) to pass source filename to input filters 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: 49023 >Category: i386 >Synopsis: Mod to LPD (printjob.c) to pass source filename to input filters >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Fri Mar 07 15:40:01 PST 2003 >Closed-Date: >Last-Modified: >Originator: JD >Release: FreeBSD 4.7-RELEASE i386 >Organization: >Environment: System: FreeBSD xxxxxxxxx 4.7-RELEASE FreeBSD 4.7-RELEASE #2: Thu Jan 30 14:21:04 CST 2003 xxxx:/usr/src/sys/compile/XSYSTEM i386 >Description: Add small section to PRINTJOB.C in /usr/src/usr.sbin/lpr/lpd to extract the source file name from the (LPD) control file and pass it to the input filter, along with another "identifying" parameter, at the end of the current/normal parameter string. The last two parameters below are what get added to the input filter parameter list: -w132 -l66 -i0 -n xxxx -h xxxx /var/account/lp.printacct -fn .cshrc This will allow remote LPD's to do special actions on print files based on their original source file name, and is really intended for use in an input filter so it can achieve specialization without having to use other, external, methods to derive meaningful identifying information about the file waiting for it on STDIN. >How-To-Repeat: >Fix: *** printjob.c.orig Wed Feb 19 17:42:35 2003 --- printjob.c Fri Mar 7 16:53:30 2003 *************** *** 114,119 **** --- 114,121 ---- /* indentation size in static characters */ static char indent[10] = "-i0"; static char jobname[100]; /* job or file name */ + static char ofilename[100]; /* name of (source) file to print - JD*/ + static long origfpos = 0L; /* original cfp file position - JD */ static char length[10] = "-l"; /* page length in lines */ static char logname[32]; /* user's login name */ static char pxlength[10] = "-y"; /* page length in pixels */ *************** *** 439,445 **** */ /* pass 1 */ - while (getline(cfp)) switch (line[0]) { case 'H': --- 441,446 ---- *************** *** 479,485 **** } else strcpy(jobname, " "); continue; - case 'C': if (line[1] != '\0') strlcpy(class, line + 1, sizeof(class)); --- 480,485 ---- *************** *** 645,650 **** --- 645,674 ---- (void) close(fi); return (OK); } + + /* + * reset pointer to config file, parse cf for filename, + * reset pointer again to where it was before we got here + * + * JD 06 March 2003 + * + */ + origfpos = ftell(cfp); /* get previous file position */ + fseek(cfp, 0L, 0); /* set file position to beginning of file */ + strcpy(ofilename, " "); /* initialize variable */ + while (getline(cfp)) + switch (line[0]){ + case 'N': + if (line[1] != '\0') { + strlcpy(ofilename, line + 1, sizeof(ofilename)); + } + else strcpy(ofilename, " "); + continue; + default: continue; + } + fseek(cfp, origfpos, 0); /* reset file pointer */ + /*-------------------- JD */ + switch (format) { case 'p': /* print file using 'pr' */ if (pp->filters[LPF_INPUT] == NULL) { /* use output filter */ *************** *** 780,785 **** --- 804,811 ---- av[n++] = "-h"; av[n++] = origin_host; av[n++] = pp->acct_file; + av[n++] = "-fn"; /* added 20 Feb 2003 - JD */ + av[n++] = ofilename; /* added 20 Feb 2003 - JD */ av[n] = 0; fo = pfd; if (of_pid > 0) { /* stop output filter */ >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message