Date: Tue, 17 Dec 2002 21:04:43 +0800 (CST) From: Wei-Kai Wu <wkwu@csie.nctu.edu.tw> To: FreeBSD-gnats-submit@FreeBSD.org Subject: misc/46328: patch for lpd Message-ID: <200212171304.gBHD4hTh033549@ccduty.csie.nctu.edu.tw>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212171304.gBHD4hTh033549>
