After upgrade 14.4 to 14.5 I found printing doesn't work anymore.
At first I assumed a problem with the upgrade, or with that bogus WCH382 puc printer card (which is very much broken), or the printer itself (which is 40+ years old).
Then I found the printer still works with an ulpt cable. So I rebooted to 14.4, only to find that now neither, ulpt or puc/lpt, would work.
After some more hassle, it came out the problem was the cable.
So now I could print per
I started to look into the desktop's CUPS, but didn't find anything useful there. I recreated lpd on the desktop, and that also failed to print on the server. So I started to look into the control files, and they are broken.
The printjob as received from remote should carry the (remote) hostname, and this should also become the filename. Now somebody had the great idea to replace this hostname with the actually authenticated name that we get from DNS for the sending interface (probably for security reasons).
But that is then NOT a hostname, it is an interface name, and that is not the same.
What they didn't change is the actual contents of the control file, which contains the same hostname, in order to later print and then delete the job.
So what we actually get from another lpd is the hostname (which, again, is NOT an interface name), and from CUPS we won't even get that, instead we get an FQDN hostname shortened to 15 characters.
In either case, that job can neither be printed nor deleted, because it cannot be found, because it is stored with a filename containing the interface-name instead.
I was under the impression that lpr/lpd is already removed in Rel.15, and I soon have to look for something else. So I just reverted the bogus to get it working for now, without bothering for a proper fix.
But now I see, lpd retirement is actually planned for Rel.16, so I decided to post the patch here, in case somebody else also runs into this and needs to quickly get it working.
At first I assumed a problem with the upgrade, or with that bogus WCH382 puc printer card (which is very much broken), or the printer itself (which is 40+ years old).
Then I found the printer still works with an ulpt cable. So I rebooted to 14.4, only to find that now neither, ulpt or puc/lpt, would work.
After some more hassle, it came out the problem was the cable.
So now I could print per
echo text > /dev/lpt0. Regular printing however would still not work.I started to look into the desktop's CUPS, but didn't find anything useful there. I recreated lpd on the desktop, and that also failed to print on the server. So I started to look into the control files, and they are broken.
The printjob as received from remote should carry the (remote) hostname, and this should also become the filename. Now somebody had the great idea to replace this hostname with the actually authenticated name that we get from DNS for the sending interface (probably for security reasons).
But that is then NOT a hostname, it is an interface name, and that is not the same.
What they didn't change is the actual contents of the control file, which contains the same hostname, in order to later print and then delete the job.
So what we actually get from another lpd is the hostname (which, again, is NOT an interface name), and from CUPS we won't even get that, instead we get an FQDN hostname shortened to 15 characters.
In either case, that job can neither be printed nor deleted, because it cannot be found, because it is stored with a filename containing the interface-name instead.
I was under the impression that lpr/lpd is already removed in Rel.15, and I soon have to look for something else. So I just reverted the bogus to get it working for now, without bothering for a proper fix.
But now I see, lpd retirement is actually planned for Rel.16, so I decided to post the patch here, in case somebody else also runs into this and needs to quickly get it working.
Code:
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index 94ff82ecb88f..39ee3828c6b2 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -253,32 +253,11 @@ readjob(struct printer *pp)
}
if (*cp++ != ' ')
break;
- /*
- * The next six bytes must be curd0, 'f', curd2
- * followed by a three-digit job number, where
- * curd2 cycles through [A-Za-z] while curd0
- * starts at 'd' and increments when curd2 rolls
- * around. The rest of the line is the client
- * host name, but we substitute the host name
- * we've already authenticated.
- */
- if (cp[0] != curd0 || cp[1] != 'f' || cp[2] != curd2 ||
- !digit(cp[3]) || !digit(cp[4]) || !digit(cp[5]))
- break;
- n = (cp[3] - '0') * 100 + (cp[4] - '0') * 10 +
- cp[5] - '0';
- if (curn == -1)
- curn = n;
- else if (curn != n)
- break;
- len = snprintf(dfname, sizeof(dfname), "%.6s%s", cp,
- from_host);
- if (len >= sizeof(dfname))
- break;
if (!chksize(size)) {
nak(pp);
continue;
}
+ strlcpy(dfname, cp, sizeof(dfname));
switch (curd2++) {
case 'Z':
curd2 = 'a';