Skip to content

Commit

Permalink
Fix handling of printer resource files (Issue #5652)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Oct 2, 2019
1 parent 3ba95ec commit eff8c82
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHANGES - 2.3.1 - 2019-09-05
CHANGES - 2.3.1 - 2019-10-02
============================


Expand All @@ -8,6 +8,7 @@ Changes in CUPS v2.3.1
- Added a workaround for the scheduler's systemd support (Issue #5640)
- Fixed spelling of "fold-accordion".
- Fixed the default common name for TLS certificates used by `ippeveprinter`.
- Fixed a bug in the handling of printer resource files (Issue #5652)


Changes in CUPS v2.3.0
Expand Down
33 changes: 23 additions & 10 deletions scheduler/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
}
}
}
else if (!strncmp(con->uri, "/admin", 6) || !strncmp(con->uri, "/printers", 9) || !strncmp(con->uri, "/classes", 8) || !strncmp(con->uri, "/help", 5) || !strncmp(con->uri, "/jobs", 5))
else if (!buf[0] && (!strncmp(con->uri, "/admin", 6) || !strncmp(con->uri, "/classes", 8) || !strncmp(con->uri, "/help", 5) || !strncmp(con->uri, "/jobs", 5) || !strncmp(con->uri, "/printers", 9)))
{
if (!WebInterface)
{
Expand All @@ -1125,14 +1125,6 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
cupsdSetStringf(&con->command, "%s/cgi-bin/admin.cgi", ServerBin);
cupsdSetString(&con->options, strchr(con->uri + 6, '?'));
}
else if (!strncmp(con->uri, "/printers", 9))
{
cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
if (con->uri[9] && con->uri[10])
cupsdSetString(&con->options, con->uri + 9);
else
cupsdSetString(&con->options, NULL);
}
else if (!strncmp(con->uri, "/classes", 8))
{
cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin);
Expand All @@ -1149,6 +1141,14 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
else
cupsdSetString(&con->options, NULL);
}
else if (!strncmp(con->uri, "/printers", 9))
{
cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin);
if (con->uri[9] && con->uri[10])
cupsdSetString(&con->options, con->uri + 9);
else
cupsdSetString(&con->options, NULL);
}
else
{
cupsdSetStringf(&con->command, "%s/cgi-bin/help.cgi", ServerBin);
Expand Down Expand Up @@ -1458,7 +1458,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
break;
}

if (!strncmp(con->uri, "/admin", 6) || !strncmp(con->uri, "/printers", 9) || !strncmp(con->uri, "/classes", 8) || !strncmp(con->uri, "/help", 5) || !strncmp(con->uri, "/jobs", 5))
if (!buf[0] && (!strncmp(con->uri, "/admin", 6) || !strncmp(con->uri, "/classes", 8) || !strncmp(con->uri, "/help", 5) || !strncmp(con->uri, "/jobs", 5) || !strncmp(con->uri, "/printers", 9)))
{
/*
* CGI output...
Expand Down Expand Up @@ -2701,6 +2701,7 @@ get_file(cupsd_client_t *con, /* I - Client connection */
* Figure out the real filename...
*/

filename[0] = '\0';
language[0] = '\0';

if (!strncmp(con->uri, "/help", 5) && (con->uri[5] == '/' || !con->uri[5]))
Expand All @@ -2718,6 +2719,7 @@ get_file(cupsd_client_t *con, /* I - Client connection */

if ((p = cupsdFindDest(dest)) == NULL)
{
strlcpy(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No destination \"%s\" found.", dest);
return (NULL);
}
Expand Down Expand Up @@ -2754,6 +2756,7 @@ get_file(cupsd_client_t *con, /* I - Client connection */

if ((p = cupsdFindDest(dest)) == NULL)
{
strlcpy(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No destination \"%s\" found.", dest);
return (NULL);
}
Expand Down Expand Up @@ -2786,6 +2789,14 @@ get_file(cupsd_client_t *con, /* I - Client connection */

perm_check = 0;
}
else if (!strncmp(con->uri, "/admin", 6) || !strncmp(con->uri, "/classes", 8) || !strncmp(con->uri, "/jobs", 5) || !strncmp(con->uri, "/printers", 9))
{
/*
* Admin/class/job/printer pages are served by CGI...
*/

return (NULL);
}
else if (!strncmp(con->uri, "/rss/", 5) && !strchr(con->uri + 5, '/'))
snprintf(filename, len, "%s/rss/%s", CacheDir, con->uri + 5);
else if (!strncmp(con->uri, "/strings/", 9) && !strcmp(con->uri + strlen(con->uri) - 8, ".strings"))
Expand All @@ -2795,12 +2806,14 @@ get_file(cupsd_client_t *con, /* I - Client connection */

if ((p = cupsdFindDest(dest)) == NULL)
{
strlcpy(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No destination \"%s\" found.", dest);
return (NULL);
}

if (!p->strings)
{
strlcpy(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No strings files for \"%s\".", dest);
return (NULL);
}
Expand Down

0 comments on commit eff8c82

Please sign in to comment.