Printing
NOTE: This page describes the steps I took to get my OpenBSD
server to print documents sent to it locally
through lpr, and remotely through Samba. Configuring your OpenBSD desktop
system likely entails additional or different steps not listed here.
I have a Canon LBP-430 printer (almost identical to the HP
LaserJet 4L) and wanted to set up network printing via Samba and lpd.
Naturally, this was not as easy as it should be so I went in
search of some help. The following page seems to have the best
information:
http://monkey.org/openbsd/archive/misc/0009/msg00412.html
My conf files follow:
smb.conf:
[global]
workgroup = GRSCP
server string = Mesa -- OpenBSD Server
hosts allow = 192.168. 127.0.0.1
encrypt passwords = yes
smb passwd file = /etc/samba/private/smbpasswd
log file = /var/log/samba%m
max log size = 50
security = user
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
remote announce = 192.168.
local master = yes
os level = 33
domain master = yes
preferred master = yes
domain logons = yes
name resolve order = host bcast
dns proxy = no
unix password sync = no
map to guest = never
password level = 0
null passwords = no
wins support = yes
dead time = 0
debug level = 0
printing = bsd
printcap name = /etc/printcap
[lbp430]
print command = lpr -r -P%p %s
lpq command = lpq -P%p
lprm command = lprm -P%p %j
comment = Canon LBP-430
path = /var/spool/samba
printable = yes
public = yes
[users]
comment = Home Directories
path = /usr/home
public = no
writeable = yes
[public]
comment = Public Folder
path = /usr/local/public
public = yes
writeable = yes
[install]
comment = Install
path = /usr/local/install
public = yes
writeable = no
printcap:
# $OpenBSD: printcap,v 1.4 2003/03/28 21:32:30 jmc Exp $
#lp|local line printer:\
# :lp=/dev/lp:sd=/var/spool/output:lf=/var/log/lpd-errs:
#rp|remote line printer:\
# :lp=:rm=printhost:rp=lp:sd=/var/spool/output:lf=/var/log/lpd-errs:
lp|local:\
:sh:sd=/var/spool/lpd/lbp430:\
:lp=/dev/lpt0:\
:if=/usr/local/libexec/hpif:
lbp430|Samba:\
:rw:sh: \
:lp=/dev/lpt0: \
:sd=/var/spool/lpd/lbp430: \
:fx=flp: \
:sf:
And the hpif script lifted directly from the above listed page:
#!/bin/sh
#
# hpif - Simple text input filter for lpd for HP-PCL based printers
# Installed in /usr/local/libexec/hpif
#
# Simply copies stdin to stdout. Ignores all filter arguments.
# Tells printer to treat LF as CR+LF. Writes a form feed character
# after printing job.
printf "\033&k2G" && cat && printf "\f" && exit 0
exit 2
Turning on a little debugging certainly helped, so I start Samba
with the following command in rc.local:
if [ -f /etc/samba/smb.conf ]; then
/usr/local/libexec/smbd -d1 -D; /usr/local/libexec/nmbd -d1 -D
fi
and I start lpd with the following line added to rc.conf.local
(or edit rc.conf for the brave, possibly foolhardy):
lpd_flags="-dls"
The "-s" option to lpd invokes it in secure
mode, not opening port 515, and taking print jobs only from local
sockets (?). Since remote printing is done through Samba, this makes
sense and keeps open ports on this system to a minimum.
Please note /var/spool/samba. This directory will need to be
group writable by the same group to which Samba users belong. I think
group daemon should be sufficient, but that does not seem to work
in my case. So I created a group samba and added each Samba user
to that group, and made that directory group writeable by the samba group.
This is problematic in that this will prevent any guests from being able
to print (should I desire such). Currently, everyone wishing to print
needs an actual user account on the machine (not just a Samba account),
with their samba account name matching their user account name.
The Samba I use is from the Ports tree (updated, of course!) and
seems to work quite well.
One more thing... and is not applicable to my system... If you want
to use CUPS and Samba (from Ports), make sure to remove the
"--disable-cups" argument from the CONFIGURATION_ARGS
section of /usr/ports/net/samba/stable/Makefile. --enable-cups is not
required as Samba will, by default (supposedly), detect CUPS if it is
running.
NEW: I did the unthinkable... I brought a liquid (coffee, with
sugar and cream) into my computer room* and promptly spilled it on my venerable
LBP-430. That printer served me well for eleven years without so much
as a hiccup. Attempts to clean it and let it dry were not enough. I may
take the thing completely apart to see if I can make it work again, but
that is a long shot. At least the coffee was good.
( *computer room is a strong word to use. It is, of course, my den
which is filled with various boxen running various OSs. My wife keeps
yelling at me to "Clean that d----d place up!" )
$179.99+tax later and I am the proud owner of a Brother HL-5140
printer. More features than the Canon, to be sure, though my gut tells
me it will not last eleven years like my old Canon. Anyway, with only
minimal change to the above configurations, this printer is working fine.
The HL-5140 can use either a USB or Parallel interface, and I chose USB.
Had I chosen Parallel, I would have had to make NO changes to my print
settings. Choosing USB required only TWO changes to be made to
/etc/printcap: each instance of lpt0 was changed to ulpt0.
Additional changes were made to better identify the new printer, though
they were not necessary from a functional perspective. New smb.conf and
printcap follow.
smb.conf:
[global]
workgroup = GRSCP
server string = Mesa -- OpenBSD Server
hosts allow = 192.168. 127.0.0.1
encrypt passwords = yes
smb passwd file = /etc/samba/private/smbpasswd
log file = /var/log/samba%m
max log size = 50
security = user
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
remote announce = 192.168.
local master = yes
os level = 33
domain master = yes
preferred master = yes
domain logons = yes
name resolve order = host bcast
dns proxy = no
unix password sync = no
map to guest = never
password level = 0
null passwords = no
wins support = yes
dead time = 0
debug level = 0
printing = bsd
printcap name = /etc/printcap
[hl5140]
print command = lpr -r -P%p %s
lpq command = lpq -P%p
lprm command = lprm -P%p %j
comment = Brother HL-5140
path = /var/spool/samba
printable = yes
public = yes
[users]
comment = Home Directories
path = /usr/home
public = no
writeable = yes
[public]
comment = Public Folder
path = /usr/local/public
public = yes
writeable = yes
[install]
comment = Install
path = /usr/local/install
public = yes
writeable = no
printcap:
# $OpenBSD: printcap,v 1.4 2003/03/28 21:32:30 jmc Exp $
#lp|local line printer:\
# :lp=/dev/lp:sd=/var/spool/output:lf=/var/log/lpd-errs:
#rp|remote line printer:\
# :lp=:rm=printhost:rp=lp:sd=/var/spool/output:lf=/var/log/lpd-errs:
lp|local:\
:sh:sd=/var/spool/output:\
:lp=/dev/ulpt0:\
:if=/usr/local/libexec/hpif:\
:lf=/var/log/lpd-errs:
hl5140|Samba:\
:rw:sh:\
:lp=/dev/ulpt0:\
:sd=/var/spool/output:\
:fx=flp:\
:sf:\
:lf=/var/log/lpd-errs:
|