smbfax - Print to a fax machine via Samba, or pretty much any other
program that can pipe WITHOUT the need for annoying
client-side software (well, other than a PostScript printer
driver anyway)
Craig Kelley - Oct 23, 2003
- MANIFEST
-rw-r--r-- 1 ink ink 164 Oct 23 09:30 AUTHORS -rw-r--r-- 1 ink ink 190 Apr 20 2001 COPYING -rw-r--r-- 1 ink ink 374 Jun 28 2000 hfaxd.conf -rw-r--r-- 1 ink ink 6391 Jun 7 2001 README -rw-r--r-- 1 ink ink 400 Jun 29 2000 smb.conf -rwxr-xr-x 1 ink ink 7653 Oct 23 09:30 smbfax* -rw-r--r-- 1 ink ink 1313 Oct 23 09:40 smbfax.conf -rwxr-xr-x 1 ink ink 823 Aug 11 2000 smbfax-cron* -rw-r--r-- 1 ink ink 1306 Apr 20 2001 smbfax-html.c -rwxr-xr-x 1 ink ink 11408 Oct 23 09:47 smbfax-html.pl*
1. What you need already installed:
UNIX or POSIX-ish OS (tested against Linux-2.2.16 -- RedHat 6.2)
hylafax (tested against 4.1beta3) Make sure you can send faxes from within hylafax before you go any further!
perl (needs at least 5.004)
the following perl modules are needed:
CGI
Digest::MD5
Net::SMTP
apache (tested against apache_1.3.12 -- suggest using SSL for maximum
security, although any CGI-BIN webserver should work fine)
cron (any task scheduler should work)
should come with your UNIX
2. How to install it:
You need to be the 'root' user to do the following:
- Choose a directory for smbfax. If you should happen to choose
/usr/local/smbfax
it will make life easier. Move all the files from the archive to this location. If you chose a different path, then you will need to edit smbfax, smbfax-cron, smbfax-html to reflect the new path.
B. Move smbfax-html to a valid cgi-bin directory (SSL-enabled for
maximum security -- but not required at all). Make sure that the root user owns it and then setuid the program to root (unless your webserver runs as root already, which is a bad idea, IMHO):
** NEW WAY TO INSTALL smbfax-html **
perl-5.6.x and higher are more strict about what they will
run by default. You can compile perl in such a way that
suid scripts still work, but it's probably easier and better
to use the smbfax-html.c wrapper provided in this distribution.
Also, many UNIX kernels will not run setuid scripts for
(dubious) security reasons. You can still install smbfax-html
the way you used to (if you used smbfax previously), but you
will PROBABLY WANT TO USE THIS METHOD since it will always work.
If you choose to run it the old way then don't forget to change
the first line of the script to point to suidperl. Here is
the new reccomended method; substitue your filesystem layout
as needed:
mv /usr/local/smbfax-html.pl /usr/local/www/cgi-bin-ssl/fax
mv /usr/local/smbfax-html.c /usr/local/www/cgi-bin-ssl/fax
cd /usr/local/www/cgi-bin-ssl/fax
cc -o smbfax-html smbfax-html.c
cd -
chown root.root /usr/local/www/cgi-bin-ssl/fax/smbfax-html
chmod 6755 /usr/local/www/cgi-bin-ssl/fax/smbfax-html
** Be sure to edit smbfax-html.c so that the correct PATH information
** is in there (unless your webserver is setup exactly the same
** way mine is :)
It needs to run as the root user, but it does NOT perform any exec() or other dangerous tasks without giving up root privileges to become the user that sent the fax (the root user is not allowed to send faxes). Be sure to restart/signal your webserver after making the httpd.conf change (if you need to, which you probably don't).
C. Make an empty spooling directory for outgoing faxes:
mkdir /usr/local/www/fax
chmod a+rwx /usr/local/www/fax
You can sticky-bit this if you like, but all files are chmod 0700 to their owner (which cannot be root, under the suid program).
D. Setup smbfax-cron to run occasionally by picking one of the following
- methods
Method One
Edit your cron table (/etc/crontab) to run the fax cleanup job, adding these lines (changed to reflect your setup, of course):
# Remove temporary file used by fax service
10,20,30,40,50,60 * * * * root /usr/local/smbfax/smbfax-cron
Then, restart your cron daemon (or otherwise signal it to reload). This will keep the fax spooling directory clean.
Method Two
If your UNIX is nice enough to have /etc/cron.hourly (or similar), then just copy the smbfax-cron file there and you're done:
cp smbfax-cron /etc/cron.hourly
E. Edit your Hylafax configuration file (usually /usr/share/fax/hfaxd.conf)
so that the JobFmt is set for suitable job queue formats:
JobFmt: "%-9o %-5a %4j %l"
and restart hylafax. This is so that Windows users can see the queued faxes in their fax printer window.
F. Configure a new printer for Samba with an entry like this (if you use
Samba):
[fax]
comment = OTC Fax Printer
path = /tmp
lpq command = /usr/local/smbfax/smbfax show
lprm command = /usr/local/smbfax/smbfax dequeue %j
print command = /usr/local/smbfax/smbfax -r queue %u %s
queuepause command = /bin/true
queueresume command = /bin/true
postscript = true
browseable = yes
printable = yes
writable = no
create mode = 0700
printing = lprng
Note that you need to be using "security = user" in order for this to work (that's the default setup anyway).
G. Open smbfax.conf in your favorite editor and change the settings to
reflect your system.
That's it. Setup a PostScript printer on a windows box. I reccomend using
HP LaserJet IIP PS Cartridge
which utilizes PSCRIPT.DLL to send out the document in PostScript. Print a test page, and you should get an e-mail containing the URL to follow. It's as simple as "print" and then check your e-mail.
