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.

### 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.

### 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)

### 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:

- Networking support (`CONFIG_NET`)
- TCP/IP support (`CONFIG_INET`)
- If your printer is connected to a parallel port, you will also need the `Parallel Printer Support' (`CONFIG_PRINTER`). You can use this as a module if you want.
- For a serial printer, answer `Yes' when asked if you want `Support for serial devices' (`CONFIG_SERIAL`). This is also available as a module.

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.

### 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.7 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.

### 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

### 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.8 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.

- a SMB server, to provide Windows NT and LAN Manager-style file and print services to SMB clients such as Windows 95, Warp Server, smbfs and others.
- a Netbios (rfc1001/1002) nameserver, which among other things gives browsing support. Samba can be the master browser on your LAN if you wish.
- a ftp-like SMB client so you can access PC resources (disks and printers) from unix, Netware and other operating systems
- a tar extension to the client for backing up PCs

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:

- smbfs, a linux-only filesystem allowing you to mount remote SMB filesystems from PCs on your linux box. This is included as standard with Linux 2.0 and later.
- tcpdump-smb, a extension to tcpdump to allow you to investigate SMB networking problems over netbeui and tcp/ip.
- smblib, a library of smb functions which are designed to make it easy to smb-ise any particular application. See ftp://samba.anu.edu.au/pub/samba/smblib.

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:
    >    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

    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.9 Printer Specific notes

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

### 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

### 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:

### 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     -
    ---------------------------------------------------------------------

### 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.10 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