Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webinterface: Changing Settings results in cupsd.conf being truncated #1976

Closed
michaelrsweet opened this issue Sep 14, 2006 · 22 comments

Comments

@michaelrsweet
Copy link
Collaborator

commented Sep 14, 2006

Version: 1.2.3
CUPS.org User: rojon

Since 1.2.3 changing settings in the Webinterface Serversettings Page truncates cupsd.conf and as an result the Server didn't start again.
This works well with Version 1.2.2

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 14, 2006

CUPS.org User: mike

Please attach the cupsd.conf file before and after the change.

Also, please describe what check boxes are set if you are changing the basic server settings or if you are using the "edit" button...

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 15, 2006

CUPS.org User: rojon

I've attached a cupsd.conf used before the changings,
the cupsd.conf after gets truncated, meaning have zero length

In either case change settings via the checkboxes i.e uncheck
"Save debugging information for troubleshooting" and Submit via "Change Settings" results in Cupsd never restarted again, because there is no more parseable cupsd.conf anymore, the same occurs while using Edit button for changing cupsd.conf.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 15, 2006

CUPS.org User: mike

Try applying the patches from STR #1968 and let me know if that does not resolve the problem:

http://www.cups.org/str.php?L1968

Also, what operating system are you using? What compiler are you using?

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 15, 2006

CUPS.org User: mike

Oh, and also are you just clicking on the "Change Settings" button on the main admin page, or "Edit Configuration File"?

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 15, 2006

CUPS.org User: jewillia

I'm able to reproduce the issue on a RHEL4 U4 test machine. The only changes I made to the default config file were to listen on all interfaces, allow access from my workstation, and turn browsing off. To reproduce the issue, I go to the web interface, click on the Administration tab, click "Edit Configuration File", make a small change (for example, turn browsing back on), and click "Save Changes". Here is what the error log shows:

I [15/Sep/2006:10:02:38 -0500] Installing config file "/etc/cups/cupsd.conf"...
I [15/Sep/2006:10:02:38 -0500] Saving remote.cache...
X [15/Sep/2006:10:02:38 -0500] No valid Listen or Port lines were found in the configuration file!
X [15/Sep/2006:10:02:38 -0500] No Listen or Port lines were found to allow access via localhost!

Cupsd stops but does not startup due to the config file being empty. Let me know if you need more info.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 15, 2006

CUPS.org User: rojon

I've applied the two patches mention in your post mike, but that doesn't resolve the problem. My system is linux with kernel 2.4.33.3 and gcc 2.95 and glibc-2.2.5.
The described issue shows up when I click on "Change Settings" button on the main admin page and also in the "Edit Configuration File" Page when I submit any changes.
It's exactly as jewilla describes in her/his mail

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: mike

What browser are you using?

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: rojon

Mozilla Firefox/1.5.0.6

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: twaugh.redhat

I see this too, with 1.2.3 and also with current SVN.

It also happens with a program I am using which uses the CUPS API (in particular, _cupsAdminSetServerSettings()), so I don't think this is to do with which browser is used.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: mike

Please try the attached patch and let me know if you still experience problems...

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: rojon

After applying the above patch at least a new cupsd.conf gets written in the appropiate location, but anyhow, cupsd doesn't keep running and have to started manually again. But the cupsd.conf looks (and is at least) usable.

Other Caveats: my Directives Listen 0.0.0.0:631 Listen /var/run/cups/cups.sock gets overwritten with a simple Port 631 command, which is basically the same, accept that 0.0.0.0:631 only listen on ipv4 connections and port 631 also enable listening on ipv6.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: rojon

error_log says_
I [16/Sep/2006:22:36:30 +0200] Saving remote.cache...
I [16/Sep/2006:22:36:30 +0200] Listening to :::631 (IPv6)
I [16/Sep/2006:22:36:30 +0200] Listening to 0.0.0.0:631 (IPv4)
I [16/Sep/2006:22:36:30 +0200] Listening to /var/run/cups/cups.sock (Domain)
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName lp" directive is deprecated; consider using "Require @lp" on line 26.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName bin" directive is deprecated; consider using "Require @bin" on line 27.
W [16/Sep/2006:22:36:30 +0200] "AuthClass Group" is deprecated; consider using "Require @groupName" on line 29.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName bin" directive is deprecated; consider using "Require @bin" on line 35.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName lp" directive is deprecated; consider using "Require @lp" on line 36.
W [16/Sep/2006:22:36:30 +0200] "AuthClass Group" is deprecated; consider using "Require @groupName" on line 38.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName bin" directive is deprecated; consider using "Require @bin" on line 44.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName lp" directive is deprecated; consider using "Require @lp" on line 45.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName root" directive is deprecated; consider using "Require @root" on line 46.
W [16/Sep/2006:22:36:30 +0200] "AuthClass Group" is deprecated; consider using "Require @groupName" on line 48.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName bin" directive is deprecated; consider using "Require @bin" on line 54.
W [16/Sep/2006:22:36:30 +0200] "AuthGroupName root" directive is deprecated; consider using "Require @root" on line 55.
W [16/Sep/2006:22:36:30 +0200] "AuthClass Group" is deprecated; consider using "Require @groupName" on line 57.
I [16/Sep/2006:22:36:30 +0200] Loaded configuration file "/etc/cups/cupsd.conf"
I [16/Sep/2006:22:36:30 +0200] Using default TempDir of /var/spool/cups/tmp...
I [16/Sep/2006:22:36:30 +0200] Cleaning out old temporary files in "/var/spool/cups/tmp"...
I [16/Sep/2006:22:36:30 +0200] Configured for up to 100 clients.
I [16/Sep/2006:22:36:30 +0200] Allowing up to 100 client connections per host.
I [16/Sep/2006:22:36:30 +0200] Using policy "default" as the default!

but cupsd is already dead

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: mike

Run cupsd from the debugger with:

run -f -c /etc/cups/cupsd.conf

Then let me know where cupsd is crashing after the restart.

Also, please open a separate STR for the "Listen 0.0.0.0:631" getting mapped to "Port 631".

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 16, 2006

CUPS.org User: rojon

Find output from gdb below ....
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 1395)]
cupsdFindPolicyOp (p=0x809f048, op=IPP_PRINT_JOB) at policy.c:311
311 if ((*po)->op == op)

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 17, 2006

CUPS.org User: twaugh.redhat

With that patch I found I couldn't authenticate using Firefox. When running the program I have which uses the CUPS API, as root, the cupsd.conf is altered as noted above (with 'Port' instead of 'Listen') and cupsd no longer restarts:

I [17/Sep/2006:11:49:10 +0100] Full reload complete.
E [17/Sep/2006:11:49:10 +0100] Unable to bind socket for address :::631 - Address already in use.
E [17/Sep/2006:11:49:10 +0100] Unable to bind socket for address 0.0.0.0:631 - Address already in use.
I [17/Sep/2006:11:49:10 +0100] Listening to /var/run/cups/cups.sock on fd 3...
E [17/Sep/2006:11:49:10 +0100] cupsdStartBrowsing: Unable to bind broadcast socket - Address already in use.
I [17/Sep/2006:11:50:18 +0100] Listening to 127.0.0.1:631 (IPv4)
I [17/Sep/2006:11:50:18 +0100] Listening to ::1:631 (IPv6)
I [17/Sep/2006:11:50:18 +0100] Listening to /var/run/cups/cups.sock (Domain)
I [17/Sep/2006:11:50:18 +0100] Loaded configuration file "/etc/cups/cupsd.conf"
I [17/Sep/2006:11:50:18 +0100] Using default TempDir of /var/spool/cups/tmp...
I [17/Sep/2006:11:50:18 +0100] Cleaning out old temporary files in "/var/spool/cups/tmp"...
I [17/Sep/2006:11:50:18 +0100] Configured for up to 100 clients.
I [17/Sep/2006:11:50:18 +0100] Allowing up to 100 client connections per host.
I [17/Sep/2006:11:50:18 +0100] Using policy "default" as the default!
I [17/Sep/2006:11:50:18 +0100] Full reload is required.
I [17/Sep/2006:11:50:18 +0100] Loaded MIME database from '/etc/cups': 34 types,
38 filters...
I [17/Sep/2006:11:50:18 +0100] Loading NextJobId from job cache file "/var/cache/cups/job.cache"...
I [17/Sep/2006:11:50:18 +0100] Full reload complete.
E [17/Sep/2006:11:50:18 +0100] Unable to bind socket for address 127.0.0.1:631 - Address already in use.
E [17/Sep/2006:11:50:18 +0100] Unable to bind socket for address ::1:631 - Address already in use.
I [17/Sep/2006:11:50:18 +0100] Listening to /var/run/cups/cups.sock on fd 3...
E [17/Sep/2006:11:50:18 +0100] cupsdStartBrowsing: Unable to bind broadcast socket - Address already in use.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 18, 2006

CUPS.org User: twaugh.redhat

Mike, can you reproduce this problem? I see exactly the same symptoms here, right down to the cupsd crash site:

311 if ((*po)->op == op)
(gdb) p *p
$6 = {name = 0x9606860 "@System", num_ops = 41, ops = 0x18}

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 19, 2006

CUPS.org User: mike

The attached patch should fix the crash bug, but I'm still seeing a hang after the restart. Still looking into it...

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 19, 2006

CUPS.org User: mike

OK, after a "make clean" the problem seems to have gone away.

Can you test the current SVN code and let me know if things are back to normal?

Thanks!

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 19, 2006

CUPS.org User: rojon

I've tested your patch and it works perfectly for me.
Also teh Server restarts without hanging.
Thanks

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 20, 2006

CUPS.org User: mike

Fixed in Subversion repository.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 20, 2006

"str1976.patch":

Index: cups/http.c

--- cups/http.c (revision 5959)
+++ cups/http.c (working copy)
@@ -222,7 +222,10 @@
if (http)
{
memset(http->fields, 0, sizeof(http->fields));

  • httpSetField(http, HTTP_FIELD_HOST, http->hostname);

  • if (http->hostname[0] == '/')

  •  httpSetField(http, HTTP_FIELD_HOST, "localhost");
    
  • else

  •  httpSetField(http, HTTP_FIELD_HOST, http->hostname);
    

    http->expect = (http_status_t)0;
    }

    Index: cups/auth.c

    --- cups/auth.c (revision 5959)
    +++ cups/auth.c (working copy)
    @@ -81,6 +81,8 @@
    http, method, resource));
    DEBUG_printf(("cupsDoAuthentication: digest_tries=%d, userpass="%s"\n",
    http->digest_tries, http->userpass));

  • DEBUG_printf(("cupsDoAuthentication: WWW-Authenticate="%s"\n",

  •            httpGetField(http, HTTP_FIELD_WWW_AUTHENTICATE)));
    

    /*

    • Clear the current authentication string...
      Index: scheduler/client.c

      --- scheduler/client.c (revision 5959)
      +++ scheduler/client.c (working copy)
      @@ -2130,28 +2130,23 @@
    • Send the HTTP status header...
      */

- httpFlushWrite(HTTP(con));

- con->http.data_encoding = HTTP_ENCODE_FIELDS;

  • if (httpPrintf(HTTP(con), "HTTP/%d.%d %d %s\r\n", con->http.version / 100,
  •             con->http.version % 100, code, httpStatus(code)) < 0)
    

- return (0);

if (code == HTTP_CONTINUE)
{
/*
* 100-continue doesn't send any headers...
*/

  • if (httpPrintf(HTTP(con), "\r\n") < 0)

  •  return (0);
    
  • else if (cupsdFlushHeader(con) < 0)

  •  return (0);
    
  • else

  •  return (1);
    
  • return (httpPrintf(HTTP(con), "HTTP/%d.%d 100 Continue\r\n\r\n",

  •          con->http.version / 100, con->http.version % 100) > 0);
    

    }

  • httpFlushWrite(HTTP(con));

  • con->http.data_encoding = HTTP_ENCODE_FIELDS;
  • if (httpPrintf(HTTP(con), "HTTP/%d.%d %d %s\r\n", con->http.version / 100,
  •             con->http.version % 100, code, httpStatus(code)) < 0)
    
  • return (0);
    if (httpPrintf(HTTP(con), "Date: %s\r\n", httpGetDateString(time(NULL))) < 0)
    return (0);
    if (ServerHeader)
@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

commented Sep 20, 2006

"str1976p2.patch":

Index: Dependencies

--- Dependencies (revision 5963)
+++ Dependencies (working copy)
@@ -178,11 +178,11 @@
type.o: ../cups/string.h ../config.h mime.h ../cups/array.h ../cups/ipp.h
type.o: ../cups/file.h ../cups/debug.h
cups-deviced.o: util.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
-cups-deviced.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
+cups-deviced.o: ../cups/ppd.h ../cups/array.h ../cups/file.h
cups-deviced.o: ../cups/language.h ../cups/file.h ../cups/string.h
cups-deviced.o: ../config.h ../cups/array.h ../cups/dir.h
cups-driverd.o: util.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
-cups-driverd.o: ../cups/md5.h ../cups/ppd.h ../cups/array.h ../cups/file.h
+cups-driverd.o: ../cups/ppd.h ../cups/array.h ../cups/file.h
cups-driverd.o: ../cups/language.h ../cups/file.h ../cups/string.h
cups-driverd.o: ../config.h ../cups/dir.h ../cups/transcode.h
cups-lpd.o: ../cups/http-private.h ../config.h ../cups/http.h ../cups/md5.h
@@ -193,17 +193,20 @@
cups-polld.o: ../cups/ipp-private.h ../cups/ipp.h ../cups/cups.h
cups-polld.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
cups-polld.o: ../cups/language.h ../cups/string.h
-testdirsvc.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-testdirsvc.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
+testdirsvc.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+testdirsvc.o: ../cups/array.h ../cups/file.h ../cups/language.h
testdirsvc.o: ../cups/string.h ../config.h
-testlpd.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-testlpd.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
-testlpd.o: ../cups/string.h ../config.h
+testlpd.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+testlpd.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/string.h
+testlpd.o: ../config.h
testmime.o: ../cups/string.h ../config.h mime.h ../cups/array.h ../cups/ipp.h
testmime.o: ../cups/file.h ../cups/dir.h
-testspeed.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-testspeed.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
+testspeed.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+testspeed.o: ../cups/array.h ../cups/file.h ../cups/language.h
testspeed.o: ../cups/language.h ../cups/debug.h
-util.o: util.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/md5.h
-util.o: ../cups/ppd.h ../cups/array.h ../cups/file.h ../cups/language.h
-util.o: ../cups/file.h ../cups/string.h ../config.h
+testsub.o: ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+testsub.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/debug.h
+testsub.o: ../cups/string.h ../config.h
+util.o: util.h ../cups/cups.h ../cups/ipp.h ../cups/http.h ../cups/ppd.h
+util.o: ../cups/array.h ../cups/file.h ../cups/language.h ../cups/file.h
+util.o: ../cups/string.h ../config.h

Index: printers.c

--- printers.c (revision 5963)
+++ printers.c (working copy)
@@ -2407,6 +2407,10 @@
p;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
{

  • /*
  • * Remove remote printers if we are no longer browsing...
  • */

if (!Browsing && (p->type & (CUPS_PRINTER_IMPLICIT | CUPS_PRINTER_REMOTE)))
{
if (p->type & CUPS_PRINTER_IMPLICIT)
@@ -2417,8 +2421,6 @@
cupsArrayRestore(Printers);
continue;
}

  • else if (!(p->type & CUPS_PRINTER_REMOTE))

  •  cupsdSetPrinterAttrs(p);
    

    /*

    • Update the operation policy pointer...
      @@ -2426,6 +2428,13 @@

      if ((p->op_policy_ptr = cupsdFindPolicy(p->op_policy)) == NULL)
      p->op_policy_ptr = DefaultPolicyPtr;
      +

  • /*

  • * Update printer attributes as needed...

  • */

  • if (!(p->type & CUPS_PRINTER_REMOTE))
  •  cupsdSetPrinterAttrs(p);
    
    }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.