summaryrefslogtreecommitdiff
path: root/scheduler
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2021-04-05 15:57:50 -0400
committerMichael R Sweet <michael.r.sweet@gmail.com>2021-04-05 15:57:50 -0400
commit064e50fb06e83e6c1756e2a81c2fcbd4d6fca8e6 (patch)
tree45145c8db9a634af861cb1ed87a7378837e72763 /scheduler
parent6918883fba4942931dc455b32545d6edf18dec5c (diff)
downloadcups-064e50fb06e83e6c1756e2a81c2fcbd4d6fca8e6.tar.gz
Import all of the bug fixes from the OpenPrinting CUPS repository.
Import the improvements to ippeveprinter from OpenPrinting/ippsample. Import the improvements to ippfind and ipptool from OpenPrinting/ippsample.
Diffstat (limited to 'scheduler')
-rw-r--r--scheduler/classes.c2
-rw-r--r--scheduler/client.c50
-rw-r--r--scheduler/cups-deviced.c2
-rw-r--r--scheduler/cups-lpd.c2
-rw-r--r--scheduler/ipp.c22
-rw-r--r--scheduler/job.c10
-rw-r--r--scheduler/listen.c2
-rw-r--r--scheduler/main.c2
-rw-r--r--scheduler/printers.c10
-rw-r--r--scheduler/subscriptions.c2
10 files changed, 48 insertions, 56 deletions
diff --git a/scheduler/classes.c b/scheduler/classes.c
index 14d2558bf..35d0eb77d 100644
--- a/scheduler/classes.c
+++ b/scheduler/classes.c
@@ -688,7 +688,7 @@ cupsdSaveAllClasses(void)
strftime(temp, sizeof(temp) - 1, "%Y-%m-%d %H:%M", &curdate);
cupsFilePuts(fp, "# Class configuration file for " CUPS_SVERSION "\n");
- cupsFilePrintf(fp, "# Written by cupsd on %s\n", temp);
+ cupsFilePrintf(fp, "# Written by cupsd\n");
cupsFilePuts(fp, "# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING\n");
/*
diff --git a/scheduler/client.c b/scheduler/client.c
index c2ee8f12a..479b70aed 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -2109,18 +2109,13 @@ cupsdSendHeader(
}
else if (auth_type == CUPSD_AUTH_NEGOTIATE)
{
-#if defined(SO_PEERCRED) && defined(AF_LOCAL)
- if (httpAddrFamily(httpGetAddress(con->http)) == AF_LOCAL)
- strlcpy(auth_str, "PeerCred", sizeof(auth_str));
- else
-#endif /* SO_PEERCRED && AF_LOCAL */
strlcpy(auth_str, "Negotiate", sizeof(auth_str));
}
- if (con->best && auth_type != CUPSD_AUTH_NEGOTIATE && !con->is_browser && !_cups_strcasecmp(httpGetHostname(con->http, NULL, 0), "localhost"))
+ if (con->best && !con->is_browser && !_cups_strcasecmp(httpGetHostname(con->http, NULL, 0), "localhost"))
{
/*
- * Add a "trc" (try root certification) parameter for local non-Kerberos
+ * Add a "trc" (try root certification) parameter for local
* requests when the request requires system group membership - then the
* client knows the root certificate can/should be used.
*
@@ -2789,6 +2784,25 @@ get_file(cupsd_client_t *con, /* I - Client connection */
perm_check = 0;
}
+ else if (!strcmp(con->uri, "/admin/conf/cupsd.conf"))
+ {
+ strlcpy(filename, ConfigurationFile, len);
+
+ perm_check = 0;
+ }
+ else if (!strncmp(con->uri, "/admin/log/", 11))
+ {
+ if (!strncmp(con->uri + 11, "access_log", 10) && AccessLog[0] == '/')
+ strlcpy(filename, AccessLog, len);
+ else if (!strncmp(con->uri + 11, "error_log", 9) && ErrorLog[0] == '/')
+ strlcpy(filename, ErrorLog, len);
+ else if (!strncmp(con->uri + 11, "page_log", 8) && PageLog[0] == '/')
+ strlcpy(filename, PageLog, len);
+ else
+ return (NULL);
+
+ 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))
{
/*
@@ -2822,25 +2836,6 @@ get_file(cupsd_client_t *con, /* I - Client connection */
perm_check = 0;
}
- else if (!strcmp(con->uri, "/admin/conf/cupsd.conf"))
- {
- strlcpy(filename, ConfigurationFile, len);
-
- perm_check = 0;
- }
- else if (!strncmp(con->uri, "/admin/log/", 11))
- {
- if (!strncmp(con->uri + 11, "access_log", 10) && AccessLog[0] == '/')
- strlcpy(filename, AccessLog, len);
- else if (!strncmp(con->uri + 11, "error_log", 9) && ErrorLog[0] == '/')
- strlcpy(filename, ErrorLog, len);
- else if (!strncmp(con->uri + 11, "page_log", 8) && PageLog[0] == '/')
- strlcpy(filename, PageLog, len);
- else
- return (NULL);
-
- perm_check = 0;
- }
else if (con->language)
{
snprintf(language, sizeof(language), "/%s", con->language->language);
@@ -3471,8 +3466,7 @@ pipe_command(cupsd_client_t *con, /* I - Client connection */
}
else
{
- sprintf(content_length, "CONTENT_LENGTH=" CUPS_LLFMT,
- CUPS_LLCAST con->bytes);
+ snprintf(content_length, sizeof(content_length), "CONTENT_LENGTH=" CUPS_LLFMT, CUPS_LLCAST con->bytes);
snprintf(content_type, sizeof(content_type), "CONTENT_TYPE=%s",
httpGetField(con->http, HTTP_FIELD_CONTENT_TYPE));
diff --git a/scheduler/cups-deviced.c b/scheduler/cups-deviced.c
index 77703b983..14478fd99 100644
--- a/scheduler/cups-deviced.c
+++ b/scheduler/cups-deviced.c
@@ -265,7 +265,7 @@ main(int argc, /* I - Number of command-line args */
* all others run as the unprivileged user...
*/
- start_backend(dent->filename, !(dent->fileinfo.st_mode & (S_IWGRP | S_IRWXO)));
+ start_backend(dent->filename, !(dent->fileinfo.st_mode & (S_IWGRP | S_IWOTH | S_IXOTH)));
}
cupsDirClose(dir);
diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c
index 0da3d0c06..7b1dc4834 100644
--- a/scheduler/cups-lpd.c
+++ b/scheduler/cups-lpd.c
@@ -1268,7 +1268,7 @@ remove_jobs(const char *dest, /* I - Destination */
request = ippNewRequest(IPP_OP_CANCEL_JOB);
- sprintf(uri, "ipp://localhost/jobs/%d", id);
+ snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", id);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 2fe3bf25c..191844117 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -880,7 +880,7 @@ add_class(cupsd_client_t *con, /* I - Client connection */
* Class doesn't exist; see if we have a printer of the same name...
*/
- if ((pclass = cupsdFindPrinter(resource + 9)) != NULL)
+ if (cupsdFindPrinter(resource + 9))
{
/*
* Yes, return an error...
@@ -2273,7 +2273,7 @@ add_printer(cupsd_client_t *con, /* I - Client connection */
* Printer doesn't exist; see if we have a class of the same name...
*/
- if ((printer = cupsdFindClass(resource + 10)) != NULL)
+ if (cupsdFindClass(resource + 10))
{
/*
* Yes, return an error...
@@ -4891,7 +4891,7 @@ copy_printer_attrs(
}
if (printer->alert && (!ra || cupsArrayFind(ra, "printer-alert")))
- ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_STRING, "printer-alert", NULL, printer->alert);
+ ippAddOctetString(con->response, IPP_TAG_PRINTER, "printer-alert", printer->alert, (int)strlen(printer->alert));
if (printer->alert_description && (!ra || cupsArrayFind(ra, "printer-alert-description")))
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-alert-description", NULL, printer->alert_description);
@@ -5016,6 +5016,9 @@ copy_printer_attrs(
if (!ra || cupsArrayFind(ra, "queued-job-count"))
add_queued_job_count(con, printer);
+ if (!ra || cupsArrayFind(ra, "uri-security-supported"))
+ ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_KEYWORD, "uri-security-supported", NULL, is_encrypted ? "tls" : "none");
+
copy_attrs(con->response, printer->attrs, ra, IPP_TAG_ZERO, 0, NULL);
if (printer->ppd_attrs)
copy_attrs(con->response, printer->ppd_attrs, ra, IPP_TAG_ZERO, 0, NULL);
@@ -10866,17 +10869,13 @@ set_printer_defaults(
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- sprintf(value, "%d", attr->values[0].integer);
- printer->num_options = cupsAddOption(name, value,
- printer->num_options,
- &(printer->options));
+ printer->num_options = cupsAddIntegerOption(name, attr->values[0].integer, printer->num_options, &(printer->options));
cupsdLogMessage(CUPSD_LOG_DEBUG,
"Setting %s to %s...", attr->name, value);
break;
case IPP_TAG_RANGE :
- sprintf(value, "%d-%d", attr->values[0].range.lower,
- attr->values[0].range.upper);
+ snprintf(value, sizeof(value), "%d-%d", attr->values[0].range.lower, attr->values[0].range.upper);
printer->num_options = cupsAddOption(name, value,
printer->num_options,
&(printer->options));
@@ -10885,10 +10884,7 @@ set_printer_defaults(
break;
case IPP_TAG_RESOLUTION :
- sprintf(value, "%dx%d%s", attr->values[0].resolution.xres,
- attr->values[0].resolution.yres,
- attr->values[0].resolution.units == IPP_RES_PER_INCH ?
- "dpi" : "dpcm");
+ snprintf(value, sizeof(value), "%dx%d%s", attr->values[0].resolution.xres, attr->values[0].resolution.yres, attr->values[0].resolution.units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
printer->num_options = cupsAddOption(name, value,
printer->num_options,
&(printer->options));
diff --git a/scheduler/job.c b/scheduler/job.c
index e20e7c563..a1af0603f 100644
--- a/scheduler/job.c
+++ b/scheduler/job.c
@@ -893,7 +893,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
goto abort_job;
}
- sprintf(jobid, "%d", job->id);
+ snprintf(jobid, sizeof(jobid), "%d", job->id);
argv[0] = job->printer->name;
argv[1] = jobid;
@@ -1247,7 +1247,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
else if (stat(command, &backinfo))
backroot = 0;
else
- backroot = !(backinfo.st_mode & (S_IWGRP | S_IRWXO));
+ backroot = !(backinfo.st_mode & (S_IWGRP | S_IWOTH | S_IXOTH));
argv[0] = job->printer->sanitized_device_uri;
@@ -2201,7 +2201,7 @@ cupsdSaveAllJobs(void)
strftime(temp, sizeof(temp) - 1, "%Y-%m-%d %H:%M", &curdate);
cupsFilePuts(fp, "# Job cache file for " CUPS_SVERSION "\n");
- cupsFilePrintf(fp, "# Written by cupsd on %s\n", temp);
+ cupsFilePrintf(fp, "# Written by cupsd\n");
cupsFilePrintf(fp, "NextJobId %d\n", NextJobId);
/*
@@ -2625,7 +2625,7 @@ cupsdSetJobState(
else
cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, "%s", buffer);
- if (newstate == IPP_JOB_STOPPED || newstate == IPP_JOB_ABORTED || newstate == IPP_JOB_HELD)
+ if (newstate == IPP_JOB_STOPPED || newstate == IPP_JOB_ABORTED)
cupsdLogJob(job, CUPSD_LOG_ERROR, "%s", buffer);
else
cupsdLogJob(job, CUPSD_LOG_INFO, "%s", buffer);
@@ -3229,7 +3229,7 @@ finalize_job(cupsd_job_t *job, /* I - Job */
exit_code = job->status;
}
- cupsdLogJob(job, CUPSD_LOG_INFO, "Backend returned status %d (%s)",
+ cupsdLogJob(job, CUPSD_LOG_WARN, "Backend returned status %d (%s)",
exit_code,
exit_code == CUPS_BACKEND_FAILED ? "failed" :
exit_code == CUPS_BACKEND_AUTH_REQUIRED ?
diff --git a/scheduler/listen.c b/scheduler/listen.c
index 92c7c626b..dbf959b25 100644
--- a/scheduler/listen.c
+++ b/scheduler/listen.c
@@ -160,7 +160,7 @@ cupsdStartListening(void)
if (lis->fd == -1)
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
+ cupsdLogMessage(errno == EAFNOSUPPORT ? CUPSD_LOG_INFO : CUPSD_LOG_ERROR,
"Unable to open listen socket for address %s:%d - %s.",
s, p, strerror(errno));
diff --git a/scheduler/main.c b/scheduler/main.c
index d5fdf971a..bd6080a50 100644
--- a/scheduler/main.c
+++ b/scheduler/main.c
@@ -581,7 +581,7 @@ main(int argc, /* I - Number of command-line args */
* Clean out old temp files and printer cache data.
*/
- if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot)))
+ if (!RequestRoot || !strncmp(TempDir, RequestRoot, strlen(RequestRoot)))
cupsdCleanFiles(TempDir, NULL);
cupsdCleanFiles(CacheDir, "*.ipp");
diff --git a/scheduler/printers.c b/scheduler/printers.c
index 432e87dc5..09ffb83bb 100644
--- a/scheduler/printers.c
+++ b/scheduler/printers.c
@@ -822,12 +822,15 @@ cupsdDeletePrinter(
ippDelete(p->attrs);
ippDelete(p->ppd_attrs);
+ _ppdCacheDestroy(p->pc);
+
mimeDeleteType(MimeDatabase, p->filetype);
mimeDeleteType(MimeDatabase, p->prefiltertype);
cupsdFreeStrings(&(p->users));
cupsdFreeQuotas(p);
+ cupsdClearString(&p->uuid);
cupsdClearString(&p->uri);
cupsdClearString(&p->hostname);
cupsdClearString(&p->name);
@@ -1503,7 +1506,7 @@ cupsdSaveAllPrinters(void)
strftime(temp, sizeof(temp) - 1, "%Y-%m-%d %H:%M", &curdate);
cupsFilePuts(fp, "# Printer configuration file for " CUPS_SVERSION "\n");
- cupsFilePrintf(fp, "# Written by cupsd on %s\n", temp);
+ cupsFilePrintf(fp, "# Written by cupsd\n");
cupsFilePuts(fp, "# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING\n");
cupsFilePrintf(fp, "NextPrinterId %d\n", NextPrinterId);
@@ -2316,8 +2319,6 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"uri-authentication-supported", NULL, auth_supported);
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "uri-security-supported", NULL, "none");
if (p->printer_id)
ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "printer-id", p->printer_id);
ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME, "printer-name", NULL,
@@ -4016,7 +4017,8 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
num_qualities = 0;
- if ((output_mode = ppdFindOption(ppd, "OutputMode")) != NULL)
+ if ((output_mode = ppdFindOption(ppd, "OutputMode")) ||
+ (output_mode = ppdFindOption(ppd, "cupsPrintQuality")))
{
if (ppdFindChoice(output_mode, "draft") ||
ppdFindChoice(output_mode, "fast"))
diff --git a/scheduler/subscriptions.c b/scheduler/subscriptions.c
index 15acedca8..eca0bfa19 100644
--- a/scheduler/subscriptions.c
+++ b/scheduler/subscriptions.c
@@ -1051,7 +1051,7 @@ cupsdSaveAllSubscriptions(void)
strftime(temp, sizeof(temp) - 1, "%Y-%m-%d %H:%M", &curdate);
cupsFilePuts(fp, "# Subscription configuration file for " CUPS_SVERSION "\n");
- cupsFilePrintf(fp, "# Written by cupsd on %s\n", temp);
+ cupsFilePrintf(fp, "# Written by cupsd\n");
cupsFilePrintf(fp, "NextSubscriptionId %d\n", NextSubscriptionId);