You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
lpadmin from 1.4rc1 fails to admin 1.3.10 remotely #3231
I have a Fedora 10 machine (cups-1.3.10) which other Fedora 10 machines can administer remotely, i.e. this sort of thing works:
lpadmin -U root -h f10-server -p foo -v /dev/null
It asks for the root password and then a queue 'foo' is added. However, when trying this same command from a Fedora 11 machine (cups-1.4rc1), it fails:
Password for root on f10-server?
lpadmin: Service Unavailable
This appears in the error_log on f10-server:
D [19/Jun/2009:17:25:53 +0100] cupsdReadClient: 19 OPTIONS * HTTP/1.1
d [19/Jun/2009:17:25:53 +0100] cupsdFindBest: uri = ""...
d [19/Jun/2009:17:25:53 +0100] cupsdFindBest: Location CUPS_INTERNAL_BROWSE_ACL Limit 0
d [19/Jun/2009:17:25:53 +0100] cupsdFindBest: Location /admin/conf Limit 7f
d [19/Jun/2009:17:25:53 +0100] cupsdFindBest: Location /admin Limit 7f
d [19/Jun/2009:17:25:53 +0100] cupsdFindBest: Location / Limit 7f
d [19/Jun/2009:17:25:53 +0100] cupsdFindBest: best = NONE
d [19/Jun/2009:17:25:53 +0100] cupsdAuthorize: con->uri="", con->best=(nil)()
d [19/Jun/2009:17:25:53 +0100] cupsdAuthorize: Authorization=""
D [19/Jun/2009:17:25:53 +0100] cupsdAuthorize: No authentication data provided.
E [19/Jun/2009:17:26:03 +0100] encrypt_client: Unable to encrypt connection from 192.168.1.11!
E [19/Jun/2009:17:26:03 +0100] encrypt_client: A TLS packet with unexpected length was received.
D [19/Jun/2009:17:26:03 +0100] cupsdCloseClient: 19
The gnutls library is used for CUPS in both Fedora 10 and Fedora 11.
I am still trying to investigate the cause, but wondered if you had seen any similar reports of SSL problems between 1.4rc1 and 1.3.10.
The problem was introduced in subversion revision 7823. In particular, applying the attached patch, cups-undo-svn7823.patch (which reverts part of revision 7823), to 1.4rc1 fixes the problem for me here.
No, that doesn't fix it either. Here's a gdb session from the patched CUPS showing what's going on. To make it succeed, I get it to jump over the contentious status test at line 269. My comments (###) inline:
$ gdb --args lpadmin -U root -h cyberelk -p foo -v /dev/null ... b request.c:268
[...]
Breakpoint 1 (request.c:268) pending.
(gdb) r
[...]
Breakpoint 1, cupsDoIORequest (http=0x7ffff8239d20, request=0x7ffff8239bc0,
resource=0x7ffff7ffd818 "/admin/", infile=-1, outfile=-1) at request.c:269
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
(gdb) p status
$1 = HTTP_UPGRADE_REQUIRED
So first time through the loop we get told to encrypt.
(gdb) c
Continuing.
Password for root on cyberelk?
Breakpoint 1, cupsDoIORequest (http=0x7ffff8239d20, request=0x7ffff8239bc0,
resource=0x7ffff7ffd818 "/admin/", infile=-1, outfile=-1) at request.c:269
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
(gdb) p status
$2 = HTTP_SERVICE_UNAVAILABLE
Next time round, after the password has been given, we get a server error. Not sure what causes this. Running this patched CUPS outside gdb would fail at this point with an error message. I'll tell gdb to skip over the test though:
(gdb) l
264 status = http->status;
265 }
266
267 DEBUG_printf(("2cupsDoIORequest: status=%d", status));
268
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
270 {
271 httpFlush(http);
272 _cupsSetHTTPError(status);
273 break;
(gdb)
274 }
275
276 if (response)
277 {
278 if (outfile >= 0)
279 {
280 /*
281 * Write trailing data to file...
282 */
283
(gdb) j 276
Continuing at 0x7ffff79ab5d7.
Breakpoint 1, cupsDoIORequest (http=0x7ffff8239d20, request=0x7ffff8239bc0,
resource=0x7ffff7ffd818 "/admin/", infile=-1, outfile=-1) at request.c:269
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
(gdb) p status
$3 = HTTP_OK
Bizarrely, having skipped the test and gone round the loop again, this time the operation has succeeded!
(gdb) c
Continuing.
Program exited normally.
(gdb) quit
$ lpstat -h cyberelk -s | grep foo
device for foo: ///dev/null
HTTP_SERVICE_UNAVAILABLE is only set when the client library is unable to connect to the server. If we allow that to loop, a dead server will call a client app to hang, which is not what we want!
What's worse is that I loaded up F10 in a VM on Friday to test this myself and was unable to reproduce with my current fix applied.
So, can you break in httpReconnect to see if it is getting called and what it is returning vs. what is happening on the server?
Thanks!
(Oh, and this is probably not going to block 1.4.0 from releasing, so the sooner we can figure out the actual cause and fix the better chance it will be in 1.4.0...)
In detail, what was happening was that while upgrading, the content part of the server's "Upgrade" message was being read as an HTTP response, which left http->data_remaining undefined. Then the server timed out the SSL handshake before the client timed out trying to read a response.
diff --git a/cups/http.c b/cups/http.c
index 7093ee3..5a2e896 100644
--- a/cups/http.c
+++ b/cups/http.c
@@ -3144,6 +3144,13 @@ http_upgrade(http_t http) / I - Connection to server */
DEBUG_printf(("7http_upgrade(%p)", http));
/*
* Flush the connection to make sure any previous "Upgrade" message
* has been read.
*/
httpFlush(http);
/*
Copy the HTTP data to a local variable so we can do the OPTIONS
request without interfering with the existing request data... /
@@ -3170,8 +3177,6 @@ http_upgrade(http_t *http) / I - Connection to server */
while (httpUpdate(http) == HTTP_CONTINUE);
}
Activity
michaelrsweet commentedon Jun 19, 2009
CUPS.org User: mike
Nope, but we do very little testing with GNU TLS.
I'm not aware of any specific changes that would account for this; are you using the same version of GNU TLS on both ends?
Does "https://server:631" work from one machine to the other?
michaelrsweet commentedon Jun 19, 2009
CUPS.org User: twaugh.redhat
The Fedora 11 machine is using gnutls 2.6.6; Fedora 10 has 2.4.2. That'll be my next job: try cups-1.4rc1 with the gnutls Fedora 10 is using.
Yes, https://f10-server:631/ works from the Fedora 11 machine.
michaelrsweet commentedon Jun 20, 2009
CUPS.org User: twaugh.redhat
Just tried cups-1.4rc1 on the same Fedora 10 system that cups-1.3.10's lpadmin was working fine on, and I get the same symptom.
That seems to isolate the reason for the problem as being in cups-1.4rc1.
michaelrsweet commentedon Jun 22, 2009
CUPS.org User: twaugh.redhat
The problem was introduced in subversion revision 7823. In particular, applying the attached patch, cups-undo-svn7823.patch (which reverts part of revision 7823), to 1.4rc1 fixes the problem for me here.
michaelrsweet commentedon Jun 22, 2009
CUPS.org User: mike
Tim, the change you're proposing actually breaks what r7823 was trying to fix. Does the following change fix things for you?
Index: cups/request.c
--- cups/request.c (revision 8723)
+++ cups/request.c (working copy)
@@ -269,6 +269,7 @@
if (status == HTTP_FORBIDDEN || status == HTTP_ERROR ||
status >= HTTP_SERVER_ERROR)
{
break;
}
michaelrsweet commentedon Jun 23, 2009
CUPS.org User: twaugh.redhat
Sorry, it doesn't.
michaelrsweet commentedon Jun 26, 2009
CUPS.org User: mike
OK, how about just dropping the HTTP_ERROR case:
Index: request.c
--- request.c (revision 8723)
+++ request.c (working copy)
@@ -266,9 +266,9 @@
{
break;
}
michaelrsweet commentedon Jun 29, 2009
CUPS.org User: twaugh.redhat
No, that doesn't fix it either. Here's a gdb session from the patched CUPS showing what's going on. To make it succeed, I get it to jump over the contentious status test at line 269. My comments (###) inline:
$ gdb --args lpadmin -U root -h cyberelk -p foo -v /dev/null
... b request.c:268
[...]
Breakpoint 1 (request.c:268) pending.
(gdb) r
[...]
Breakpoint 1, cupsDoIORequest (http=0x7ffff8239d20, request=0x7ffff8239bc0,
resource=0x7ffff7ffd818 "/admin/", infile=-1, outfile=-1) at request.c:269
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
(gdb) p status
$1 = HTTP_UPGRADE_REQUIRED
So first time through the loop we get told to encrypt.
(gdb) c
Continuing.
Password for root on cyberelk?
Breakpoint 1, cupsDoIORequest (http=0x7ffff8239d20, request=0x7ffff8239bc0,
resource=0x7ffff7ffd818 "/admin/", infile=-1, outfile=-1) at request.c:269
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
(gdb) p status
$2 = HTTP_SERVICE_UNAVAILABLE
Next time round, after the password has been given, we get a server error. Not sure what causes this. Running this patched CUPS outside gdb would fail at this point with an error message. I'll tell gdb to skip over the test though:
(gdb) l
264 status = http->status;
265 }
266
267 DEBUG_printf(("2cupsDoIORequest: status=%d", status));
268
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
270 {
271 httpFlush(http);
272 _cupsSetHTTPError(status);
273 break;
(gdb)
274 }
275
276 if (response)
277 {
278 if (outfile >= 0)
279 {
280 /*
281 * Write trailing data to file...
282 */
283
(gdb) j 276
Continuing at 0x7ffff79ab5d7.
Breakpoint 1, cupsDoIORequest (http=0x7ffff8239d20, request=0x7ffff8239bc0,
resource=0x7ffff7ffd818 "/admin/", infile=-1, outfile=-1) at request.c:269
269 if (status == HTTP_FORBIDDEN || status >= HTTP_SERVER_ERROR)
(gdb) p status
$3 = HTTP_OK
Bizarrely, having skipped the test and gone round the loop again, this time the operation has succeeded!
(gdb) c
Continuing.
Program exited normally.
(gdb) quit
$ lpstat -h cyberelk -s | grep foo
device for foo: ///dev/null
michaelrsweet commentedon Jun 29, 2009
CUPS.org User: mike
HTTP_SERVICE_UNAVAILABLE is only set when the client library is unable to connect to the server. If we allow that to loop, a dead server will call a client app to hang, which is not what we want!
What's worse is that I loaded up F10 in a VM on Friday to test this myself and was unable to reproduce with my current fix applied.
So, can you break in httpReconnect to see if it is getting called and what it is returning vs. what is happening on the server?
Thanks!
(Oh, and this is probably not going to block 1.4.0 from releasing, so the sooner we can figure out the actual cause and fix the better chance it will be in 1.4.0...)
michaelrsweet commentedon Jul 1, 2009
CUPS.org User: twaugh.redhat
http-upgrade-flush.patch fixes it here.
In detail, what was happening was that while upgrading, the content part of the server's "Upgrade" message was being read as an HTTP response, which left http->data_remaining undefined. Then the server timed out the SSL handshake before the client timed out trying to read a response.
michaelrsweet commentedon Jul 1, 2009
CUPS.org User: mike
Fixed in Subversion repository.
michaelrsweet commentedon Jul 1, 2009
"cups-undo-svn7823.patch":
diff -up cups-1.4rc1/cups/request.c.undo-svn7823 cups-1.4rc1/cups/request.c
--- cups-1.4rc1/cups/request.c.undo-svn7823 2009-05-13 22:39:17.000000000 +0100
+++ cups-1.4rc1/cups/request.c 2009-06-22 14:42:41.577421022 +0100
@@ -266,8 +266,7 @@ cupsDoIORequest(http_t http, / I -
{
_cupsSetHTTPError(status);
break;
michaelrsweet commentedon Jul 1, 2009
"http-upgrade-flush.patch":
From 7c84a9c31c1b2b6be03db87d20b67b0202cd6290 Mon Sep 17 00:00:00 2001
From: Tim Waugh twaugh@redhat.com
Date: Wed, 1 Jul 2009 12:12:36 +0100
Subject: [PATCH] Flush the connection before upgrading (STR #3231).
Make sure to flush the connection at the start of http_upgrade() so
that we don't start reading the content part of the previous "Upgrade"
message as the SSL handshake.
cups/http.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/cups/http.c b/cups/http.c
index 7093ee3..5a2e896 100644
--- a/cups/http.c
+++ b/cups/http.c
@@ -3144,6 +3144,13 @@ http_upgrade(http_t http) / I - Connection to server */
DEBUG_printf(("7http_upgrade(%p)", http));
/*
/
@@ -3170,8 +3177,6 @@ http_upgrade(http_t *http) / I - Connection to server */
while (httpUpdate(http) == HTTP_CONTINUE);
}
- httpFlush(http);
/*
Restore the HTTP request data...
1.6.2.5*/