Yes. This is a (recently discovered) known problem.
I assume that the answer to this problem has not been put into any FAQ or
PRINTING-HOWTO documentation yet.

If anyone out there maintaining documentation or FAQ's could add this
explaination it would be appreciated. We need to tell others about the
problem with printing through papd to TCP/IP connected printers using LPR.

It is a problem with LPR. Discovered by Ryan Cleary.
The fix to LPR is attached, and explained below. From Ryan Cleary.

+--------------------------------------------------------------+
 Russell E Glaue, Technologies Engineer   [EMAIL PROTECTED]
 Center for the Application of Information Technologies
 101 Horrabin Hall, 1 University Circle, Macomb, Illinois 61455
 http://www.cait.org  http://cait.wiu.edu

On Tue, 14 Sep 1999, Ali Boudani wrote:

>
>
> hello,
>
> i installed netatalk1.4.2b as an rpm in my Redhat6 and all things seem
> ok.
>
> i want that i can print  from my mac to 2 HP printer connected to my
ethernet
> network so i can conrol the use of number of page that every user use
> in my network.
>


---------- Forwarded message ----------
Date: Tue, 10 Aug 1999 15:29:09 -0400
From: Ryan Cleary <[EMAIL PROTECTED]>
To: Russell E Glaue <[EMAIL PROTECTED]>, Mary L Stracke <[EMAIL PROTECTED]>
Subject: Re: [netatalk-admins] Netatalk and remote printers

Russell E Glaue wrote:

> Has this been brought to the attention to those individuals completing the
> overhaul on Netatalk?  A fix for this should be included in the next
> release so we can all print from papd through LPD to any remote TCP/IP
> LPR.

Like I said before, I fixed lpd, not netatalk, since lpd exhibits the
same problem when printing via lpr machine A to lpd on machine B then to
lpd on machine C. 

See the attached patch, and modified spec file for rebuilding the lpr
rpm (which includes lpd). [*]

Here's what I think is going on with lpd:

When lpd finds a file in it's queue that is supposed to go to a remote
lpd queue, it calls the function sendit() (in lpd/printjob.c), which
mirrors the cf file with a new, temporary filename.  The creation of
this temporary filename is dependent on the original filename having 13
characters, and fails if it's longer.

(771)       dup_cfpname = strdup(file);
(772)       memcpy((dup_cfpname+7), "XXXXXX", 6);
(773)       mktemp(dup_cfpname);
(774)       tmpmask = umask(007);
(775)       dup_cfp=fopen(dup_cfpname, "w");
(776)       umask(tmpmask);
(777)       if (dup_cfp == NULL)
(778)         {
(779)           syslog(LOG_ERR, "Can't create temp cfp file %s", dup_cfpname);
(780)           return(OK);
(781)         }

the memcpy in line 772 replaces characters 7-12 (the last 6 characters
of a 13 character filename) with XXXXXX, so the mktemp in the next line
can create a unique temporary file name.  However if the last 6
characters are not XXXXXX, and they won't be if the original filename is
longer than 13 characters, mktemp fails, and returns NULL.

Sound like a valid conclusions?

By editing line 772 to be:

(772)       memcpy((dup_cfpname + (strlen(dup_cfpname) - 6)), "XXXXXX",
6);

so that it just replaces te last 6 characters with XXXXXX, I seem to
have fixed it.

> I would be interested in any patches to Netatalk papd that will allow it
> to successfully work together with LPD for printing to remote LPRs over
> TCP/IP.
> 
> After 2 years I finally got this problem answered by someone.
> Please forward your patches.  Thank you very much!

You're welcome.  I hope this is useful to you.

--Ryan Cleary

--------------------------------------------------------------------------

* If haven't built your own RPMs before, here's how to rebuild lpr in a
nutshell:

Get the SRPM for lpr-0.35 and install it.  This will put RedHat's spec
file in /usr/src/redhat/SPECS, and the source (lpr-0.35.tar.gz) in
/usr/src/redhat/SOURCES.  Now put my .patch file in the
/usr/src/redhat/SOURCES directory, and replace RedHat's .spec file with
mine.

Now, to actually build the binaries, use the command

   rpm -bb /usr/src/redhat/SPECS/lpr.spec

Then update your installed rpm (probably lpr-0.35-1) to my version
(release 1id1), which should now be in
/usr/src/redhat/RPMS/i386/lpr-0.35-1id1.i386.rpm

   rpm -Uvh /usr/src/redhat/RPMS/i386/lpr-0.35-1id1.i386.rpm

Of, if you prefer, I can email you the binary rpm, ready for
installation.
It's about 76k.



=============== Forwarded message from Ryan Cleary ===============

I searched RedHat's bugzilla site for lpr bugs, and found the one I was
referring to earlier.  It's already been reported (at least twice), and
their fixes are the same as the one I came up with.  There is an updated
version of lpr available (lpr-0.39) that incorporates this fix.  I found
it at:

http://rpmfind.net/linux/rawhide/1.0/i386/RedHat/RPMS/lpr-0.39-2.alpha.rpm

for the Intel version.  SPARC and Alpha versions are there, as well, in
the expected places.

Again, it's not a problem with netatalk at all.  It is (was) a bug in
RedHat's lpd.

--Ryan Cleary

diff -uNr lpr-0.35/lpd/printjob.c lpr-0.35.good/lpd/printjob.c
--- lpr-0.35/lpd/printjob.c     Tue Feb 16 15:01:45 1999
+++ lpr-0.35.good/lpd/printjob.c        Tue Aug 10 14:14:53 1999
@@ -769,7 +769,7 @@
        if (IF != NULL)
          {
            dup_cfpname = strdup(file);
-           memcpy((dup_cfpname+7), "XXXXXX", 6);
+           memcpy((dup_cfpname + (strlen(dup_cfpname) - 6)), "XXXXXX", 6);
            mktemp(dup_cfpname);
            tmpmask = umask(007);
            dup_cfp=fopen(dup_cfpname, "w");

Summary: A utility that manages print jobs.
Name: lpr
Version: 0.35
Release: 1id1
Copyright: distributable
Group: System Environment/Daemons
Source: lpr-%{PACKAGE_VERSION}.tar.gz
Patch: lpr-netatalk.patch
Prereq: /sbin/chkconfig
BuildRoot: /var/tmp/lpr-root

%description
The lpr package provides the basic system utility for managing printing
services.  Lpr manages print queues, sends print jobs to local and remote
printers and accepts print jobs from remote clients.

If you will be printing from your system, you'll need to install the lpr
package.

%prep
%setup -q
%patch -p1 -b .netatalk

%build

%ifarch alpha
# we shouldn't need this with more recent glibc's, but lpq kills remote
# lpd w/o it
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Dgetline=get_line"
%else
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
%endif

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/{bin,sbin,man/man1,man/man5,man/man8}

%ifarch alpha
# we shouldn't need this with more recent glibc's, but lpq kills remote
# lpd w/o it and there seems to be a mistake in lpr's makefiles somewhere
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS -Dgetline=get_line" DESTDIR=$RPM_BUILD_ROOT install
%else
make DESTDIR=$RPM_BUILD_ROOT install
%endif

mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
install -m755 lpd.init $RPM_BUILD_ROOT/etc/rc.d/init.d/lpd
( cd $RPM_BUILD_ROOT
mkdir -p ./etc/rc.d/{rc0.d,rc1.d,rc2.d,rc3.d,rc4.d,rc5.d,rc6.d}
  ln -sf ../init.d/lpd ./etc/rc.d/rc0.d/K60lpd
  ln -sf ../init.d/lpd ./etc/rc.d/rc1.d/K60lpd
  ln -sf ../init.d/lpd ./etc/rc.d/rc2.d/S60lpd
  ln -sf ../init.d/lpd ./etc/rc.d/rc3.d/S60lpd
  ln -sf ../init.d/lpd ./etc/rc.d/rc5.d/S60lpd
  ln -sf ../init.d/lpd ./etc/rc.d/rc6.d/K60lpd
  mkdir -p ./var/spool/lpd
)

%clean
rm -rf $RPM_BUILD_ROOT

%post
/sbin/chkconfig --add lpd

%postun
if [ $1 = 0 ]; then
   /sbin/chkconfig --del lpd
fi

%files
%defattr(-,root,root)
%attr(6555,root,lp) /usr/bin/lpq
%attr(6555,root,lp) /usr/bin/lpr
%attr(6555,root,lp) /usr/bin/lprm
/usr/bin/lptest
/usr/man/man1/lpq.1
/usr/man/man1/lpr.1
/usr/man/man1/lprm.1
/usr/man/man1/lptest.1
/usr/man/man5/printcap.5
/usr/man/man8/lpc.8
/usr/man/man8/lpd.8
/usr/man/man8/pac.8
%attr(2755,root,lp) /usr/sbin/lpc
/usr/sbin/lpd
/usr/sbin/lpf
/usr/sbin/pac
%attr(0775,root,daemon) %dir /var/spool/lpd
%config /etc/rc.d/init.d/lpd
%config(missingok) /etc/rc.d/rc0.d/K60lpd
%config(missingok) /etc/rc.d/rc1.d/K60lpd
%config(missingok) /etc/rc.d/rc2.d/S60lpd
%config(missingok) /etc/rc.d/rc3.d/S60lpd
%config(missingok) /etc/rc.d/rc5.d/S60lpd
%config(missingok) /etc/rc.d/rc6.d/K60lpd

%changelog
* Tue Aug 10 1999 Ryan Cleary <[EMAIL PROTECTED]>
- fixed sendit() in lpd/printjob.c to allow queue files
- that aren't exactly 13 characters long

* Mon Mar 22 1999 Bill Nottingham <[EMAIL PROTECTED]>
- increase buffer length for filenames (bug #1676)

* Fri Mar 19 1999 Bill Nottingham <[EMAIL PROTECTED]>
- change man page to show that -r -s is not supported (bug #717)

* Mon Feb 15 1999 Bill Nottingham <[EMAIL PROTECTED]>
- security patch from Chris Evans
- fix for remote but not local users (originally from Kevin Sochacki)

* Mon Feb  8 1999 Bill Nottingham <[EMAIL PROTECTED]>
- build for 6.0 tree

* Thu Oct  1 1998 Bill Nottingham <[EMAIL PROTECTED]>
- don't ignore SIGCHLD in filters

* Mon Aug  3 1998 Jeff Johnson <[EMAIL PROTECTED]>
- build root.

* Fri Jun 26 1998 Jeff Johnson <[EMAIL PROTECTED]>
- bring printjob up-to-date (fix problem #564)

* Thu Apr 23 1998 Michael K. Johnson <[EMAIL PROTECTED]>
- enhanced initscript

* Thu Apr 23 1998 Erik Troan <[EMAIL PROTECTED]>
- included new rmjob security fix from BSD

* Sat Apr 18 1998 Erik Troan <[EMAIL PROTECTED]>
- included rmjob patches from BSD

* Fri Feb 27 1998 Otto Hammersmith <[EMAIL PROTECTED]>
- increased buffer for hostname from 32 to 1024, plenty big enough now.

* Wed Oct 29 1997 Donnie Barnes <[EMAIL PROTECTED]>
- added chkconfig support
- changed the initscript name from lpd.init to lpd (all links, too)

* Mon Oct 27 1997 Michael Fulbright <[EMAIL PROTECTED]>
- Fixed print filters to change to printer's UID so root-squashing wont bite us

* Wed Oct  8 1997 Michael Fulbright <[EMAIL PROTECTED]>
- Fixed nasty error in getprent() and forked lpd's in startup() which
  caused the printcap file to be read incorrectly.
- added #include <string.h> as needed to make compile cleaner.  

* Thu Jul 10 1997 Erik Troan <[EMAIL PROTECTED]>
- changes for glibc 2.0.4

* Tue Apr 22 1997 Michael Fulbright <[EMAIL PROTECTED]>
- moved to v. 0.17, then 0.18 (!)
- Fixed bug on Alpha/glibc when printing to a remote queue via a filter

* Fri Mar 28 1997 Michael Fulbright <[EMAIL PROTECTED]>
- Moved version up to 0.16
- Added input filter support for remote queues

* Wed Mar 05 1997 Erik Troan <[EMAIL PROTECTED]>
- Incorporated filter patch into main sources
- Removed RCS logs from source tar file
- Added patched from David Mosberger to fix __ivaliduser on Alpha's
- added -Dgetline=get_line for old glibcs (this means alpha)

Reply via email to