--- lpr-5.9.orig/lprm/lprm.c +++ lpr-5.9/lprm/lprm.c @@ -77,6 +77,14 @@ name = argv[0]; gethostname(host, sizeof(host)); + { /* use the official host name */ + register struct hostent *hp; + + if (hp = gethostbyname(host)) + strcpy(host, hp->h_name); + else + fatal("unable to get official name for local machine"); + } openlog("lpd", 0, LOG_LPR); if ((p = getpwuid(getuid())) == NULL) fatal("Who are you?"); --- lpr-5.9.orig/lpr/lpr.c +++ lpr-5.9/lpr/lpr.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -85,7 +86,7 @@ char *title; /* pr'ing title */ char *fonts[4]; /* troff font names */ char *width; /* width for versatec printing */ -char host[32]; /* host name */ +char host[MAXHOSTNAMELEN]; /* host name */ char *class = host; /* class title on header page */ char *jobname; /* job name on header page */ char *name; /* program name */ @@ -333,7 +334,8 @@ continue; /* file unreasonable */ if (sflag && (cp = linked(arg)) != NULL) { - (void) sprintf(buf, "%d %d", statb.st_dev, statb.st_ino); + (void) sprintf(buf, "%d %d", + (int) statb.st_dev, (int) statb.st_ino); card('S', buf); if (format == 'p') card('T', title ? title : arg); @@ -461,8 +463,8 @@ } break; } - strcat(buf, "/"); - strcat(buf, file); + strncat(buf, "/", sizeof(buf) - strlen(buf) - 1); + strncat(buf, file, sizeof(buf) - strlen(buf) - 1); file = buf; } return(symlink(file, dfname) ? NULL : file); --- lpr-5.9.orig/lpd/printjob.c +++ lpr-5.9/lpd/printjob.c @@ -45,6 +45,7 @@ #include "lp.h" #include "pathnames.h" +#include #define DORETURN 0 /* absorb fork error */ #define DOABORT 1 /* abort if dofork fails */ --- lpr-5.9.orig/lpd/lpd.c +++ lpr-5.9/lpd/lpd.c @@ -453,7 +453,8 @@ hostf = fopen(_PATH_HOSTSEQUIV, "r"); again: if (hostf) { - if (!_validuser(hostf, ahost, DUMMY, DUMMY, baselen)) { + if (__ivaliduser(hostf, f->sin_addr.s_addr, + DUMMY, DUMMY) == 0) { (void) fclose(hostf); return; } --- lpr-5.9.orig/lpc/cmds.c +++ lpr-5.9/lpc/cmds.c @@ -213,8 +213,13 @@ { int c = d->d_name[0]; +#if 1 /* HP-UX hack. */ + if ((c == 'c' && d->d_name[1] == 'f') || c == 't' || c == 'd') + return(1); +#else if ((c == 't' || c == 'c' || c == 'd') && d->d_name[1] == 'f') return(1); +#endif return(0); } --- lpr-5.9.orig/common_source/lp.local.h +++ lpr-5.9/common_source/lp.local.h @@ -43,7 +43,11 @@ * printing objects files. */ +#if !defined(__alpha) && !defined(LINUX) #include +#else +#include +#endif #include #ifndef A_MAGIC1 /* must be a VM/UNIX system */ --- lpr-5.9.orig/Makefile +++ lpr-5.9/Makefile @@ -1,10 +1,9 @@ .EXPORT_ALL_VARIABLES: CC = gcc -CFLAGS = -O2 -fomit-frame-pointer -include /usr/include/bsd/bsd.h \ - -I/usr/include/bsd -I../common_source -LDFLAGS = -N -s -LDLIBS = -lbsd -lcommon -L ../common_source +CFLAGS = -O2 -I../common_source +LDFLAGS = +LDLIBS = -lcommon -L ../common_source SUBDIRS = common_source filters lpc lpd lpq lpr lprm lptest pac --- lpr-5.9.orig/printcap.5 +++ lpr-5.9/printcap.5 @@ -109,7 +109,7 @@ .Tn FORTRAN style text files .It "rg str" Ta Dv NULL Ta No "restricted group. Only members of group allowed access" -.It "rm str" Ta Dv NULL Ta No "machine name for remote printer" +.It "rm str" Ta Dv NULL Ta No "machine name for remote printer (filters not run)" .It "rp str ``lp'' remote printer name argument" .It "rs bool false restrict remote users to those with local accounts" .It "rw bool false open the printer device for reading and writing" @@ -245,6 +245,41 @@ .Xr syslog 3 , and must not ignore .Dv SIGINT . +.Pp +Here is a sample filter, which eliminates the "stairstep" effect by +inserting a carriage return before each line feed: +.Bd -unfilled indent + #!perl + while(){chop $_; print "$_\\r\\n";}; +.Ed +.Pp +No filters are run for remote printers. However, it is possible to +run one by setting up a double queue and requeueing the job. As an +example, consider this printcap: +.Bd -unfilled indent + lj5:remote-hplj:\\ + :lp=/dev/null:sh:\\ + :sd=/var/spool/lpd/lj5:\\ + :if=/usr/lib/lpd/filter-lj5: + lj5-remote:lp=/dev/null:sh:rm=printer.name.com:\\ + :rp=raw:sd=/var/spool/lpd/lj5-raw: +.Ed +.Pp +in light of this +.Em filter-lj5 +script: +.Bd -unfilled indent + #!/bin/sh + gs -q -dSAFER -sOutputFile=- - | lpr -Plj5-remote -U$5 +.Ed +.Pp +Text sent to lj5 is processed by the script, which forwards it +to lj5-remote. +.Pp +The -U option to lpr only works if lpr is run as daemon, and it sets +the submitter's name for the job in the resubmitted queue. You should +probably use a more robust method of getting the username, since it is +not argument 5 if the -c option is passed (see above). .Sh LOGGING Error messages generated by the line printer programs themselves (that is, the --- lpr-5.9.orig/debian/changelog +++ lpr-5.9/debian/changelog @@ -0,0 +1,145 @@ +lpr (5.9-26) frozen unstable; urgency=low + + * Now "Depends" on netbase (closes: #20807) + * Moved heavily modified rc.lpd to debian/init + * Changes to debian/rules: + + Requires version 0.72 or greater of debhelper + + Use "dh_installinit --init-script=lpd" + + Use dh_fixperms + + -- Adam Klein Fri, 10 Apr 1998 16:27:46 -0400 + +lpr (5.9-25) frozen unstable; urgency=low + + * Added patch for Alpha (closes: #19551) + + -- Adam Klein Sun, 22 Mar 1998 01:19:11 -0500 + +lpr (5.9-24) unstable; urgency=low + + * Tweaked preinst + * Removed "set -e" from init.d script + * Corrected spelling in description (closes: #18937) + * Removed dh_du call in debian/rules + * Symlink lpf.1 to undocumented.7 + * Tweaked init.d script + * Changes made in the last version but not documented: + Added a cron.weekly script (closes: #7409) + Added "Suggests: magicfilter" to debian/control + + -- Adam Klein Sat, 21 Feb 1998 21:41:53 -0800 + +lpr (5.9-23) unstable; urgency=low + + * Uses debhelper + * lpr/lpr.c: fixed symlink inode validation (closes: #16205) + * Uses printcap.5 manpage from Jim Van Zandt + (closes: #16946) + * Tweaked preinst + * Updated to Standards-Version 2.4.0.0 + + -- Adam Klein Tue, 10 Feb 1998 20:28:57 -0800 + +lpr (5.9-22) unstable; urgency=low + + * New maintainer + + -- Adam Klein Tue, 10 Feb 1998 20:04:30 -0800 + +lpr (5.9-21) unstable; urgency=low + + * recompiled against libc6 + * lpd/lpd.c: use __ivaliduser instead of _validuser + * debian/rules: strip executables (#14564, #15323) + * lpr/lpr.c: set char host[] length to MAXHOSTNAMELEN + * lpr/lpr.c: print symlink inode validation info as unsigned + * debian/rules: clean target: remove */*~ + * debian/rules: install debian/changelog (#12673) + + -- Sven Rudolph Mon, 22 Dec 1997 16:55:35 +0100 + +lpr (5.9-20) stable unstable; urgency=low + + * debian/postinst: add $i to chown call + + -- Sven Rudolph Wed, 30 Jul 1997 23:10:15 +0200 + +lpr (5.9-19) stable unstable; urgency=low + + * upload to stable with long changelog + * create logfiles in postinst (part of #7409) + * debian/control: extended description changed + + -- Sven Rudolph Wed, 30 Jul 1997 12:00:23 +0200 + +lpr (5.9-18) stable unstable; urgency=low + + * upload to stable + + -- Sven Rudolph Sun, 20 Jul 1997 15:46:43 +0200 + +lpr (5.9-17) unstable; urgency=low + + * debian/rules: don't reset permission/ownership for lpr etc. + + -- Sven Rudolph Tue, 15 Jul 1997 13:05:56 +0200 + +lpr (5.9-16) unstable; urgency=low + + * lpr/lpr.c: avoid buffer overflow via strcat + + -- Sven Rudolph Wed, 9 Jul 1997 22:11:43 +0200 + +lpr (5.9-15) unstable; urgency=low + + * lpc/cmds.c: added workaround for new HP-UX bug; by + Miquel van Smoorenburg + + -- Sven Rudolph Tue, 8 Jul 1997 23:29:25 +0200 + +lpr (5.9-14) unstable; urgency=low + + * converted to Standards-Version: 2.1.0.0 (#7117) + * lprm/lprm.c: use FQDN for permission checking; patch by + Juan-Mariano de Goyeneche + (#5791, #6085, #7589, #7611, #8438, #8689, #11032) + * Makefile: don't set -N -s for LDFLAGS + + -- Sven Rudolph Sun, 6 Jul 1997 22:04:45 +0200 + +lpr (5.9-13) unstable; urgency=low + +Sun Nov 24 21:03:28 1996 Sven Rudolph + + * lpr/lpr.c: fixed buffer-overflow security bug + +Mon Jul 29 22:38:55 1996 Sven Rudolph + + * debian.rules: added multi-architecture support (Bug#3346) + + * lpr/lpr.c: added fix for canonizing hostname (Bug#3034, patch + in Bug#3038) + + * lpd/recvjob.c: chksize should work now (Bug#3935) + + * debian.rules: fixed typo in clean rule, deleted some junk (Bug#2555) + + * new maintainer + +Sat Nov 25 17:04:59 EST 1995 D.J. Gregor + + lpr-5.9-7: + + * removed if filter from etc.printcap + + * changed maintainer + + +Fri May 12 01:17:37 MET DST 1995 Peter Tobias + + lpr-5.9-6: + + * moved filter.ps/filter.pcl files to /etc and added them to + conffiles (Bug#858) + + * Added a short notice about filter entries to /etc/printcap --- lpr-5.9.orig/debian/conffiles +++ lpr-5.9/debian/conffiles @@ -0,0 +1,6 @@ +/etc/printcap +/etc/hosts.lpd +/etc/init.d/lpd +/etc/filter.pcl +/etc/filter.ps +/etc/cron.weekly/lpr --- lpr-5.9.orig/debian/dirs +++ lpr-5.9/debian/dirs @@ -0,0 +1,7 @@ +usr/sbin +usr/bin +usr/man/man1 +usr/man/man5 +usr/man/man8 +etc/init.d +var/log --- lpr-5.9.orig/debian/init +++ lpr-5.9/debian/init @@ -0,0 +1,31 @@ +#!/bin/sh +# +# Start the printer daemon. + +DAEMON=/usr/sbin/lpd + +test -x $DAEMON || exit 0 + +case "$1" in + start) + echo -n "Starting printer spooler: lpd" + start-stop-daemon --start --quiet --exec $DAEMON + echo "." + ;; + stop) + echo -n "Stopping printer spooler: lpd" + start-stop-daemon --stop --quiet --pidfile /var/run/lpd.pid --exec $DAEMON + echo "." + ;; + restart|force-reload) + echo -n "Restarting printer spooler: lpd" + start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/lpd.pid --exec $DAEMON + start-stop-daemon --start --quiet --exec $DAEMON + echo "." + ;; + *) + echo "Usage: /etc/init.d/lpd {start|stop|restart}" + exit 1 +esac + +exit 0 --- lpr-5.9.orig/debian/control +++ lpr-5.9/debian/control @@ -0,0 +1,13 @@ +Source: lpr +Section: net +Priority: standard +Maintainer: Adam Klein +Standards-Version: 2.4.0.0 + +Package: lpr +Architecture: any +Depends: ${shlibs:Depends}, netbase +Suggests: magicfilter +Description: BSD lpr/lpd line printer spooling system + This is the BSD printer spooler and associated utilities. + You can use this for local and remote printers. --- lpr-5.9.orig/debian/postinst +++ lpr-5.9/debian/postinst @@ -0,0 +1,21 @@ +#!/bin/sh +# post install script for the Debian GNU/Linux lpr package + +for i in /var/log/lp-acct /var/log/lp-errs +do + if [ ! -f $i ]; then + touch $i + chmod 644 $i + fi +done + +# Fix directory permissions that might be incorrect. +for i in /var/spool/lpd /var/spool/lpd/lp /var/spool/lpd/remote +do + if [ -d $i ]; then + chmod 2775 $i + chown lp.lp $i + fi +done + +#DEBHELPER# --- lpr-5.9.orig/debian/postrm +++ lpr-5.9/debian/postrm @@ -0,0 +1,11 @@ +#!/bin/sh +# post remove script for the Debian GNU/Linux lpd package + +set -e + +if [ $1 = "purge" ] +then + rm -f /var/log/lp-acct /var/log/lp-errs +fi + +#DEBHELPER# --- lpr-5.9.orig/debian/preinst +++ lpr-5.9/debian/preinst @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +if [ -x /usr/sbin/lpd ]; then + start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/lpd.pid --exec /usr/sbin/lpd +fi + +#DEBHELPER# --- lpr-5.9.orig/debian/cron.weekly +++ lpr-5.9/debian/cron.weekly @@ -0,0 +1,5 @@ +#! /bin/sh + +savelog -t /var/log/lp-acct /var/log/lp-errs >/dev/null + +/etc/init.d/lpd restart >/dev/null --- lpr-5.9.orig/debian/prerm +++ lpr-5.9/debian/prerm @@ -0,0 +1,6 @@ +#!/bin/sh +# pre remove script for the Debian GNU/Linux lpd package + +set -e + +#DEBHELPER# --- lpr-5.9.orig/debian/rules +++ lpr-5.9/debian/rules @@ -0,0 +1,58 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. +# Modified for lpr by Adam Klein + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +build: build-stamp +build-stamp: + dh_testdir + $(MAKE) + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + -$(MAKE) clean + dh_clean + +# Build architecture-independent files here. +binary-indep: build +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build + dh_testversion 0.72 + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) DEBDIR=`pwd`/debian/tmp install + install -o root -g root -m 644 hosts.lpd debian/tmp/etc + install -o root -g root -m 755 rc.lpd debian/tmp/etc/init.d/lpd + dh_installdocs +# dh_installexamples +# dh_installmenu + dh_installinit --init-script=lpd + dh_installcron +# dh_installmanpages + dh_undocumented lpf.1 + dh_installchangelogs + dh_strip + dh_compress + dh_fixperms + dh_suidregister + dh_installdeb + dh_shlibdeps + dh_gencontrol +# dh_makeshlibs + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary --- lpr-5.9.orig/debian/TODO +++ lpr-5.9/debian/TODO @@ -0,0 +1,9 @@ +This is the To Do list for the Debian ``lpr'' package: + + - Add simple filter to distinguish between PostScript and text, + like pscat on (yuk!) SCO UNIX. + + - Fix Bug#1061 dealing with filters that differ from what they + _should_ be. This will take some work and some configuration + script writing. + --- lpr-5.9.orig/debian/copyright +++ lpr-5.9/debian/copyright @@ -0,0 +1,9 @@ +This is Debian/GNU Linux's prepackaged version of lpr, the BSD line +printing spool system. + +This package is maintained by Sven Rudolph . + +I don't know the location of the upstream sources :-( + +The lpr package is distributed under the BSD licence. On Debian +systems this licance is available in the file /usr/doc/copyright/BSD.