Next Previous Contents

4. Installing the programs

The basic components of the LPRng system are the executables and the database files. This section deals with generating and installing the executable files.

4.1 Files and Setup

The LPRng system can run in several different manners. However, for most users it will require the executables for the server lpd, and the client applications for job submission - lpr, job status - lpq, job removal - lprm, and server management - lprc, and the /etc/lpd.conf and /etc/printcap files.

By default, all the LPRng executables are installed in /usr/local/bin, which differs from other UNIX lpr systems, which scatter them in various hidden and arcane locations. Note that the original printing system executables will need to be renamed or removed after installing LPRng.

The /etc/lpd.conf file contains the configuration information for the server and application programs. The LPRng system has a compiled in set of defaults that should be suitable for most user applications. In fact, the default /etc/lpd.conf does not override any of the precompiled values.

The /etc/printcap file contains the printer database information. This information can override the defaults in /etc/lpd.conf

4.2 Source Code and Installation

If you have a binary distribution, you can skip this section. However, since LPRng is a rapidly evolving package, I would advise you to check whether there is a newer stable version available on one of the FTP sites. There should be a link to this stable version called LPRng-stable.tar.gz.

You should also look at the System specific notes to see if there are any special things that you need to do for your system.

Building the software

Before you start to build the software, you should read the README.1st and README.installation files in the distribution. If you have GNU Make, do:

./configure;
  #if you want internationalization,
  # ./configure --enable-nls
make clean all;
su   # you must do the following commands as root
make install
# if  you have not installed LPRng before,
# install default lpd.perms and lpd.conf file in /etc
if [ ! -f /etc/lpd.perms ]; then
    make default;
fi;
# update permissions,  create files needed for LPRng, check
# /etc/printcap file for problems.  Do as root:
./src/checkpc -f

If you have BSD make do:

./configure;
  #if you want internationalization,
  # ./configure --enable-nls
make -f Makefile.bsd clean all;
su   # you must do the following commands as root
make -f Makefile.bsd install
# if  you have not installed LPRng before,
# install default lpd.perms and lpd.conf file in /etc
if [ ! -f /etc/lpd.perms ]; then
    make -f Makefile.bsd default;
fi;
# update permissions,  create files needed for LPRng, check
# /etc/printcap file for problems.  Do as root:
./src/checkpc -f

Use the configure --bindir option to specify the location of the binaries, or edit src/Makefile or src/Makefile.bsd after running configure. The lines you have to change are:

INSTALL_BIN =     ${exec_prefix}/bin
# where daemons are installed: lpd
#INSTALL_LIB =     ${prefix}/lib
INSTALL_LIB =     ${prefix}/sbin
# where maintenance commands are installed: checkpc, setstatus
INSTALL_MAINT =   ${exec_prefix}/sbin

By default, all LPRng executables are placed in /usr/local/bin.

Problems with compilation

If you have problems compiling the package, you can try these things:

  1. Try gcc instead of your vendor's C compiler. This is the standard compiler used for LPRng. Almost without exception, if you have a ANSI C compatible compiler and libraries a POSIX compatible standard set of system support routines, LPRng will compile and run out of the box. The main problems are with missing or modified system support routines, but configure will usually detect this and set flags to use suitable alternatives.
  2. The configure and the make should be run on the target host, especially if the target host has a different version of the operating system. This is extremely important for SunOS or Solaris, where there tend to be changes in the system's include files between versions as well as support libraries.
  3. configure and the LPRng software tends to make the assumption that newer versions will not have the same problems that older versions have had.

If you are not familiar with GNU configure, read the file INSTALL for instructions.

Also read the notes for your OS in section System-dependent notes for specific installation help (if any).

4.3 Preparing to run the daemon

Don't be too impatient. Take your time to completely read through this HOWTO. Things will be a lot easier when you first set up the configuration files, and then start the new lpd.

During the course of these steps, you will have to change some files. Be sure to keep a copy of the original file(s)!

Removing Existing Facilities

Here is a summary and some scripts to help you prepare your site for running the server.

  1. Kill off the old server.
    BSD or Linux:
      ps -aux |grep lpd
      kill (pid of lpd server)
    System V:
      ps -ea |grep lpsched
      kill (pid of lpsched server)
    
  2. You should remove or rename the existing print system executables. Use the following script and examine the /tmp/candidates file for possible programs. Remove or rename the non-LPRng versions of the programs.
    # you might want to track down the old lpr, lpq, lprm binaries
    find /usr -type file -name lp\* \; -print >/tmp/candidates
    find /sbin -type file -name lp\* \; -print >>/tmp/candidates
    
    # example rename
    mv /usr/libexec/lpd /usr/libexec/lpd.orig
    # example link
    ln -s /usr/local/bin/lpd /usr/libexec/lpd
    
  3. Try starting and running lpd before permanently installing it. You should do the next steps as root.
    /usr/local/bin/lpd;                # start up LPD
    lpq;                               # test it with LPQ
    

Startup Scripts

Don't forget to modify your system print startup files, i.e. - the /etc/rc file in most BSD based UNIX systems, or those in /etc/init.d or /sbin/init.d on System V and Linux. You will need to have them reference the LPRng lpd and not the original system executable. For systems that use the System V run-level scripts, you will also likely need to install a symbolic link in the default system run-level directory (perhaps /etc/rc3.d or /sbin/rc3.d) pointing to the master copy of the startup script in the init.d directory.

Here is the core of a typical UNIX SystemV or LINUX startup file that can be used to start up and shut down the server. Note that you will most likely need to modify the echo lines.

#!/bin/sh
case "$1" in
  start) # Start daemons.
    echo "Starting lpd: \c"; /usr/local/bin/lpd; bin/echo;
    ;;
  stop) # Stop daemons.
    echo "Shutting down lpd: \c"
    server=`/usr/local/bin/lpc -Pany@localhost lpd \
    | awk '{for(i=1;i<=NF;++i){v=$i+0;if(v>1){ print v;exit;}}}'`
    if [ -n "$server" ]; then
      echo " server pid $server";
      kill $server;
    else
       echo " no server active";
    fi;
    ;;
    *)
       echo "Usage: lpd {start|stop}"
       exit 1
     ;;
esac

4.4 Replacing UNIX SystemV lp, lpstat Printing Services

Many UNIX utilities in the Solaris and HP UNIX environment use the UNIX System V lp and lpstat programs. It is almost impossible to modify their operation to use the LPRng lpr or lpq programs, as they depend on various return codes and information.

Here are Patrick Powell's comments on this:

After fighting with LP simulation, I finally decided to make the interface part of the LPR/LPQ package. If LPR is invoked as LP, then it will 'act' like a 'semi-compatible' LP; similarly for LPQ and LPSTAT, and LPRM and CANCEL.

To get this functionality, you need to either make a symbolic link or a hard link to the appropriate executable.

cd /usr/local/bin
ln -s lpr lp
ln -s lpq lpstat
ln -s lprm cancel
cd /usr/sbin
ln -s /usr/local/bin/lpr lp
ln -s /usr/local/bin/lpq lpstat
ln -s /usr/local/bin/lprm cancel

See the man pages for lp, lpstat, and cancel in the LPRng/man directory. Note that not all the functions of the original lp programs are supported. These man pages should be installed to replace the normal lp, etc, man pages.

For some purposes, the rather rugged lpstat simulation provided by this method does not work. Garrett D'Amore <garrett@qualcomm.com> has written some much improved versions; take a look at http://people.qualcomm.com/garrett/ for details.

4.5 Setuid ROOT and Security Issues

By default, LPRng executables are installed setuid ROOT. When running, they normally perform all operations with the user's effective UID, and perform all other operations set to the user and group specified by the user=daemon and group=daemon printcap entries, except for a very few places where they take extreme precautions against actions that could cause security breaches, change the EUID to ROOT, and then immediately change back to the normal operation.

As a scan of the various CERT Security Advisories will indicate, many programs that run SUID root can be serious security loopholes. While LPRng has been designed and implemented with security and paranoia in mind, there is still the possibility that user level or LPD processes can have an exposed security loophole.

To reduce the risk, the user level utilities such as lpr, lprm, lpq, and lpc can be installed non-setuid. This effectively closes several possible security loopholes. To install the executables as non-setuid, the distribution src/Makefile must have the following lines commented out, and then LPRng must be reinstalled:

edit src/Makefile
   # comment out the next line to have LPRng installed non-setuid
   PERMS=$(SUID_ROOT_PERMS)
make install

4.6 System specific notes

The following are a set of suggestions and recommendations for specific systems.

4.7 Solaris 2.4, 2.5, 2.6

The Sun Solaris operating system is derived from the System V UNIX baseline. Use the following installation procedure.

  1. First, install the LPRng software and then rename all of the existing Solaris print facilities. See the Installation section for details. You should especially look out for lp, lpstat, lpsched, lpadmin, and other executables used by Solaris for print support.
  2. Next, make sure you update the /etc/rc startup files. During the startup or initialization, Solaris will invoke a set of individual startup files. You will find that the startupfile files are usually links to a common one in the /etc/init.d directory.
    ># grep -l lpsched /etc/rc* /etc/rc*/* init.d/* init.d/*/*
    /etc/rc0.d/K20lp
    /etc/rc2.d/K20lp
    /etc/rc2.d/S80lp
    /etc/init.d/lp
    ># ls -l /etc/rc0.d/K20lp
    lrwxrwxr-x  1 root  bin  1 Dec 29 23:39 /etc/rc0.d/K20lp -> ../../init.d/lp
    
  3. Replace the existing lp startup file with one similar to the startup script in the previous section.
  4. Check the /etc/inetd.conf file for a line like:
    printer stream tcp nowait root /usr/lib/print/in.lpd in.lpd
    

    and remove it if it is present.

  5. Reboot. Don't try to be fancy and kill off processes, use the nlsadmin command, or other insanity. This is brutal, but appears to be necessary in order to ensure that the networking support is set up correctly.
  6. When the system restarts, try using lpq to check to see if the lpd server is active.

James P. Dugal <jpd@usl.ed> has also makde the following suggestions as well.

From: "Dugal James P." <jpd@usl.edu>
To: lprng@iona.com
Subject: Re: [LPRng] start up trouble

Here are some more tips for Solaris:

1. If /var/spool/cron/crontabs/lp exists, remove it.

In fact, we actually test if /etc/init.d/lp exists on any newly-installed
system, and if so, we issue these commands:
        /etc/init.d/lp stop
        /usr/sbin/pkgrm -n SUNWpsu
        /usr/sbin/pkgrm -n SUNWscplp
        /usr/sbin/pkgrm -n SUNWpcu
        /usr/sbin/pkgrm -n SUNWpsr
        /usr/sbin/pkgrm -n SUNWpcr
        /bin/rm -f /var/spool/cron/crontabs/lp

Regards,
-- James Dugal, N5KNX           Internet: jpd@usl.edu
Associate Director              Ham packet: n5knx@k5arh.#lft.la.usa.noam
Computing Support Services      US Mail: PO Box 42770  Lafayette, LA  70504
University of Southwestern LA.  Tel. 318-482-6417       U.S.A.

4.8 Solaris, Newsprint and FrameMaker

The following is a guide to using LPRng and Sun Microsystems Newsprint by Christopher Hylands, Ptolemy Project Manager of the University of California.

The Sun Newsprint printer is actually an OEM version of the Textronix PhaserII; Sun Microsystems appears to have dropped support for Newsprint, and the recommended migration path is to buy a PostScript printer. If you want more information on using the Newsprint system, notes are available via http://ptolemy.eecs.berkeley.edu/~cxh/lprng.html.

Looking through the mailing list logs, it looks like everyone was having a hard time getting lprng to work with Sun's braindead newsprinters. I tried using ghostscript, but the fonts were, IMHO, ugly, so I spent a little time getting the newsprint fonts to work.

The key thing was to grab the file /usr/newsprint/lpd/if from a SunOS4.1.3 newsprint installation. If you cannot get this code, then the installation will be extremely difficult.

To install lprng on a Solaris2.x machine, you need to first stop the existing print services and install the startup scripts for LPRng. Note that if there is a local printer, you may have to also fix the permissions of the device. Typical commands are:

chown daemon /devices/sbus@1,f8000000/SUNW,lpvi@1,300000:lpvi0

We use the following simple if script.

#/bin/sh
# extremely simple filter script
/bin/cat

The Sparcprinters use licensed fonts from NeWSprint. To use the licensed fonts, you must have the lprng spool directory for the sparcprinter in the same location as spool directory of the brain dead Solaris lp system. If your printer is named xsp524, then this directory would be /etc/lp/printers/xsp524.

The printcap entry looks like:

sp524|524:
    :mx#0:sf:sh:sb:
    :lp=:rm=doppler:rp=xsp524:mx#0:
    :sd=/var/spool/lpd/sp524d:
    :lf=/var/spool/lpd/sp524d/log:
xsp524|Sun SPARCprinter NeWSprint printer:
    :mx#0:sf:sb:sh:rs:
    :lp=/dev/lpvi0:
    :sd=/etc/lp/printers/xsp524:
    :lf=/etc/lp/printers/xsp524/log:
    :af=/var/spool/lpd/xsp524/acct:
    :if=/usr/local/lib/newsprint/if:

The /usr/local/lib/newsprint/if was copied from /usr/newsprint/lpd/if in a SunOS4.x installation of the newsprint software. Unfortunately, the newsprint engine is so brain dead that it needs many environment variables set, so it is fairly difficult to come up with a clean script to start the engine. I made the following changes to the file.

  1. First, set the path in the script. You may also need to change defaults to suit your preferences:
    PATH=/usr/ucb:/usr/bin:/etc:/usr/etc:/opt/NeWSprint/bin:/opt/NeWSprint/np/bin:
    PATH=$PATH:$NPHOME/pl.$ARCH/bin:$NPHOME/np/bin; export PATH
    
  2. You will also need a /etc/lp/printers/printername/.params file. If you are using the same spooler directory as the directory that the Solaris lp system uses, then the .param file should appear there. If you are using a different spooler directory, then you will need to copy the .param file from elsewhere and edit it accordingly.
  3. If you are going to move a license to a new printer, you should probably save the .param file in the old printer spooler directory. Run /opt/NeWSprint/bin/fp_install and remove the license from the old printer and assign it to the new printer. You could run /opt/NeWSprint/bin/rm_np_printer and remove the printer, but that will get rid of the .param file
  4. FrameMaker under Solaris2.x uses the lp command. The fix is to edit $FMHOME/fminit/FMlpr and comment out the lp line and add an lpr line
    sunxm.s5.sparc)
        lpr -P"$PRINTER" "$FILE"
        #lp -c -d"$PRINTER" "$FILE"
    
Christopher Hylands, Ptolemy Project Manager  University of California
cxh@eecs.berkeley.edu                 US Mail: 558 Cory Hall #1770
ph: (510)643-9841 fax:(510)642-2739       Berkeley, CA 94720-1770
home: (510)526-4010 (if busy -4068)       (Office: 493 Cory)

4.9 Linux

At the time of this writing (Jan 1998), the three major Linux distributions (Slackware, Red Hat and Debian) carry an older version of LPRng. Users of those systems should download the latest stable release, and install that instead of the distributed binaries.

This is mostly important for Slackware 3.2 users, as this version installs LPRng by default. Patrick Volkerding changed the default back to BSD LPR in Slackware 3.3, as many users had experienced problems because they didn't realize they weren't using the BSD software.

Debian's dselect utility lets you choose between all packages. Amongst these are LPRng, as well as the traditional LPR software.

You have to make sure your kernel is configured correctly. The documentation for the kernel sources in /usr/src/linux/Documentation/ and the Kernel-HOWTO will help you to generate a new kernel if needed. You will need to set the following options:

Once you have done this, the current releases of LPRng will install and run without problems. See the Installing the programs section for details on how to install LPRng and deactivate the existing print support.

You may need to update the printcap file and filters. See /etc/printcap Print Spool Database File for details.

4.10 AIX

This information was supplied by Dirk Nitschke, as of August 1997, and describes how to install the LPRng package on a workstation running AIX 4.1.x and possibly 3.x.x as well. Dirk would be interested in any comments or corrections.

Printing on AIX systems is different. AIX provides a general queueing facility and printing is only one way to use it. You submit a print job to a print queue using one of the commands qprt, enq. You can use the BSD or System V printing commands lpr or lp, too. The qdaemon watches all (general) queues and knows how to handle your job. A (general) queue is defined in the file /etc/qconfig. The format of this file is different from the printcap format.

OK, how to replace the AIX printing system? There is no group daemon on AIX. Therefore you have to change the default group for file ownership and process permissions. We decided to use the printq group. The user daemon exists on AIX but we have chosen lpd as the user who runs lpd and all filters and owns the spooling directories. You can change the values for group, server_user and user in your lpd.conf file or in the sources src/common/default.c. This is an example for lpd.conf:

# lpd.conf for AIX (change group, server_user and user)
group=printq
server_user=lpd
user=lpd
Compile and install the LPRng package. Create your printcap, spooling directories, accounting and logfiles and so on. Don't forget to use checkpc to make sure that all the permissions are set correctly and the necessary files are created.

Then stop all print queues defined on your workstation. Use

# chque -q queuename -a "up = FALSE"
for this (yes, blanks around = are needed).

If you have local printers attached to your system you will have an lpd running. Stop this daemon using SMIT (Print Spooling, Manage Print Server, Stop the Print Server Subsystem). Choosing both also removes lpd from /etc/inittab. Maybe it's faster to do this by hand:

# stopsrc -p'pid of /usr/sbin/lpd'
# rmitab "lpd"

Now delete all print queues (managed by qdaemon) defined on your system. You can use SMIT for this or the commands {mk,ch,rm}que, {mk,ch,rm}quedev, {mk,ch,rm}virprt. The SMIT fast path is smit rmpq.

To start the new lpd at system startup you have to add an entry to /etc/inittab:

# mkitab "lpd:2:once:/full/path/lpd"

Some work has to be done if have have a local printer attached to your workstation. You have to create a device file like /dev/lp0. The SMIT fast path for this is smit mkdev. Choose Printer/Plotter and then Printer/Plotter Devices. Now Add a Printer/Plotter. To create a parallel printer device select the following:

Plotter type:              opp Other parallel printer
Printer/Plotter Interface: parallel
Parent Adapter:            ppa0 Available
Now define the characteristictics of the device:
Port Number: p
(p is for parallel). Go to the field
Send all characters to printer UNMODIFIED   no
and select yes! We have had a lot of trouble with no. This is very important! Expect erroneous output if you choose no. If you have already created a device file, change the characteristictics! SMIT's fast path is smit chdev.

Finally remove all AIX printing commands like qprt, lp, cancel, lpr, lprm. You will find a lot of them in /usr/bin. Do not remove enq and friends if you want to use the general queueing facility.

Now you can start your new lpd.

4.11 Appletalk Support

Netatalk is used to communicate from TCP/IP to Appletalk printers and vice versa. The netalk distribution FAQ is at:

http://www.umich.edu/~rsug/netatalk

There are two issues with using netatalk. The first issue has to do with printing to LPRng-served printers from Macs. The second issue has to do with printing from LPRng to network printers that speak AppleTalk.

4.12 Apple to LPRng Printing

After you have installed and gotten netatalk working, you can use the following configuration file to print from a Macintosh to an LPRng printer.

From edan@mtu.edu Mon Sep 29 21:31:25 1997
Date: Tue, 30 Sep 1997 00:04:58 -0400 (EDT)
From: Edan Idzerda <edan@mtu.edu>
To: lprng@iona.com
Subject: Re: [LPRng] Netatalk configuration file
> Somebody posted a very nice Netatalk papd.conf file
> that showed the setup for LPRng.  If anybody has this
> handy could you post it?
Well, *I* use:
Your 32 Character Printer Name:\
        :pr=|/your/path/to/lpr -Pprintername
        :ppd=/your/path/to/ppd/files/yourprinter.ppd
--
Edan Idzerda    <edan@mtu.edu>
System Administrator -- Michigan Technological University, Houghton MI USA

4.13 LPRng to Appletalk Printing

The netatalk package comes with a PostScript filter called psf. After compilation, it is in (e.g.) netatalk-1.4b2/etc/psf and will be installed in (e.g.) /usr/local/atalk/etc/. After installation, there will also be a directory /usr/local/atalk/etc/filters that contains ifpap, ofpap, et al. These are just symlinks to psf, and psf will do the appropriate thing based on how it was invoked. If there's a 'pap' in the name, psf uses AppleTalk to talk to the printer. See psf(8) for more information.

A printcap entry for a network printer looks like the following:

dave|Dave's 32 Character Printer Name:\
    :sd=/var/spool/dave:\
    :lf=/var/adm/lpd-errs:\
    :lo=lock:\
    :if=/usr/local/atalk/etc/filters/ifpap:\
    :of=/usr/local/atalk/etc/filters/ofpap:\
    :lp=/var/spool/dave/null

There are three caveats to using netatalk this way.

  1. The first is that psf (i.e., the filters) needs to run as root. You can accomplish this in one of two ways. The first is to uncomment the following line in src/Makefile and recompile:
    # ROOT_CFLAG=-DROOT_PERMS_TO_FILTER_SECURITY_LOOPHOLE
    

    The filter lines then need to look like the following:

        :if=ROOT /usr/local/atalk/etc/filters/ifpap:\
        :of=ROOT /usr/local/atalk/etc/filters/ofpap:\
    

    The alternative is to make psf setuid root. To minimize the risk, you may want to make psf executable only by group daemon. (I haven't tested the first option. I'm currently using the second option.)

  2. The second caveat is that each network printer needs a .paprc in its spool directory. For instance, /var/spool/dave/.paprc looks like this:
    Dave's 32 Character Printer Name:LaserWriter@Your AppleTalk Zone
    

    See psf(8) and pap(1) for more information.

  3. The third caveat concerns the lp line in the printcap entry. For a single printer, this can be /dev/null. If the host spools to more than one AppleTalk printer, you shouldn't use /dev/null for lp. You should use mknod to create a null device for each printer. See psf(8).
Chad Mynhier <mynhier@cs.utk.edu>
Lab Engineer, CS Department        
University of Tennessee, Knoxville                   

4.14 SAMBA Support

From the http://samba.canberra.edu.au/pub/samba/ Web Site.

What is SMB

This is a big question.

The very short answer is that it is the protocol by which a lot of PC-related machines share files and printers and other information such as lists of available files and printers. Operating systems that support this natively include Windows NT, OS/2, and Linux and add on packages that achieve the same thing are available for DOS, Windows, VMS, Unix of all kinds, MVS, and more. There is no reason why Apple Macs and indeed any Web browser should not be able to speak this protocol, and current development (in which the Samba team is heavily involved) is aimed at exactly that. Alternatives to SMB include Netware, NFS, Appletalk, Banyan Vines, Decnet etc; many of these have advantages but none are both public specifications and widely implemented in desktop machines by default.

The Common Internet Filesystem is what the new SMB initiative is called. For details watch http://samba.anu.edu.au/cifs.

WHAT CAN SAMBA DO?

Here is a very short list of what samba includes, and what it does.

For a much better overview have a look at the web site at http://samba.canberra.edu.au/pub/samba and browse the user survey.

Related packages include:

FTP SITE

The main anonymous ftp distribution site for this software is samba.anu.edu.au in the directory pub/samba/. WEB SITE

A Samba WWW site has been setup with lots of useful info. Connect to:

http://samba.canberra.edu.au/pub/samba/

As well as general information and documentation, this also has searchable archives of the mailing list and a user survey that shows who else is using this package. Have you registered with the survey yet? :-)

It is maintained by Paul Blackman (thanks Paul!). You can contact him at ictinus@lake.canberra.edu.au.

Samba and LPRng

The SAMBA code is very easy to configure. See the SAMBA documentation for details, but you only need to modify the samba.conf file and put in the pathnames of the LPRng facilities. The following is a sample.

From: Sascha Ottolski <alzhimer@cs.tu-berlin.de>
To: lprng@iona.com
Subject: Re: [LPRng] lprng-3.2.6 and smb on Linux
webnut@conc.tds.net said:

 I have samba sending print from Win95 machines to LPRng.  The key to
 making it work is in the samba.conf file in the [global] section:

[global]
    printing = lprng
    print command = /usr/local/bin/lpr  -P%p %s -r
    lpq command   = /usr/local/bin/lpq  -P%p
    lprm command  = /usr/local/bin/lprm -P%p %j
    printcap name = /etc/printcap
    load printers = no 
[printers]
   comment = All Printers
   path = /tmp
   browseable = no
   printable = yes
   guest ok = no
   writable = no
   create mode = 0700

Note: the path= value specifies the spool directory where
the print files are temporarily stored.  This should NOT
be the LPRng spool directory,  but some other directory that
Samba has write permissions for.
Reply-To: "Pascal A. Dupuis" <dupuis@lei.ucl.ac.be>
To: papowell@astart2.astart.com
Subject: Re: LPRng-3.2.10

I include the smbprint script used to send stdin to a NetBEUI printer.

#!/bin/sh -x
# This script is an input filter for printcap printing on a unix machine. It
# uses the smbclient program to print the file to the specified smb-based 
# server and service.
# For example you could have a printcap entry like this
#
# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
#
# which would create a unix printer called "smb" that will print via this 
# script. You will need to create the spool directory /usr/spool/smb with
# appropriate permissions and ownerships for your system.
#
# The /usr/spool/smb/.config file should contain:
#   server=PC_SERVER
#   service=PR_SHARENAME
#   password="password"
#
# Set these to the server and service you wish to print to 
# In this example I have a WfWg PC called "lapland" that has a printer 
# exported called "printer" with no password.
#
# E.g.
#   server=PAULS_PC
#   service=CJET_371
#   password=""
# Should read the following variables set in the config file:
#   server, service, password
config_file=.config
eval `cat $config_file`
# echo "server $server, service $service" 2>&1
(
# NOTE You may wish to add the line `echo translate' if you want automatic
# CR/LF translation when printing.
#       echo translate
    echo "print -"
    cat
) | /usr/local/bin/smbclient "\\\\$server\\$service" \
   $password -U $server -N -P
# comment preceeding line and uncomment following 
# to just test for correct filter working
#) | cat > /dev/null

4.15 Printer Specific notes

This is a small collection of miscellaneous notes about printers and applications.

4.16 HP Deskjet

From: jarausch@igpm.rwth-aachen.de (Helmut Jarausch)
Subject: Re: Using gs (ghostscript) as a filter? 
To: lprng@iona.com
Cc: Rick Gaine <rgaine@nbcs.rutgers.edu>
Sender: majordomo-owner@iona.com
Reply-To: lprng@iona.com
>> 
>> Hello All:
>> 
>> I would like to use LPRng 3.1.4 with an HP LaserJet 4P.  I'd like to be
>> able to use gs to convert PostScript files so that I can print them on my
>> HP 4P.  Can I do this with LPRng?  If so, could someone semd me a printcap
>> entry?  I'd appreciate it.  I am not sure how I will be cconnecting the
>> printer yet, but I am thinking either serial or network.  Probably serial
>> though.  Thanks for any help.

This printcap works for my Deskjet:

djps
        :cm=Local Deskjet(GhostScript)
        :sd=/var/spool/djps:sf:sh:mx#0
        :lp=/dev/plp
        :if=/usr/LOCAL/bin/LPRng/ps_to_deskjet:

and this is the script /usr/LOCAL/bin/LPRng/ps_to_deskjet

#!/bin/sh
nice -19 /usr/LOCAL/bin/gs -sDEVICE=cdj550 -sPAPERSIZE=a4 -sOutputFile=- -q -r300 - 
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology
RWTH Aachen
D 52056 Aachen, Germany

4.17 HP LaserJet IIISiMX

> From majordomo-owner@iona.com Mon Aug 31 11:17:26 1998
> To: lprng@iona.ie
> Subject: [LPRng] problems printing PS-level2 jobs on LJIIIsi's...
> Date: Mon, 31 Aug 1998 15:06:22 -0400
> From: "John Saroglou" <johny@yorku.ca>
>
> Greetings...
>
> I'm wondering if someone got around the problem of printing
> Postscript(R) Level 2  jobs on Laser Jet IIIsi printers.
> Our printers are direct network printers talking to a
> print server running solaris 2.6 and lprng-3.5.1.
>
> Is there a fix (possible drivers?) for such problem?
>
> Thanks in advance.

The LaserJet IIISi does not support PostScript level 2, only level 1 (really, it is called 3SiMX). The Windows (you are under Windows, right?) HP driver for 3Si/3Si MX PostScript should produce only PS level 1.

Beware: latest version of Adobe Windows PS driver produces *ONLY* PS level 2.

So, if you have (or receive) level 2 files, read them using ghostscript and print a screen dump :-) or as a bitmap.

You can too convert them into PDF (using either Adobe distiller or ghostscript ps2pdf) then use acroread to print the result. acroread can produce either level 1 or level 2 PostScript. THE definite solution !

This trouble has nothing to do with the way they are connected or driven, it is only a driver problem.

I believe that HP had once a PS level2 update, but the price was so high that bying a new printer was a better solution!

Bertrand
-- 
| Bertrand DECOUTY              | mailto:Bertrand.Decouty@irisa.fr   |
| IRISA - INRIA (Atelier)       | PHONE : 0299847346 / 0299847100    |
| Campus de Beaulieu            | FAX   : +33 (0) 299842534          |
| F-35042 Rennes Cedex - FRANCE | http://www.irisa.fr/               |

4.18 HP Deskjet 1600CM

The following printcap entry was posted by Olaf Lotzkat (Sysadm), Faculty of Computer Science, TU Dresden, Germany >Olaf_Lotzkat@inf.tu-dresden.de<.

# HP DeskJet 1600CM
tinte|:
    :lp=dj1600cm%9100:
    :mx#0:rw:sf:
    :ps=status:af=acct:lf=log:sd=/lpspool/tinte:fx=flpv:
    :if=/usr/local/lib/filters/ifhp \
     -Tpagecount=off,forcepagecount=on,infostatus=off,sync=off:
    :of=/usr/local/lib/filters/ofhp \
     -Tpagecount=off,forcepagecount=on,infostatus=off,sync=off,banner=off:
    :vf=/usr/local/lib/filters/ifhp -c:
    :bp=/usr/local/lib/filters/psbanner:

4.19 HP JetDirect Interface

The HPJetDirect card can be configured through the front panel or through a set of network files. Here is a summary of the methods used from UNIX systems, or when you are desperate, to configure the printer.

Setting Up IP Networking and Address

You can set the network address from the front panel. Reset the printer, put it in offline mode. and then use the MENU, +-, SELECT keys as follows:

 MENU  -> MIO MENU (use MENU to display MIO MENU)
 ITEM  -> CFG NETWORK=NO*
 +     -> CFG NETWORK=YES
 ENTER -> CFG NETWORK=YES*
 ITEM  -> TCP/IP=OFF* (use ITEM to display TCP/IP)
 +     -> TCP/IP=ON
 ENTER -> TCP/IP=ON*
 ITEM  -> CFG TCP/IP=NO* (use ITEM to display TCP/IP)
 +     -> CFG TCP/IP=YES
 ENTER -> CFG TCP/IP=YES*
 ITEM  -> BOOTP=NO*
         (Enable BOOTP if you want to - see below)
 ITEM  -> IP BYTE 1=0*
         This is IP address MSB byte.
         Use +- keys to change value, and then ENTER to change
         Use ITEM keys to get IP BYTE=2,3,4
 ITEM  -> SM BYTE 1=255*
          This is the subnet mask value
         Use +- keys to change value, and then ENTER to change
         Use ITEM keys to get IP BYTE=2,3,4
 ITEM  -> LG BYTE 1=255*
         This is the Syslog server (LoGger) IP address
         Use +- keys to change value, and then ENTER to change
         Use ITEM keys to get IP BYTE=2,3,4
 ITEM  -> GW BYTE 1=255*
         This is the subnet gateway (router) IP address
         Use +- keys to change value, and then ENTER to change
         Use ITEM keys to get IP BYTE=2,3,4
 ITEM  -> TIMEOUT=90
          This is the connection timeout value.  It puts a limit
         on time between connections.  A value of 10 is reasonable.

BOOTP Information

If you have a bootp server, you can put this information in the bootptab file. To use this, you must enable the bootp option on the printer. The T144 option specifies a file to be read from the bootp server. This file is read by using the TFTP protocol, and you must have a TFTPD server enabled. Here is a sample bootptab entry.

# Example /etc/bootptab: database for bootp server (/etc/bootpd).
# Blank lines and lines beginning with '#' are ignored.
#
# Legend:
#
#       first field -- hostname
#                       (may be full domain name)
#
#       hd -- home directory
#       bf -- bootfile
#       cs -- cookie servers
#       ds -- domain name servers
#       gw -- gateways
#       ha -- hardware address
#       ht -- hardware type
#       im -- impress servers
#       ip -- host IP address
#       lg -- log servers
#       lp -- LPR servers
#       ns -- IEN-116 name servers
#       rl -- resource location protocol servers
#       sm -- subnet mask
#       tc -- template host (points to similar host entry)
#       to -- time offset (seconds)
#       ts -- time servers
#
# Be careful about including backslashes where they're needed.  Weird (bad)
# things can happen when a backslash is omitted where one is intended.
#
peripheral1:
:hn:ht=ether:vm=rfc1048:
:ha=08000903212F:
:ip=190.40.101.22:
:sm=255.255.255.0:
:gw=190.40.101.1:
:lg=190.40.101.3:
:T144="hpnp/peripheral1.cfg":

If you are using the T144 option, you will need to create the configuration file. The sample configuration file from the HP Direct distribution is included below.

#
# Example HP Network Peripheral Interface configuration file
#
# Comments begin with '#' and end at the end of the line.
# Blank lines are ignored.  Entries cannot span lines.

# Name is the peripheral (or node) name.  It is displayed on the peripheral's
# self-test page or configuration plot, and when sysName is obtained through
# SNMP.  This name can be provided in the BOOTP response or can be specified
# in the NPI configuration file to prevent the BOOTP response from overflowing
# the packet.  The domain portion of the name is not necessary because the
# peripheral does not perform Domain Name System (DNS) searches.  Name is
# limited to 64 characters.

name: picasso

# Location describes the physical location of the peripheral.  This is the
# value used by the interface for the MIB-II sysLocation object.  The default
# location is undefined.  Only printable ASCII characters are allowed.
# Maximum length is 64 characters.

location: 1st floor, south wall

# Contact is the name of the person who administers or services the peripheral
# and may include how to contact this person.  It is limited to 64 characters.
# This is the value used by the interface for the MIB-II sysContact object.
# The default contact is undefined.  Only printable ASCII characters are
# allowed.  Maximum length is 64 characters.

contact: Phil, ext 1234

# The host access list contains the list of hosts or networks of hosts
# that are allowed to connect to the peripheral.  The format is
# "allow: netnum [mask]", where netnum is a network number or a host IP
# address.  Mask is an address mask of bits to apply to the network number
# and connecting host's IP address to verify access to the peripheral.
# The mask usually matches the network or subnet mask, but this is not
# required.  If netnum is a host IP address, the mask 255.255.255.255 can
# be omitted.  Up to ten access list entries are permitted.

# to allow all of network 10 to access the peripheral:
allow: 10.0.0.0  255.0.0.0

# to allow a single host without specifying the mask:
allow: 15.1.2.3

# Idle timeout is the time (in seconds) after which an idle
# print data connection is closed.  A value of zero disables
# the timeout mechanism.  The default timeout is 90 seconds.

idle-timeout: 120

# A community name is a password that allows SNMP access to MIB values on
# the network peripheral.  Community names are not highly secure; they are
# not encrypted across the network.  The get community name determines which
# SNMP GetRequests are responded to.  By default, the network peripheral
# responds to all GetRequests.  The get community name is limited to 32
# characters.
#
# For hpnpstat and hpnpadmin, the community name can be stored in
# /usr/lib/hpnp/hpnpsnmp.

get-community-name: blue

# The set community name is similar to the get community name.  The set
# community name determines which SNMP SetRequests are responded to.  In
# addition, SetRequests are only honored if the sending host is on the
# host access list.  By default, the network peripheral does not respond
# to any SetRequests.  The set community name is limited to 32 characters.
#
# The set community name can come from /usr/lib/hpnp/hpnpsnmp
# if it is the same as the get community name.  We recommend that the
# set community name be different from the get community name though.

set-community-name: yellow

# SNMP traps are asynchronous notifications of some event that has occurred.
# SNMP traps are useful only with network management software.  Traps are
# sent to specific hosts and include a trap community name.  Up to four
# hosts can be sent SNMP traps.   The trap community name is limited to
# 32 characters.  The default name is public.

trap-community-name: red

# The SNMP trap destination list specifies systems to which SNMP
# traps are sent.  Up to four IP addresses are allowed.  If no
# trap destinations are listed, traps are not sent.

trap-dest: 15.1.2.3
trap-dest: 15.2.3.4

# The SNMP authentication trap parameter enables or disables the sending
# of SNMP authentication traps.  Authentication traps indicate that an SNMP
# request was received and the community name check failed.  By default,
# the parameter is off.

authentication-trap: on

# The syslog-facility parameter sets the source facility identifier that the
# card uses when issuing syslog messages.  Other facilities, for example,
# include the kernel (LOG_KERN), the mail system (LOG_MAIL), and the spooling
# system (LOG_LPR).  The card only allows its syslog facility to be configured
# to one of the local user values (LOG_LOCAL0 through LOG_LOCAL7).  The
# selectable option strings, local0 through local7 (configured to LOG_LOCAL0
# through LOG_LOCAL7, respectively) are case insensitive.  The default
# syslog-facility for the card is LOG_LPR.

syslog-facility: local2

# This parameter allows the card to treat hosts on other subnets as if the
# hosts were on the card's subnet.  This parameter determines the TCP
# Maximum Segment Size (MSS) advertised by the card to hosts on other subnets
# and affects the card's initial receive-window size.  The card will use a
# TCP MSS of 1460 bytes for local hosts, and 536 bytes for a non-local host.
# The default is off, that is, the card will use the maximum packet sizes
# only on the card's configured subnet.
#
# The configuration utility does not allow access to this parameter.  If you
# want to configure it, you must manually edit the NPI configuration file
# and add it to the bottom of the entry for the network peripheral.

subnets-local: on

# This parameter affects how the card handles TCP connection requests from
# the host.  By default, the JetDirect MPS card will accept a TCP connection
# even if the peripheral is off-line.  If this parameter is set to "on", then
# the card will only accept a TCP connection when the peripheral is on-line.

old-idle-mode: off

Paper Tray Selection

Be careful with your paper tray selection. You should configure the printer, using the front panel switches, to select the FIRST paper tray. See your printer documentation on this. Unfortunately, different models of HP printers have different methods of handling paper trays.

4.20 Lexmark Printers

Some Lexmark printers do not send end of job status back unless configured to do so. Here is what is needed to force this.

Date: Wed, 21 Jan 1998 18:25:50 -0600 (CST)
From: Matt White <whitem@bofh.usask.ca>
To: lprng@iona.com
Subject: Re: [LPRng] CTI-ifhp with Lexmark Optra N printer

On Wed, 21 Jan 1998, Simon Greaves wrote:

> Apologies in advance if this is way off mark, but we've been evaluating a
> commercial print charging package (Geomica) which works by talking to the
> printer in what I think is a similar way to the ifhp filters. Lexmarks are
> currently a big headache because they seem to fail to return the message
> that they have finished printing which screws things up somewhat. In our
> case, it is believed to be a problem with the Lexmark firmware which they
> are looking into. 

There is a fix for that...it is originally from the Lexmark 4039 series,
but it still works on the Optra S 1650 machines that we have (and should
work on the rest of the optra line).  Just send this little chunk of
postscript to the printer once:

-----------snip----------
%! Postscript utility file to set the 4039 printer into synchronous mode
serverdict begin 0 exitserver
statusdict begin true setenginesync end
-----------snip----------

Basically, it causes the printer to wait until it is finished printing
before actually reporting that it is done.  I've got 3 Optra S printers
running with ifhp right now with no extra options (just defaults).
 
---------------------------------------------------------------------
- Matt White                         whitem@arts.usask.ca           -
- Network Technical Support          http://arts.usask.ca/~whitem   -
- College of Arts & Science          University of Saskatchewan     -
---------------------------------------------------------------------

4.21 Tektronix P450 and Family

The Tektronix P450 has a very odd network interface. You can open a TCP (stream) connection to port 9100 and send a file to be printed on the connection.

When a UDP datagram is sent to UDP Port 9101, the printer resonds with status information. This apparently is the poor man's SNMP, but I digress. Here is a clever implementation of a filter that handles this printer.

From: Russ Thacher <thacher@brl.uiuc.edu>
To: lprng@iona.com
Subject: Re: [LPRng] Tektronix P450 & psfilter

Having only limited success with the psfilter UDP status port option, and
not satisfied with the overall slowness of sending print jobs out via
AppleShare with CAP, I (we) decided to roll our own filter for the Phaser
450 that speaks AppSocket (sending on TCP 9100, monitoring UDP 9101),
grabs reliable page counts and can tell the Phaser to switch to
transparency mode based upon LPRng queue alias ('qq' printcap option).

Here's out printcap entry for the Phaser 450, using our filter:

# Tektronix Phaser 450-2
phaser450-2|phaser450-2t|phaser440|phaser440t
   :lp=/dev/null:qq
   :af=acct:lf=log:fx=flpv:sh:mx#0:ps=status
   :if=/usr/local/lib/filters/phaserif
   :sd=/var/spool/lpd/phaser450-2

Attached is the Perl filter I wrote that has been very slightly modified
since its inception by Al Marquardt.  It's written with Solaris in mind
and is perhaps a little crude, but it works quite well for us.  Feel free
to modify/use it in any way you like- direct any and all comments to Al
Marquardt (almar@uiuc.edu).

--
Russ Thacher
Systems Administrator, UIUC Bioacoustics Research Lab

-------------- Filter -----------------
#!/usr/local/bin/perl5

use Getopt::Std;
use Socket;
use Sys::Hostname;

pop @ARGV;

# Get all the filter options LPRng knows

getopts('a:b:cd:e:f:h:i:j:k:l:m:n:p:r:s:t:w:x:y:F:P:S:C:H:A:J:L:Q:');

# set default exit status (JFAIL)

$! = 1;

# Set default error messages

$udpsockerr = "ERROR: Cannot establish UDP socket: $!\n";
$udpbinderr = "ERROR: Cannot bind to UDP socket: $!\n";
$udpsenderr = "ERROR: Cannot send UDP status request: !$\n";
$udprecverr = "ERROR: Cannot receive UDP status report: !$\n";
$tcpsockerr = "ERROR: Cannot establish TCP socket: $!\n";
$tcpconnecterr = "ERROR: Cannot connect to TCP socket: $!\n";
$tcpcloseerr = "ERROR: Cannot close TCP socket: $!\n";

# Get current time/date

@MONTHS = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun",
           "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$month = $MONTHS[$mon];
if (length($sec)  == 1)  { $sec = "0$sec" }
if (length($min)  == 1)  { $min = "0$min" }
if (length($hour) == 1)  { $hour= "0$hour" }
if (length($mday) == 1)  { $mday= " $mday" }

$datestamp = "$month $mday $hour:$min:$sec";

# Write a 'job begin' line to printer log file

print STDERR "START: job number $opt_j (dfile: $opt_e) for $opt_n\@$opt_h on $opt_P at $datestamp\n";

# Setup network info for printers

$phaser4501 = 'phaser450-1';
$phaser4502 = 'phaser440';

$udpport = '9101';
$tcpport = '9100';

# Setting up UDP socket info so we can get status reports from phasers...

$myip = gethostbyname(hostname());

$udpproto = getprotobyname('udp');
$myudppaddr = sockaddr_in(0, $myip);

if ($opt_P eq 'phaser450-1') {
  $printip = inet_aton($phaser4501);
}
elsif ($opt_P eq 'phaser450-2') {
  $printip = inet_aton($phaser4502);
}

$printudppaddr = sockaddr_in($udpport, $printip);     

socket(UDPSOCK, PF_INET, SOCK_DGRAM, $udpproto) or die $udpsockerr;
bind(UDPSOCK, $myudppaddr) or die $udpbinderr;

# Setting up TCP socket info so we can send jobs to the printer
# and read pagecounts

$tcpproto = getprotobyname('tcp');
$mytcppaddr = sockaddr_in(0, $myip);
$printtcppaddr = sockaddr_in($tcpport, $printip);
socket(TCPSOCK, PF_INET, SOCK_STREAM, $tcpproto) or die $tcpsockerr;
setsockopt(TCPSOCK, SOL_SOCKET, SO_KEEPALIVE, 0);
setsockopt(TCPSOCK, SOL_SOCKET, SO_LINGER, 0);     

# Before any printing check to be sure printer is idle
# If it's not, check every 5 seconds until it is 

defined(send(UDPSOCK, "\r\n", 0, $printudppaddr)) or die $udpsenderr;
$udpout = "";
($printudppaddr = recv(UDPSOCK, $udpout, 100, 0)) or die $udprecverr;
$realudpout = unpack("a*", $udpout);

while ($realudpout ne 'status: idle') {
  print STDERR "$opt_P not at idle status.  Cannot start print job.\n";
  defined(send(UDPSOCK, "\r\n", 0, $printudppaddr)) or die $udpsenderr;
  $udpout = "";
  ($printudppaddr = recv(UDPSOCK, $udpout, 100, 0)) or die $udprecverr;
  $realudpout = unpack("a*", $udpout);
  sleep 5;
}

# Get the initial page count

connect(TCPSOCK, $printtcppaddr) or die $tcpconnecterr;
select TCPSOCK;
$| = 1;
select STDOUT;
print TCPSOCK "%!\n";
print TCPSOCK "(%%\[ pagecount: )print statusdict /pagecount get exec ";
print TCPSOCK "(                )cvs print ";
print TCPSOCK "( \]%%) = flush\n";
$tcpout = <TCPSOCK>;
if ($tcpout =~ /%%\[ pagecount:.*/) {
  @tcparray = split /\s/, $tcpout;
  $pagecount1 = $tcparray[2];
}

# Get current time/date (again, this time for the accounting file)

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$month = $MONTHS[$mon];
if (length($sec)  == 1)  { $sec = "0$sec" }
if (length($min)  == 1)  { $min = "0$min" }
if (length($hour) == 1)  { $hour= "0$hour" }
if (length($mday) == 1)  { $mday= " $mday" }

$datestamp = "$month $mday $hour:$min:$sec";

# open LPRng accounting file

if( defined( $opt_a ) && $opt_a && open ACCT, ">>$opt_a" ){
print ACCT "DEBUG: printer return string= $tcpout";
print ACCT "start  -p'$pagecount1' -q'$opt_j' -J'$opt_J' -k'$opt_k' -n'$opt_n' -h'$opt_h' -P'$opt_P' -F'$opt_F' -t'$datestamp'\n";  
close ACCT;
}

# Start shoving data out to printer

# Set print/transparency by queue name

if ($opt_Q =~ /.*t/) {
  print TCPSOCK "%!\n";
  print TCPSOCK "mark\n";
  print TCPSOCK "{\n";
  print TCPSOCK " 3 dict begin\n";
  print TCPSOCK " /MediaType null def\n";
  print TCPSOCK " /MediaColor (Transparent) def\n";
  print TCPSOCK " currentdict end setpagedevice\n";
  print TCPSOCK "} stopped cleartomark\n";
} 

# Shove the rest of the data file out to the printer

while ($line = <STDIN>) {
  print TCPSOCK $line;
}

close TCPSOCK or die $tcpcloseerr;

# Listen for 'status:idle' from printer- this signifies that job is done and
# we can ask printer for page count
# we wait until 'status:idle' is received- retrying every 3 seconds

$realudpout = "";

while ($realudpout ne 'status: idle') {
  defined(send(UDPSOCK, "\r\n", 0, $printudppaddr)) or die $udpsenderr;
  $udpout = "";
  ($printudppaddr = recv(UDPSOCK, $udpout, 100, 0)) or die $udprecverr;
  $realudpout = unpack("a*", $udpout);
  sleep 2;
}

# Now we're ready to grab the final page count from the printer

socket(TCPSOCK, PF_INET, SOCK_STREAM, $tcpproto) or die $tcpsockerr;
connect(TCPSOCK, $printtcppaddr) or die $tcpconnecterr;

print TCPSOCK "%!\n";
print TCPSOCK "(%%\[ pagecount: )print statusdict /pagecount get exec ";
print TCPSOCK "(                )cvs print ";
print TCPSOCK "( \]%%) = flush\n";
$tcpout = <TCPSOCK>;
if ($tcpout =~ /%%\[ pagecount:.*/) {
  @tcparray = split /\s/, $tcpout;
  $pagecount2 = $tcparray[2];
}

close TCPSOCK or die $tcpcloseerr;

# Get date/time again

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$month = $MONTHS[$mon];
if (length($sec)  == 1)  { $sec = "0$sec" }
if (length($min)  == 1)  { $min = "0$min" }
if (length($hour) == 1)  { $hour= "0$hour" }
if (length($mday) == 1)  { $mday= " $mday" }

$datestamp = "$month $mday $hour:$min:$sec";

# Update accounting file upon close

$pages = $pagecount2 - $pagecount1; 

if( defined( $opt_a ) && $opt_a && open ACCT, ">>$opt_a" ){
print ACCT "DEBUG: printer return string= $tcpout";
print ACCT "end  -b'$pages' -p'$pagecount2' -q'$opt_j' -J'$opt_J' -k'$opt_k' -n'$opt_n' -h'$opt_h' -P'$opt_P' -F'o' -t'$datestamp'\n";
close ACCT;
}

# Write a 'Job End' line to the printer log

print STDERR "END: job number $opt_j (dfile: $opt_e) for $opt_n\@$opt_h on $opt_P at $datestamp\n\n";

4.22 Duplex Printing

Duplex printing is when you print on both sides of a page. Some printers which do duplex printing require that you send them special commands to force this mode. This is usually done by the FILTERS. The CTI-ifhp (for HP PJL printers) and psfilter (for PostScript Printers) make a stab at sending the PJL or PostScript commands to the printer. Many people have reported problems doing duplex printing, so here is a check list.

  1. Make sure you have enough memory for the worst case print job. Usually the printer has to rasterize both pages before it can produce an impression. It may require much more memory than you expect.
  2. Check your printer manual to discover the EXACT form of the enter duplex mode command and make sure that either the command is part of the job (PJL language at the start of the job, postscript header, etc), or that the filter generates the correct form.

    Note there is a PostScript Printer Description file (PPD) for most printers that support PostScript, and they even have the PJL and PostScript code for this in the PPD file.

  3. It has been observed that even with what would apparently be sufficient memory, that many duplex jobs print 'oddly', that they are not aligned on the same side in the same way, etc etc. This may not be the fault of the software, but of the support for duplex operation.
  4. Get the source code for psfilter or CTI-ifhp filter, and modify the appropriate lines to send the appropriate "turn on duplex" strings to the printer.

I know this is painful, but until there is a uniform way to get the correct commands extracted from either PPD or some other database then this appears to be the only way to do it.

Patrick Powell

4.23 TESTVERSION and Portability Testing

The LPRng code has the ability to run as non-setuid software, and to use the non-default TCP/IP ports for communication. This facility allows a TESTVERSION to be run in parallel with the normal LPRng software.

To simplify testing and portability issues, a simple test version of the spool queues and jobs has been supplied with the LPRng distribution. These queues can be placed in a suitable location (/tmp is common) and the LPRng software tested.

The test version of the software will use the LPD_CONF environment variable to specify the location of the configuration file. It will read this configuration file on startup and use the values to override the normal defaults. Since a user could maliciously set up their own configuration files with values that could compromise system security, it is strongly recommended that the test version is not made SETUID root. In fact, the LPRng code will chatter messages when the LPD_CONF ability is enabled and it is run as root.

Compiling the TESTVERSION

The TESTVERSION of the software can be compiled in two ways:

  1. Remove the vars.o file, and then explicitly request the generation of the test version:
    cd src
    rm ./vars.o 
    make TESTVERSION=yes
    
  2. Edit src/Makefile, and uncomment the indicated line. Then run make to regenerate the distribution. This is the preferred method of generating the software.
    #### ****** TESTING AND SECURITY LOOPHOLE ******************************
    # Define TESTVERSION and GETENV to allow the LPD_CONFIG environment
    #  variable to be used as the name of a configuration file.  In non-testing
    #  systems,  this is a security loophole.
    # TESTVERSION=yes
    

Setting up the TESTVERSION Spool Queues

The LPRng TESTSUPPORT directory contains a set of shell scripts and files that need to be installed in the appropriate directory. The following steps are used.

  1. First, you need to set up your HOST environment variable to the fully qualified domain name of your host and your USER environment variable to your user name. This is done in order to get values to put into the TESTVERSION configuration files.
  2. In the TESTSUPPORT directory, edit the Makefile, and specify the location of the TESTVERSION spool queues. The default location is /tmp; since on most systems these files are deleted or are available to everybody, a more secure location should most likely be used. DO NOT USE THE RAW TESTFILE DIRECTORY. These files need to be copied and placed in another directory.
  3. The LPD_CONF environment variable should be set to the location of the installed lpd.conf file.
  4. In the TESTSUPPORT directory, run make. This will copy and install the necessary files.

Example:

  CSH:
    setenv HOST {fully qualified domain name};
    setenv USER `whoami`
    setenv LPD_CONF /tmp/LPD/lpd.conf
    set path=( /tmp/LPD $path )
    unsetenv PRINTER
   Example:
      setenv HOST astart1.astart.com
      setenv USER papowell
      setenv LPD_CONF /tmp/LPD/lpd.conf
      set path=( /tmp/LPD $path )
      unsetenv PRINTER
  Bourne Shell:
    HOST={fully qualified domain name}; export HOST;
    USER='whoami'; export USER
    LPD_CONF=/tmp/LPD/lpd.conf.$HOST; export LPD_CONF
    PATH=/tmp/LPD:$PATH; export PATH
    PRINTER=; export PRINTER
   Example: 
      HOST=astart1.astart.com; export HOST
      USER=papowell; export USER
      LPD_CONF=/tmp/LPD/lpd.conf.$HOST; export LPD_CONF
      PATH=/tmp/LPD:$PATH; export PATH
      PRINTER=; export PRINTER
  cd TESTSUPPORT
  make

Portability Testing

You should ignore the information in this section UNLESS you are trying to do a port to a new or whacko version of a UNIX system. LPRng has been tested on just about every version of UNIX that supports POSIX capabilities, and if it is having problems then most likely it is due to non-portability issues. However, if you feel that your system is not POSIX compatible, or you are having serious problems due to LPRng's use of the system facilities, feel free to try the following tests.

Needless to say, if you identify problems, please inform the developers and they will most likely assist you in resolving them.

Set your current directory to the location of the compiled TESTVERSION executables. Execute the various executables using ./cmd, or set . as the first entry in the PATH . If it is not the first entry, then the standard system executables will be used.

  1. Run ./checkpc -T /tmp/a. This will perform a limited set of tests of the LPRng functionality. Note that some of them will fail as checkpc is not running SUID ROOT and the /tmp/a is not a serial device. ALL of the non-SUID related messages should indicate success.
  2. Set checkpc to setuid ROOT, and then rerun the tests.
    chown root checkpc
    chmod u+s checkpc
    ./checkpc -T /tmp/a
    

    The SETUID tests should now succeed. If they do not, then you have a VERY odd UNIX system, and you are on your own on this one. See the comments in src/common/setuid.c for help.

  3. Now run tests for serial line control and locking:
    ./checkpc -T /dev/ttya   # or an appropriate UNUSED tty device
    

    You most likely will have to attach a terminal or modem to the serial device in order to cause the open() to succeed, as most serial device drivers block when DSR is not enabled. Check the messages concerning the stty actions. Make sure that the appropriate changes have taken place.

    You may get errors about device lock failing. This is due to whacko differences in the ways that different UNIX systems (or versions of the same UNIX system) implement serial device locking. My advice is to ignore this problem unless you INSIST on having multiple users of the same serial printing port, in which case you are asking for serious trouble, and you are on your own. I am not interested in patches or queries on problems on serial device locking problems. In fact, this facility is only used if the lk printcap flag is TRUE (default FALSE).

Running the TESTVERSION Software

Set your current directory to the location of the compiled TESTVERSION executables. Execute the various executables using ./cmd, or set . as the first entry in the PATH . If it is not the first entry, then the standard system executables will be used.

  1. Run ./checkpc. this will print out the various values for the spool queues in the TESTVERSION setup. If the t1, t2,... spool queues are not displayed, make sure that the LPD_CONF environment variable is set correctly and that you are using the TESTVERSION executable.
  2. Run ./checkpc -f. This will fix up the (deliberately introduced) problems in the spool queues.
  3. Next, run ./lpd -F in one window, and then run ./lpq -a in another window. This will check that the server is working.
  4. You can now amuse yourself by sending jobs, setting up permissions checking, and other chores.
  5. When everything appears to be working correctly, you can then remove the TESTVERSION flag from the src/Makefile, recompile, and install the LPRng software.

Next Previous Contents