commit 47277aceed548255640352c752c6efddec2a824e Author: Bertram Scharpf Date: 2015-12-23 22:35:55 +0100 lpd: filter-path variable diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h index fb05d2f..6225722 100644 --- a/usr.sbin/lpr/common_source/lp.h +++ b/usr.sbin/lpr/common_source/lp.h @@ -57,6 +57,7 @@ struct printer { long conn_timeout; /* CT: TCP connection timeout */ long daemon_user; /* DU: daemon user id -- XXX belongs ???? */ char *form_feed; /* FF: form feed */ + char *filter_path; /* FP: PATH environment variable for filters */ long header_last; /* HL: print header last */ char *log_file; /* LF: log file */ char *lock_file; /* LO: lock file */ diff --git a/usr.sbin/lpr/common_source/lp.local.h b/usr.sbin/lpr/common_source/lp.local.h index 79cc52a..5fc1f8a 100644 --- a/usr.sbin/lpr/common_source/lp.local.h +++ b/usr.sbin/lpr/common_source/lp.local.h @@ -48,6 +48,8 @@ #define DEFUID 1 #define DEFTIMEOUT 120 +#define ENV_PATH "PATH" + /* * When files are created in the spooling area, they are normally * readable only by their owner and the spooling group. If you diff --git a/usr.sbin/lpr/common_source/printcap.c b/usr.sbin/lpr/common_source/printcap.c index 0d3644b..c895d44 100644 --- a/usr.sbin/lpr/common_source/printcap.c +++ b/usr.sbin/lpr/common_source/printcap.c @@ -217,7 +217,7 @@ static int getprintcap_int(char *bp, struct printer *pp) { enum lpd_filters filt; - char *rp_name; + char *p_path, *rp_name; int error; if ((pp->printer = capdb_canonical_name(bp)) == 0) @@ -231,6 +231,7 @@ getprintcap_int(char *bp, struct printer *pp) CHK(capdb_getaltnum(bp, "du", "daemon.user", DEFUID, &pp->daemon_user)); CHK(capdb_getaltstr(bp, "ff", "job.formfeed", DEFFF, &pp->form_feed)); + CHK(capdb_getaltstr(bp, "fp", "filt.path", 0, &pp->filter_path)); CHK(capdb_getaltstr(bp, "lf", "spool.log", _PATH_CONSOLE, &pp->log_file)); CHK(capdb_getaltstr(bp, "lo", "spool.lock", DEFLOCK, &pp->lock_file)); @@ -270,6 +271,17 @@ getprintcap_int(char *bp, struct printer *pp) pp->tof = !capdb_getaltlog(bp, "fo", "job.topofform"); /* + * Substitute spaces and commas in the PATH environment variable + * by colons. + */ + if (pp->filter_path) { + for (p_path = pp->filter_path; *p_path; p_path++) { + if (*p_path == ' ' || *p_path == ',') + *p_path = ':'; + } + } + + /* * Decide if the remote printer name matches the local printer name. * If no name is given then we assume they mean them to match. * If a name is given see if the rp_name is one of the names for @@ -344,6 +356,7 @@ free_printer(struct printer *pp) for (filt = 0; filt < LPF_COUNT; filt++) cfree(pp->filters[filt]); cfree(pp->form_feed); + cfree(pp->filter_path); cfree(pp->log_file); cfree(pp->lock_file); cfree(pp->lp); diff --git a/usr.sbin/lpr/lpd/printjob.c b/usr.sbin/lpr/lpd/printjob.c index 06ea1b0..e685a77 100644 --- a/usr.sbin/lpr/lpd/printjob.c +++ b/usr.sbin/lpr/lpd/printjob.c @@ -1680,6 +1680,12 @@ dofork(const struct printer *pp, int action) pp->printer, pp->daemon_user); break; } + fail = setenv(ENV_PATH, pp->filter_path, 1); + if (fail) { + syslog(LOG_ERR, "%s: setenv(%s, %s, 1): %m", + pp->printer, ENV_PATH, pp->filter_path); + break; + } } return (forkpid); } diff --git a/usr.sbin/lpr/lpr/printcap.5 b/usr.sbin/lpr/lpr/printcap.5 index 7076b5f..cf4314d 100644 --- a/usr.sbin/lpr/lpr/printcap.5 +++ b/usr.sbin/lpr/lpr/printcap.5 @@ -83,6 +83,7 @@ call) .Tn ( DVI format) .It "ff str" Ta So Li \ef Sc Ta No "string to send for a form feed" +.It "fp str" Ta So Li NULL Sc Ta No "PATH environment variable for filter command" .It "fo bool false print a form feed when device is opened" .It "gf str" Ta Dv NULL Ta No "graph data filter" .Xr ( plot 3 @@ -142,6 +143,7 @@ Each two-letter capability has a human-readable alternate name. .It "df filt.dvi" .It "du daemon.user" .It "ff job.formfeed" +.It "fp filt.path" .It "fo job.topofform" .It "gf filt.plot" .It "hl banner.last"