head 1.4; access; symbols pkgsrc-2026Q1:1.4.0.104 pkgsrc-2026Q1-base:1.4 pkgsrc-2025Q4:1.4.0.102 pkgsrc-2025Q4-base:1.4 pkgsrc-2025Q3:1.4.0.100 pkgsrc-2025Q3-base:1.4 pkgsrc-2025Q2:1.4.0.98 pkgsrc-2025Q2-base:1.4 pkgsrc-2025Q1:1.4.0.96 pkgsrc-2025Q1-base:1.4 pkgsrc-2024Q4:1.4.0.94 pkgsrc-2024Q4-base:1.4 pkgsrc-2024Q3:1.4.0.92 pkgsrc-2024Q3-base:1.4 pkgsrc-2024Q2:1.4.0.90 pkgsrc-2024Q2-base:1.4 pkgsrc-2024Q1:1.4.0.88 pkgsrc-2024Q1-base:1.4 pkgsrc-2023Q4:1.4.0.86 pkgsrc-2023Q4-base:1.4 pkgsrc-2023Q3:1.4.0.84 pkgsrc-2023Q3-base:1.4 pkgsrc-2023Q2:1.4.0.82 pkgsrc-2023Q2-base:1.4 pkgsrc-2023Q1:1.4.0.80 pkgsrc-2023Q1-base:1.4 pkgsrc-2022Q4:1.4.0.78 pkgsrc-2022Q4-base:1.4 pkgsrc-2022Q3:1.4.0.76 pkgsrc-2022Q3-base:1.4 pkgsrc-2022Q2:1.4.0.74 pkgsrc-2022Q2-base:1.4 pkgsrc-2022Q1:1.4.0.72 pkgsrc-2022Q1-base:1.4 pkgsrc-2021Q4:1.4.0.70 pkgsrc-2021Q4-base:1.4 pkgsrc-2021Q3:1.4.0.68 pkgsrc-2021Q3-base:1.4 pkgsrc-2021Q2:1.4.0.66 pkgsrc-2021Q2-base:1.4 pkgsrc-2021Q1:1.4.0.64 pkgsrc-2021Q1-base:1.4 pkgsrc-2020Q4:1.4.0.62 pkgsrc-2020Q4-base:1.4 pkgsrc-2020Q3:1.4.0.60 pkgsrc-2020Q3-base:1.4 pkgsrc-2020Q2:1.4.0.56 pkgsrc-2020Q2-base:1.4 pkgsrc-2020Q1:1.4.0.36 pkgsrc-2020Q1-base:1.4 pkgsrc-2019Q4:1.4.0.58 pkgsrc-2019Q4-base:1.4 pkgsrc-2019Q3:1.4.0.54 pkgsrc-2019Q3-base:1.4 pkgsrc-2019Q2:1.4.0.52 pkgsrc-2019Q2-base:1.4 pkgsrc-2019Q1:1.4.0.50 pkgsrc-2019Q1-base:1.4 pkgsrc-2018Q4:1.4.0.48 pkgsrc-2018Q4-base:1.4 pkgsrc-2018Q3:1.4.0.46 pkgsrc-2018Q3-base:1.4 pkgsrc-2018Q2:1.4.0.44 pkgsrc-2018Q2-base:1.4 pkgsrc-2018Q1:1.4.0.42 pkgsrc-2018Q1-base:1.4 pkgsrc-2017Q4:1.4.0.40 pkgsrc-2017Q4-base:1.4 pkgsrc-2017Q3:1.4.0.38 pkgsrc-2017Q3-base:1.4 pkgsrc-2017Q2:1.4.0.34 pkgsrc-2017Q2-base:1.4 pkgsrc-2017Q1:1.4.0.32 pkgsrc-2017Q1-base:1.4 pkgsrc-2016Q4:1.4.0.30 pkgsrc-2016Q4-base:1.4 pkgsrc-2016Q3:1.4.0.28 pkgsrc-2016Q3-base:1.4 pkgsrc-2016Q2:1.4.0.26 pkgsrc-2016Q2-base:1.4 pkgsrc-2016Q1:1.4.0.24 pkgsrc-2016Q1-base:1.4 pkgsrc-2015Q4:1.4.0.22 pkgsrc-2015Q4-base:1.4 pkgsrc-2015Q3:1.4.0.20 pkgsrc-2015Q3-base:1.4 pkgsrc-2015Q2:1.4.0.18 pkgsrc-2015Q2-base:1.4 pkgsrc-2015Q1:1.4.0.16 pkgsrc-2015Q1-base:1.4 pkgsrc-2014Q4:1.4.0.14 pkgsrc-2014Q4-base:1.4 pkgsrc-2014Q3:1.4.0.12 pkgsrc-2014Q3-base:1.4 pkgsrc-2014Q2:1.4.0.10 pkgsrc-2014Q2-base:1.4 pkgsrc-2014Q1:1.4.0.8 pkgsrc-2014Q1-base:1.4 pkgsrc-2013Q4:1.4.0.6 pkgsrc-2013Q4-base:1.4 pkgsrc-2013Q3:1.4.0.4 pkgsrc-2013Q3-base:1.4 pkgsrc-2013Q2:1.4.0.2 pkgsrc-2013Q2-base:1.4 pkgsrc-2013Q1:1.3.0.10 pkgsrc-2013Q1-base:1.3 pkgsrc-2012Q4:1.3.0.8 pkgsrc-2012Q4-base:1.3 pkgsrc-2012Q3:1.3.0.6 pkgsrc-2012Q3-base:1.3 pkgsrc-2012Q2:1.3.0.4 pkgsrc-2012Q2-base:1.3 pkgsrc-2012Q1:1.3.0.2 pkgsrc-2012Q1-base:1.3 pkgsrc-2011Q4:1.2.0.4 pkgsrc-2011Q4-base:1.2 pkgsrc-2011Q3:1.2.0.2 pkgsrc-2011Q3-base:1.2 pkgsrc-2011Q2:1.1.1.1.0.14 pkgsrc-2011Q2-base:1.1.1.1 pkgsrc-2011Q1:1.1.1.1.0.12 pkgsrc-2011Q1-base:1.1.1.1 pkgsrc-2010Q4:1.1.1.1.0.10 pkgsrc-2010Q4-base:1.1.1.1 pkgsrc-2010Q3:1.1.1.1.0.8 pkgsrc-2010Q3-base:1.1.1.1 pkgsrc-2010Q2:1.1.1.1.0.6 pkgsrc-2010Q2-base:1.1.1.1 pkgsrc-2010Q1:1.1.1.1.0.4 pkgsrc-2010Q1-base:1.1.1.1 pkgsrc-2009Q4:1.1.1.1.0.2 pkgsrc-2009Q4-base:1.1.1.1 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.4 date 2013.04.10.15.34.02; author drochner; state Exp; branches; next 1.3; 1.3 date 2012.01.26.11.49.23; author drochner; state Exp; branches; next 1.2; 1.2 date 2011.07.13.19.58.54; author drochner; state Exp; branches; next 1.1; 1.1 date 2009.11.20.20.50.43; author drochner; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2009.11.20.20.50.43; author drochner; state Exp; branches 1.1.1.1.14.1; next ; 1.1.1.1.14.1 date 2011.07.16.21.11.49; author spz; state Exp; branches; next ; desc @@ 1.4 log @update to 4.0.17 changes: bugfixes pkgsrc note: The namespace problem fixed by patch-b* was reported upstream: https://bugs.linuxfoundation.org/show_bug.cgi?id=1095 @ text @$NetBSD$ --- foomaticrip.c.orig 2012-07-02 14:50:46.000000000 +0000 +++ foomaticrip.c @@@@ -180,7 +180,7 @@@@ char cupsfilterpath[PATH_MAX] = "/usr/lo "/opt/cups/filter:" "/usr/lib/cups/filter"; -char modern_shell[64] = "/bin/bash"; +char modern_shell[64] = "/bin/sh"; void config_set_option(const char *key, const char *value) { @@@@ -1014,7 +1014,7 @@@@ int print_file(const char *filename, int if (!ppd_supports_pdf()) { - char pdf2ps_cmd[PATH_MAX]; + char pdf2ps_cmd[FM_CMDLINE_MAX]; FILE *out, *in; int renderer_pid; char tmpfilename[PATH_MAX] = ""; @@@@ -1060,12 +1060,12 @@@@ int print_file(const char *filename, int We give priority to Ghostscript here and use Poppler if Ghostscript is not available. */ if (spooler == SPOOLER_CUPS) - snprintf(pdf2ps_cmd, PATH_MAX, + snprintf(pdf2ps_cmd, FM_CMDLINE_MAX, "pdftops '%s' '%s' '%s' '%s' '%s' '%s'", job->id, job->user, job->title, "1", job->optstr->data, filename); else - snprintf(pdf2ps_cmd, PATH_MAX, + snprintf(pdf2ps_cmd, FM_CMDLINE_MAX, "gs -q -sstdout=%%stderr -sDEVICE=ps2write -sOutputFile=- " "-dBATCH -dNOPAUSE -dPARANOIDSAFER -dNOINTERPOLATE %s 2>/dev/null || " "pdftops -level2 -origpagesizes %s - 2>/dev/null", @@@@ -1076,6 +1076,7 @@@@ int print_file(const char *filename, int if (dup2(fileno(out), fileno(stdin)) < 0) rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, "Couldn't dup stdout of pdf-to-ps\n"); + rewind(stdin); ret = print_file("", 0); @@@@ -1107,6 +1108,7 @@@@ int print_file(const char *filename, int /* Read further data from the file converter and not from STDIN */ if (dup2(fileno(fchandle), fileno(stdin)) < 0) rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, "Couldn't dup fileconverterhandle\n"); + rewind(stdin); ret = print_file("", 0); @ 1.3 log @update to 4.0.9 changes: -bugfixes (command injection fix was integrated) -minor feature extensions (color profile support, ghostscript speedup) @ text @d3 1 a3 1 --- foomaticrip.c.orig 2011-07-25 21:29:09.000000000 +0000 d14 25 a38 1 @@@@ -1068,6 +1068,7 @@@@ int print_file(const char *filename, int d46 1 a46 1 @@@@ -1099,6 +1100,7 @@@@ int print_file(const char *filename, int @ 1.2 log @add a patch from Suse bug #698451 (which is said there to originate from upstream but I couldn't locate it) to fix possible injection of shell commands in print requests which would be executed as the "lp" user bump PKGREV @ text @d3 1 a3 1 --- foomaticrip.c.orig 2011-07-13 13:54:29.000000000 +0000 d5 1 a5 1 @@@@ -177,7 +177,7 @@@@ char cupsfilterpath[PATH_MAX] = "/usr/lo d14 1 a14 1 @@@@ -1059,6 +1059,7 @@@@ int print_file(const char *filename, int d22 1 a22 1 @@@@ -1090,6 +1091,7 @@@@ int print_file(const char *filename, int a29 206 @@@@ -1236,8 +1238,11 @@@@ int main(int argc, char** argv) } /* Check for LPRng first so we do not pick up bogus ppd files by the -ppd option */ - if (arglist_remove_flag(arglist, "--lprng")) - spooler = SPOOLER_LPRNG; + if (spooler != SPOOLER_CUPS && spooler != SPOOLER_PPR && + spooler != SPOOLER_PPR_INT) { + if (arglist_remove_flag(arglist, "--lprng")) + spooler = SPOOLER_LPRNG; + } /* 'PRINTCAP_ENTRY' environment variable is : LPRng the :ppd=/path/to/ppdfile printcap entry should be used */ @@@@ -1259,96 +1264,104 @@@@ int main(int argc, char** argv) } } - /* PPD file name given via the command line - allow duplicates, and use the last specified one */ - if (spooler != SPOOLER_LPRNG) { - while ((str = arglist_get_value(arglist, "-p"))) { - strncpy(job->ppdfile, str, 256); - arglist_remove(arglist, "-p"); - } - } - while ((str = arglist_get_value(arglist, "--ppd"))) { - strncpy(job->ppdfile, str, 256); - arglist_remove(arglist, "--ppd"); - } - - /* Check for LPD/GNUlpr by typical options which the spooler puts onto - the filter's command line (options "-w": text width, "-l": text - length, "-i": indent, "-x", "-y": graphics size, "-c": raw printing, - "-n": user name, "-h": host name) */ - if ((str = arglist_get_value(arglist, "-h"))) { - if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) - spooler = SPOOLER_LPD; - strncpy(job->host, str, 127); - job->host[127] = '\0'; - arglist_remove(arglist, "-h"); - } - if ((str = arglist_get_value(arglist, "-n"))) { - if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) - spooler = SPOOLER_LPD; - - strncpy(job->user, str, 127); - job->user[127] = '\0'; - arglist_remove(arglist, "-n"); - } - if (arglist_remove(arglist, "-w") || - arglist_remove(arglist, "-l") || - arglist_remove(arglist, "-x") || - arglist_remove(arglist, "-y") || - arglist_remove(arglist, "-i") || - arglist_remove_flag(arglist, "-c")) { + /* CUPS calls foomatic-rip only with 5 or 6 positional parameters, + not with named options, like for example "-p ". Also PPR + does not used named options. */ + if (spooler != SPOOLER_CUPS && spooler != SPOOLER_PPR && + spooler != SPOOLER_PPR_INT) { + /* Check for LPD/GNUlpr by typical options which the spooler puts onto + the filter's command line (options "-w": text width, "-l": text + length, "-i": indent, "-x", "-y": graphics size, "-c": raw printing, + "-n": user name, "-h": host name) */ + if ((str = arglist_get_value(arglist, "-h"))) { + if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) + spooler = SPOOLER_LPD; + strncpy(job->host, str, 127); + job->host[127] = '\0'; + arglist_remove(arglist, "-h"); + } + if ((str = arglist_get_value(arglist, "-n"))) { if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) spooler = SPOOLER_LPD; - } - /* LPRng delivers the option settings via the "-Z" argument */ - if ((str = arglist_get_value(arglist, "-Z"))) { - spooler = SPOOLER_LPRNG; - dstrcatf(job->optstr, "%s ", str); - arglist_remove(arglist, "-Z"); - } - /* Job title and options for stock LPD */ - if ((str = arglist_get_value(arglist, "-j")) || (str = arglist_get_value(arglist, "-J"))) { - strncpy_omit(job->title, str, 128, omit_shellescapes); - if (spooler == SPOOLER_LPD) - dstrcatf(job->optstr, "%s ", job->title); - if (!arglist_remove(arglist, "-j")) - arglist_remove(arglist, "-J"); - } - /* Check for CPS */ - if (arglist_remove_flag(arglist, "--cps") > 0) - spooler = SPOOLER_CPS; - - /* Options for spooler-less printing, CPS, or PDQ */ - while ((str = arglist_get_value(arglist, "-o"))) { - strncpy_omit(tmp, str, 1024, omit_shellescapes); - dstrcatf(job->optstr, "%s ", tmp); - arglist_remove(arglist, "-o"); - /* If we don't print as PPR RIP or as CPS filter, we print - without spooler (we check for PDQ later) */ - if (spooler != SPOOLER_PPR && spooler != SPOOLER_CPS) - spooler = SPOOLER_DIRECT; - } - - /* Printer for spooler-less printing or PDQ */ - if ((str = arglist_get_value(arglist, "-d"))) { - strncpy_omit(job->printer, str, 256, omit_shellescapes); - arglist_remove(arglist, "-d"); - } - - /* Printer for spooler-less printing, PDQ, or LPRng */ - if ((str = arglist_get_value(arglist, "-P"))) { - strncpy_omit(job->printer, str, 256, omit_shellescapes); - arglist_remove(arglist, "-P"); - } - - /* Were we called from a PDQ wrapper? */ - if (arglist_remove_flag(arglist, "--pdq")) - spooler = SPOOLER_PDQ; - /* Were we called to build the PDQ driver declaration file? */ - genpdqfile = check_pdq_file(arglist); - if (genpdqfile) - spooler = SPOOLER_PDQ; + strncpy(job->user, str, 127); + job->user[127] = '\0'; + arglist_remove(arglist, "-n"); + } + if (arglist_remove(arglist, "-w") || + arglist_remove(arglist, "-l") || + arglist_remove(arglist, "-x") || + arglist_remove(arglist, "-y") || + arglist_remove(arglist, "-i") || + arglist_remove_flag(arglist, "-c")) { + if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) + spooler = SPOOLER_LPD; + } + /* LPRng delivers the option settings via the "-Z" argument */ + if ((str = arglist_get_value(arglist, "-Z"))) { + spooler = SPOOLER_LPRNG; + dstrcatf(job->optstr, "%s ", str); + arglist_remove(arglist, "-Z"); + } + /* Job title and options for stock LPD */ + if ((str = arglist_get_value(arglist, "-j")) || (str = arglist_get_value(arglist, "-J"))) { + strncpy_omit(job->title, str, 128, omit_shellescapes); + if (spooler == SPOOLER_LPD) + dstrcatf(job->optstr, "%s ", job->title); + if (!arglist_remove(arglist, "-j")) + arglist_remove(arglist, "-J"); + } + + /* Check for CPS */ + if (arglist_remove_flag(arglist, "--cps") > 0) + spooler = SPOOLER_CPS; + + /* PPD file name given via the command line + allow duplicates, and use the last specified one */ + if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG && + spooler != SPOOLER_LPD) { + while ((str = arglist_get_value(arglist, "-p"))) { + strncpy(job->ppdfile, str, 256); + arglist_remove(arglist, "-p"); + } + while ((str = arglist_get_value(arglist, "--ppd"))) { + strncpy(job->ppdfile, str, 256); + arglist_remove(arglist, "--ppd"); + } + } + + /* Options for spooler-less printing, CPS, or PDQ */ + while ((str = arglist_get_value(arglist, "-o"))) { + strncpy_omit(tmp, str, 1024, omit_shellescapes); + dstrcatf(job->optstr, "%s ", tmp); + arglist_remove(arglist, "-o"); + /* If we don't print as PPR RIP or as CPS filter, we print + without spooler (we check for PDQ later) */ + if (spooler != SPOOLER_PPR && spooler != SPOOLER_CPS) + spooler = SPOOLER_DIRECT; + } + + /* Printer for spooler-less printing or PDQ */ + if ((str = arglist_get_value(arglist, "-d"))) { + strncpy_omit(job->printer, str, 256, omit_shellescapes); + arglist_remove(arglist, "-d"); + } + + /* Printer for spooler-less printing, PDQ, or LPRng */ + if ((str = arglist_get_value(arglist, "-P"))) { + strncpy_omit(job->printer, str, 256, omit_shellescapes); + arglist_remove(arglist, "-P"); + } + + /* Were we called from a PDQ wrapper? */ + if (arglist_remove_flag(arglist, "--pdq")) + spooler = SPOOLER_PDQ; + + /* Were we called to build the PDQ driver declaration file? */ + genpdqfile = check_pdq_file(arglist); + if (genpdqfile) + spooler = SPOOLER_PDQ; + } /* spooler specific initialization */ switch (spooler) { @ 1.1 log @Initial revision @ text @d3 1 a3 1 --- foomaticrip.c.orig 2009-01-14 20:23:15.000000000 +0100 d5 1 a5 1 @@@@ -153,7 +153,7 @@@@ char cupsfilterpath[PATH_MAX] = "/usr/lo d14 1 a14 1 @@@@ -968,6 +968,7 @@@@ int print_file(const char *filename, int d22 1 a22 1 @@@@ -999,6 +1000,7 @@@@ int print_file(const char *filename, int d30 206 @ 1.1.1.1 log @add foomatic-filters-4.0.3 which is basically foomatic-rip, a printer filter This mostly duplicates pkgsrc/print/foomatic-filters but since there are likely compatibility problems wich different generations of foomatic-rip and PPDs I'll leave the old version intact. @ text @@ 1.1.1.1.14.1 log @Pullup ticket #3474 - requested by drochner print/foomatic4-filters: security patch Revisions pulled up: - print/foomatic4-filters/Makefile 1.10 - print/foomatic4-filters/distinfo 1.4 - print/foomatic4-filters/patches/patch-ac 1.2 ------------------------------------------------------------------- Module Name: pkgsrc Committed By: drochner Date: Wed Jul 13 19:58:54 UTC 2011 Modified Files: pkgsrc/print/foomatic4-filters: Makefile distinfo pkgsrc/print/foomatic4-filters/patches: patch-ac Log Message: add a patch from Suse bug #698451 (which is said there to originate from upstream but I couldn't locate it) to fix possible injection of shell commands in print requests which would be executed as the "lp" user bump PKGREV To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 pkgsrc/print/foomatic4-filters/Makefile cvs rdiff -u -r1.3 -r1.4 pkgsrc/print/foomatic4-filters/distinfo cvs rdiff -u -r1.1.1.1 -r1.2 pkgsrc/print/foomatic4-filters/patches/patch-ac @ text @d3 1 a3 1 --- foomaticrip.c.orig 2011-07-13 13:54:29.000000000 +0000 d5 1 a5 1 @@@@ -177,7 +177,7 @@@@ char cupsfilterpath[PATH_MAX] = "/usr/lo d14 1 a14 1 @@@@ -1059,6 +1059,7 @@@@ int print_file(const char *filename, int d22 1 a22 1 @@@@ -1090,6 +1091,7 @@@@ int print_file(const char *filename, int a29 206 @@@@ -1236,8 +1238,11 @@@@ int main(int argc, char** argv) } /* Check for LPRng first so we do not pick up bogus ppd files by the -ppd option */ - if (arglist_remove_flag(arglist, "--lprng")) - spooler = SPOOLER_LPRNG; + if (spooler != SPOOLER_CUPS && spooler != SPOOLER_PPR && + spooler != SPOOLER_PPR_INT) { + if (arglist_remove_flag(arglist, "--lprng")) + spooler = SPOOLER_LPRNG; + } /* 'PRINTCAP_ENTRY' environment variable is : LPRng the :ppd=/path/to/ppdfile printcap entry should be used */ @@@@ -1259,96 +1264,104 @@@@ int main(int argc, char** argv) } } - /* PPD file name given via the command line - allow duplicates, and use the last specified one */ - if (spooler != SPOOLER_LPRNG) { - while ((str = arglist_get_value(arglist, "-p"))) { - strncpy(job->ppdfile, str, 256); - arglist_remove(arglist, "-p"); - } - } - while ((str = arglist_get_value(arglist, "--ppd"))) { - strncpy(job->ppdfile, str, 256); - arglist_remove(arglist, "--ppd"); - } - - /* Check for LPD/GNUlpr by typical options which the spooler puts onto - the filter's command line (options "-w": text width, "-l": text - length, "-i": indent, "-x", "-y": graphics size, "-c": raw printing, - "-n": user name, "-h": host name) */ - if ((str = arglist_get_value(arglist, "-h"))) { - if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) - spooler = SPOOLER_LPD; - strncpy(job->host, str, 127); - job->host[127] = '\0'; - arglist_remove(arglist, "-h"); - } - if ((str = arglist_get_value(arglist, "-n"))) { - if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) - spooler = SPOOLER_LPD; - - strncpy(job->user, str, 127); - job->user[127] = '\0'; - arglist_remove(arglist, "-n"); - } - if (arglist_remove(arglist, "-w") || - arglist_remove(arglist, "-l") || - arglist_remove(arglist, "-x") || - arglist_remove(arglist, "-y") || - arglist_remove(arglist, "-i") || - arglist_remove_flag(arglist, "-c")) { + /* CUPS calls foomatic-rip only with 5 or 6 positional parameters, + not with named options, like for example "-p ". Also PPR + does not used named options. */ + if (spooler != SPOOLER_CUPS && spooler != SPOOLER_PPR && + spooler != SPOOLER_PPR_INT) { + /* Check for LPD/GNUlpr by typical options which the spooler puts onto + the filter's command line (options "-w": text width, "-l": text + length, "-i": indent, "-x", "-y": graphics size, "-c": raw printing, + "-n": user name, "-h": host name) */ + if ((str = arglist_get_value(arglist, "-h"))) { + if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) + spooler = SPOOLER_LPD; + strncpy(job->host, str, 127); + job->host[127] = '\0'; + arglist_remove(arglist, "-h"); + } + if ((str = arglist_get_value(arglist, "-n"))) { if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) spooler = SPOOLER_LPD; - } - /* LPRng delivers the option settings via the "-Z" argument */ - if ((str = arglist_get_value(arglist, "-Z"))) { - spooler = SPOOLER_LPRNG; - dstrcatf(job->optstr, "%s ", str); - arglist_remove(arglist, "-Z"); - } - /* Job title and options for stock LPD */ - if ((str = arglist_get_value(arglist, "-j")) || (str = arglist_get_value(arglist, "-J"))) { - strncpy_omit(job->title, str, 128, omit_shellescapes); - if (spooler == SPOOLER_LPD) - dstrcatf(job->optstr, "%s ", job->title); - if (!arglist_remove(arglist, "-j")) - arglist_remove(arglist, "-J"); - } - /* Check for CPS */ - if (arglist_remove_flag(arglist, "--cps") > 0) - spooler = SPOOLER_CPS; - - /* Options for spooler-less printing, CPS, or PDQ */ - while ((str = arglist_get_value(arglist, "-o"))) { - strncpy_omit(tmp, str, 1024, omit_shellescapes); - dstrcatf(job->optstr, "%s ", tmp); - arglist_remove(arglist, "-o"); - /* If we don't print as PPR RIP or as CPS filter, we print - without spooler (we check for PDQ later) */ - if (spooler != SPOOLER_PPR && spooler != SPOOLER_CPS) - spooler = SPOOLER_DIRECT; - } - - /* Printer for spooler-less printing or PDQ */ - if ((str = arglist_get_value(arglist, "-d"))) { - strncpy_omit(job->printer, str, 256, omit_shellescapes); - arglist_remove(arglist, "-d"); - } - - /* Printer for spooler-less printing, PDQ, or LPRng */ - if ((str = arglist_get_value(arglist, "-P"))) { - strncpy_omit(job->printer, str, 256, omit_shellescapes); - arglist_remove(arglist, "-P"); - } - - /* Were we called from a PDQ wrapper? */ - if (arglist_remove_flag(arglist, "--pdq")) - spooler = SPOOLER_PDQ; - /* Were we called to build the PDQ driver declaration file? */ - genpdqfile = check_pdq_file(arglist); - if (genpdqfile) - spooler = SPOOLER_PDQ; + strncpy(job->user, str, 127); + job->user[127] = '\0'; + arglist_remove(arglist, "-n"); + } + if (arglist_remove(arglist, "-w") || + arglist_remove(arglist, "-l") || + arglist_remove(arglist, "-x") || + arglist_remove(arglist, "-y") || + arglist_remove(arglist, "-i") || + arglist_remove_flag(arglist, "-c")) { + if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG) + spooler = SPOOLER_LPD; + } + /* LPRng delivers the option settings via the "-Z" argument */ + if ((str = arglist_get_value(arglist, "-Z"))) { + spooler = SPOOLER_LPRNG; + dstrcatf(job->optstr, "%s ", str); + arglist_remove(arglist, "-Z"); + } + /* Job title and options for stock LPD */ + if ((str = arglist_get_value(arglist, "-j")) || (str = arglist_get_value(arglist, "-J"))) { + strncpy_omit(job->title, str, 128, omit_shellescapes); + if (spooler == SPOOLER_LPD) + dstrcatf(job->optstr, "%s ", job->title); + if (!arglist_remove(arglist, "-j")) + arglist_remove(arglist, "-J"); + } + + /* Check for CPS */ + if (arglist_remove_flag(arglist, "--cps") > 0) + spooler = SPOOLER_CPS; + + /* PPD file name given via the command line + allow duplicates, and use the last specified one */ + if (spooler != SPOOLER_GNULPR && spooler != SPOOLER_LPRNG && + spooler != SPOOLER_LPD) { + while ((str = arglist_get_value(arglist, "-p"))) { + strncpy(job->ppdfile, str, 256); + arglist_remove(arglist, "-p"); + } + while ((str = arglist_get_value(arglist, "--ppd"))) { + strncpy(job->ppdfile, str, 256); + arglist_remove(arglist, "--ppd"); + } + } + + /* Options for spooler-less printing, CPS, or PDQ */ + while ((str = arglist_get_value(arglist, "-o"))) { + strncpy_omit(tmp, str, 1024, omit_shellescapes); + dstrcatf(job->optstr, "%s ", tmp); + arglist_remove(arglist, "-o"); + /* If we don't print as PPR RIP or as CPS filter, we print + without spooler (we check for PDQ later) */ + if (spooler != SPOOLER_PPR && spooler != SPOOLER_CPS) + spooler = SPOOLER_DIRECT; + } + + /* Printer for spooler-less printing or PDQ */ + if ((str = arglist_get_value(arglist, "-d"))) { + strncpy_omit(job->printer, str, 256, omit_shellescapes); + arglist_remove(arglist, "-d"); + } + + /* Printer for spooler-less printing, PDQ, or LPRng */ + if ((str = arglist_get_value(arglist, "-P"))) { + strncpy_omit(job->printer, str, 256, omit_shellescapes); + arglist_remove(arglist, "-P"); + } + + /* Were we called from a PDQ wrapper? */ + if (arglist_remove_flag(arglist, "--pdq")) + spooler = SPOOLER_PDQ; + + /* Were we called to build the PDQ driver declaration file? */ + genpdqfile = check_pdq_file(arglist); + if (genpdqfile) + spooler = SPOOLER_PDQ; + } /* spooler specific initialization */ switch (spooler) { @