/*
- * "$Id: ipp.c 6145 2006-12-06 20:10:16Z mike $"
+ * "$Id: ipp.c 6318 2007-03-06 04:36:55Z mike $"
*
* IPP routines for the Common UNIX Printing System (CUPS) scheduler.
*
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ *
+ * This file contains Kerberos support code, copyright 2006 by
+ * Jelmer Vernooij.
*
* These coded instructions, statements, and computer programs are the
* property of Easy Software Products and are protected by Federal
* release_job() - Release a held print job.
* restart_job() - Restart an old print job.
* save_auth_info() - Save authentication information for a job.
+ * save_krb5_creds() - Save Kerberos credentials for a job.
* send_document() - Send a file to a printer or class.
* send_http_error() - Send a HTTP error back to the IPP client.
* send_ipp_status() - Send a status back to the IPP client.
#include "cupsd.h"
+#ifdef HAVE_KRB5_H
+# include <krb5.h>
+#endif /* HAVE_KRB5_H */
+
#ifdef HAVE_LIBPAPER
# include <paper.h>
#endif /* HAVE_LIBPAPER */
static void add_class(cupsd_client_t *con, ipp_attribute_t *uri);
static int add_file(cupsd_client_t *con, cupsd_job_t *job,
mime_type_t *filetype, int compression);
-static cupsd_job_t *add_job(cupsd_client_t *con, ipp_attribute_t *uri,
- cupsd_printer_t **dprinter,
+static cupsd_job_t *add_job(cupsd_client_t *con, cupsd_printer_t *printer,
mime_type_t *filetype);
static void add_job_state_reasons(cupsd_client_t *con, cupsd_job_t *job);
static void add_job_subscriptions(cupsd_client_t *con, cupsd_job_t *job);
static void release_job(cupsd_client_t *con, ipp_attribute_t *uri);
static void renew_subscription(cupsd_client_t *con, int sub_id);
static void restart_job(cupsd_client_t *con, ipp_attribute_t *uri);
-static void save_auth_info(cupsd_client_t *con, cupsd_job_t *job);
+static void save_auth_info(cupsd_client_t *con, cupsd_job_t *job,
+ ipp_attribute_t *auth_info);
+#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5_H)
+static void save_krb5_creds(cupsd_client_t *con, cupsd_job_t *job);
+#endif /* HAVE_GSSAPI && HAVE_KRB5_H */
static void send_document(cupsd_client_t *con, ipp_attribute_t *uri);
static void send_http_error(cupsd_client_t *con, http_status_t status);
static void send_ipp_status(cupsd_client_t *con, ipp_status_t status,
/*
* Then validate the request header and required attributes...
*/
-
+
if (con->request->request.any.version[0] != 1)
{
/*
_("Bad request version number %d.%d!"),
con->request->request.any.version[0],
con->request->request.any.version[1]);
- }
+ }
else if (!con->request->attrs)
{
cupsdAddEvent(CUPSD_EVENT_SERVER_AUDIT, NULL, NULL,
cupsdLogMessage(CUPSD_LOG_DEBUG, "Request attributes follow...");
for (attr = con->request->attrs; attr; attr = attr->next)
- cupsdLogMessage(CUPSD_LOG_DEBUG,
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
"attr \"%s\": group_tag = %x, value_tag = %x",
attr->name ? attr->name : "(null)", attr->group_tag,
attr->value_tag);
con->http.data_remaining = length;
}
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdProcessIPPRequest: Adding fd %d to OutputSet...",
- con->http.fd);
-
- FD_SET(con->http.fd, OutputSet);
+ cupsdAddSelect(con->http.fd, (cupsd_selfunc_t)cupsdReadClient,
+ (cupsd_selfunc_t)cupsdWriteClient, con);
/*
* Tell the caller the response header was sent successfully...
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI], /* Method portion of URI */
- username[HTTP_MAX_URI], /* Username portion of URI */
- host[HTTP_MAX_URI], /* Host portion of URI */
- resource[HTTP_MAX_URI]; /* Resource portion of URI */
- int port; /* Port portion of URI */
- const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
cupsdAddPrinterHistory(printer);
if (dtype & CUPS_PRINTER_CLASS)
+ {
cupsdSaveAllClasses();
+
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" now accepting jobs (\"%s\").",
+ printer->name, get_username(con));
+ }
else
+ {
cupsdSaveAllPrinters();
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" now accepting jobs (\"%s\").", name,
- get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" now accepting jobs (\"%s\").",
+ printer->name, get_username(con));
+ }
/*
* Everything was ok, so return OK status...
IPP_TAG_BOOLEAN)) != NULL)
{
if (pclass->shared && !attr->values[0].boolean)
- cupsdSendBrowseDelete(pclass);
+ cupsdDeregisterPrinter(pclass, 1);
cupsdLogMessage(CUPSD_LOG_INFO,
"Setting %s printer-is-shared to %d (was %d.)",
* Search for the printer or class URI...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if (!cupsdValidateDest(host, resource, &dtype, &member))
+ if (!cupsdValidateDest(attr->values[i].string.text, &dtype, &member))
{
/*
* Bad URI...
static cupsd_job_t * /* O - Job object */
add_job(cupsd_client_t *con, /* I - Client connection */
- ipp_attribute_t *uri, /* I - printer-uri */
- cupsd_printer_t **dprinter, /* I - Destination printer */
+ cupsd_printer_t *printer, /* I - Destination printer */
mime_type_t *filetype) /* I - First print file type, if any */
{
http_status_t status; /* Policy status */
- ipp_attribute_t *attr; /* Current attribute */
- const char *dest; /* Destination */
- cups_ptype_t dtype; /* Destination type (printer or class) */
+ ipp_attribute_t *attr, /* Current attribute */
+ *auth_info; /* auth-info attribute */
const char *val; /* Default option value */
int priority; /* Job priority */
char *title; /* Job name/title */
cupsd_job_t *job; /* Current job */
- char job_uri[HTTP_MAX_URI], /* Job URI */
- method[HTTP_MAX_URI], /* Method portion of URI */
- username[HTTP_MAX_URI], /* Username portion of URI */
- host[HTTP_MAX_URI], /* Host portion of URI */
- resource[HTTP_MAX_URI]; /* Resource portion of URI */
- int port; /* Port portion of URI */
- cupsd_printer_t *printer; /* Printer data */
+ char job_uri[HTTP_MAX_URI]; /* Job URI */
int kbytes; /* Size of print file */
int i; /* Looping var */
int lowerpagerange; /* Page range bound */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %s)", con,
- con->http.fd, uri->values[0].string.text);
-
- /*
- * Is the destination valid?
- */
-
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
- {
- /*
- * Bad URI...
- */
-
- send_ipp_status(con, IPP_NOT_FOUND,
- _("The printer or class was not found."));
- return (NULL);
- }
-
- if (dprinter)
- *dprinter = printer;
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job(%p[%d], %p(%s), %p(%s/%s))",
+ con, con->http.fd, printer, printer->name,
+ filetype, filetype->super, filetype->type);
/*
* Check remote printing to non-shared printer...
{
send_ipp_status(con, IPP_NOT_ACCEPTING,
_("Destination \"%s\" is not accepting jobs."),
- dest);
+ printer->name);
return (NULL);
}
/*
* Validate job template attributes; for now just document-format,
- * copies, and page-ranges...
+ * copies, number-up, and page-ranges...
*/
if (filetype && printer->filetypes &&
}
}
+ if ((attr = ippFindAttribute(con->request, "number-up",
+ IPP_TAG_INTEGER)) != NULL)
+ {
+ if (attr->values[0].integer != 1 &&
+ attr->values[0].integer != 2 &&
+ attr->values[0].integer != 4 &&
+ attr->values[0].integer != 6 &&
+ attr->values[0].integer != 9 &&
+ attr->values[0].integer != 16)
+ {
+ send_ipp_status(con, IPP_ATTRIBUTES, _("Bad number-up value %d."),
+ attr->values[0].integer);
+ ippAddInteger(con->response, IPP_TAG_UNSUPPORTED_GROUP, IPP_TAG_INTEGER,
+ "number-up", attr->values[0].integer);
+ return (NULL);
+ }
+ }
+
if ((attr = ippFindAttribute(con->request, "page-ranges",
IPP_TAG_RANGE)) != NULL)
{
for (i = 0, lowerpagerange = 1; i < attr->num_values; i ++)
{
- if (attr->values[i].range.lower < lowerpagerange ||
+ if (attr->values[i].range.lower < lowerpagerange ||
attr->values[i].range.lower > attr->values[i].range.upper)
{
send_ipp_status(con, IPP_BAD_REQUEST,
if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs)
cupsdCleanJobs();
- if (cupsArrayCount(Jobs) >= MaxJobs && MaxJobs)
+ if (MaxJobs && cupsArrayCount(Jobs) >= MaxJobs)
{
send_ipp_status(con, IPP_NOT_POSSIBLE,
_("Too many active jobs."));
if ((job = cupsdAddJob(priority, printer->name)) == NULL)
{
send_ipp_status(con, IPP_INTERNAL_ERROR,
- _("Unable to add job for destination \"%s\"!"), dest);
+ _("Unable to add job for destination \"%s\"!"),
+ printer->name);
return (NULL);
}
- job->dtype = dtype;
+ job->dtype = printer->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT |
+ CUPS_PRINTER_REMOTE);
job->attrs = con->request;
con->request = ippNewRequest(job->attrs->request.op.operation_id);
if (attr)
cupsdSetString(&attr->values[0].string.text, con->username);
-
- save_auth_info(con, job);
}
else if (attr)
{
attr->name = _cupsStrAlloc("job-originating-user-name");
}
+ auth_info = ippFindAttribute(job->attrs, "auth-info", IPP_TAG_TEXT);
+
+ if (con->username[0] || auth_info)
+ {
+ save_auth_info(con, job, auth_info);
+
+ /*
+ * Remove the auth-info attribute from the attribute data...
+ */
+
+ if (auth_info)
+ {
+ if (job->attrs->prev)
+ job->attrs->prev->next = auth_info->next;
+ else
+ job->attrs->attrs = auth_info->next;
+
+ if (job->attrs->last == auth_info)
+ job->attrs->last = job->attrs->prev;
+
+ _ippFreeAttr(auth_info);
+ }
+ }
+
if ((attr = ippFindAttribute(job->attrs, "job-originating-host-name",
IPP_TAG_ZERO)) != NULL)
{
* the connection...
*/
- ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME,
+ ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_NAME,
"job-originating-host-name", NULL, con->http.hostname);
}
IPP_TAG_BOOLEAN)) != NULL)
{
if (printer->shared && !attr->values[0].boolean)
- cupsdSendBrowseDelete(printer);
+ cupsdDeregisterPrinter(printer, 1);
cupsdLogMessage(CUPSD_LOG_INFO,
"Setting %s printer-is-shared to %d (was %d.)",
int i, /* Looping var */
num_options; /* Number of default options */
cups_option_t *options, /* Default options */
- *option; /* Current option */
+ *option; /* Current option */
/*
authenticate_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Job URI */
{
- ipp_attribute_t *attr; /* Job-id attribute */
+ ipp_attribute_t *attr, /* job-id attribute */
+ *auth_info; /* auth-info attribute */
int jobid; /* Job ID */
cupsd_job_t *job; /* Current job */
char method[HTTP_MAX_URI],
httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
sizeof(method), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
-
+
if (strncmp(resource, "/jobs/", 6))
{
/*
* See if we have already authenticated...
*/
- if (!con->username[0])
+ auth_info = ippFindAttribute(con->request, "auth-info", IPP_TAG_TEXT);
+
+ if (!con->username[0] && !auth_info)
{
send_ipp_status(con, IPP_NOT_AUTHORIZED,
_("No authentication information provided!"));
* Save the authentication information for this job...
*/
- save_auth_info(con, job);
+ save_auth_info(con, job, auth_info);
/*
* Reset the job-hold-until value to "no-hold"...
ipp_attribute_t *uri) /* I - Job or Printer URI */
{
http_status_t status; /* Policy status */
- const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type */
- char method[HTTP_MAX_URI], /* Method portion of URI */
+ char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
userpass[HTTP_MAX_URI], /* Username portion of URI */
- host[HTTP_MAX_URI], /* Host portion of URI */
+ hostname[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
ipp_attribute_t *attr; /* Attribute in request */
* And if the destination is valid...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), userpass, sizeof(userpass), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI?
*/
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text,
+ scheme, sizeof(scheme), userpass, sizeof(userpass),
+ hostname, sizeof(hostname), &port,
+ resource, sizeof(resource));
+
if ((!strncmp(resource, "/printers/", 10) && resource[10]) ||
(!strncmp(resource, "/classes/", 9) && resource[9]))
{
_("The printer or class was not found."));
return;
}
- else if (strcmp(resource, "/printers/"))
- {
- send_ipp_status(con, IPP_NOT_FOUND,
- _("The printer-uri \"%s\" is not valid."),
- uri->values[0].string.text);
- return;
- }
/*
* Check policy...
* Check policy...
*/
- if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
+ NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
* Cancel all of the jobs on the named printer...
*/
- cupsdCancelJobs(dest, username, purge);
+ cupsdCancelJobs(printer->name, username, purge);
cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \"%s\" were %s by \"%s\".",
- dest, purge ? "purged" : "canceled", get_username(con));
+ printer->name, purge ? "purged" : "canceled",
+ get_username(con));
}
con->response->request.status.status_code = IPP_OK;
{
ipp_attribute_t *attr; /* Current attribute */
int jobid; /* Job ID */
- char method[HTTP_MAX_URI], /* Method portion of URI */
+ char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
int port; /* Port portion of URI */
cupsd_job_t *job; /* Job information */
- const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
cupsd_printer_t *printer; /* Printer data */
* Find the current job on the specified printer...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
/*
* No, see if there are any pending jobs...
*/
-
+
for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
job;
job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
if (job->state_value <= IPP_JOB_PROCESSING &&
- !strcasecmp(job->dest, dest))
+ !strcasecmp(job->dest, printer->name))
break;
if (job)
else
{
send_ipp_status(con, IPP_NOT_POSSIBLE, _("No active jobs on %s!"),
- dest);
+ printer->name);
return;
}
}
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+ sizeof(scheme), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
-
+
if (strncmp(resource, "/jobs/", 6))
{
/*
const char *from, /* I - Source file */
const char *to) /* I - Destination file */
{
- fd_set *input; /* select() input set */
+ fd_set input; /* select() input set */
struct timeval timeout; /* select() timeout */
int maxfd; /* Maximum file descriptor for select() */
char tempfile[1024]; /* Temporary PPD file */
cupsdOpenPipe(temppipe);
- if ((input = calloc(1, SetSize)) == NULL)
- {
- close(tempfd);
- unlink(tempfile);
-
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "copy_model: Unable to allocate %d bytes for select()...",
- SetSize);
- return (-1);
- }
-
cupsdLogMessage(CUPSD_LOG_DEBUG,
"copy_model: Running \"cups-driverd cat %s\"...", from);
if (!cupsdStartProcess(buffer, argv, envp, -1, temppipe[1], CGIPipes[1],
- -1, 0, &temppid))
+ -1, -1, 0, &temppid))
{
- free(input);
close(tempfd);
unlink(tempfile);
return (-1);
bytes = 0;
- FD_SET(temppipe[0], input);
- FD_SET(CGIPipes[0], input);
+ FD_ZERO(&input);
+ FD_SET(temppipe[0], &input);
+ FD_SET(CGIPipes[0], &input);
timeout.tv_sec = 30;
timeout.tv_usec = 0;
- if ((i = select(maxfd, input, NULL, NULL, &timeout)) < 0)
+ if ((i = select(maxfd, &input, NULL, NULL, &timeout)) < 0)
{
if (errno == EINTR)
continue;
break;
}
- if (FD_ISSET(temppipe[0], input))
+ if (FD_ISSET(temppipe[0], &input))
{
/*
* Read the PPD file from the pipe, and write it to the PPD file.
break;
}
- if (FD_ISSET(CGIPipes[0], input))
+ if (FD_ISSET(CGIPipes[0], &input))
cupsdUpdateCGI();
}
close(temppipe[0]);
close(tempfd);
- free(input);
-
if (!total)
{
/*
if ((!strcmp(system_paper, "Letter") && have_letter) ||
(!strcmp(system_paper, "A4") && have_a4))
{
- num_defaults = cupsAddOption("PageSize", system_paper,
+ num_defaults = cupsAddOption("PageSize", system_paper,
num_defaults, &defaults);
- num_defaults = cupsAddOption("PageRegion", system_paper,
+ num_defaults = cupsAddOption("PageRegion", system_paper,
num_defaults, &defaults);
- num_defaults = cupsAddOption("PaperDimension", system_paper,
+ num_defaults = cupsAddOption("PaperDimension", system_paper,
num_defaults, &defaults);
- num_defaults = cupsAddOption("ImageableArea", system_paper,
+ num_defaults = cupsAddOption("ImageableArea", system_paper,
num_defaults, &defaults);
}
}
if (!ra || cupsArrayFind(ra, "printer-state-change-time"))
ippAddInteger(con->response, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
"printer-state-change-time", printer->state_time);
-
+
if (MaxPrinterHistory > 0 && printer->num_history > 0 &&
cupsArrayFind(ra, "printer-state-history"))
{
create_job(cupsd_client_t *con, /* I - Client connection */
ipp_attribute_t *uri) /* I - Printer URI */
{
- cupsd_job_t *job; /* New job */
+ cupsd_printer_t *printer; /* Printer */
+ cupsd_job_t *job; /* New job */
cupsdLogMessage(CUPSD_LOG_DEBUG2, "create_job(%p[%d], %s)", con,
con->http.fd, uri->values[0].string.text);
+ /*
+ * Is the destination valid?
+ */
+
+ if (!cupsdValidateDest(uri->values[0].string.text, NULL, &printer))
+ {
+ /*
+ * Bad URI...
+ */
+
+ send_ipp_status(con, IPP_NOT_FOUND,
+ _("The printer or class was not found."));
+ return;
+ }
+
/*
* Create the job object...
*/
- if ((job = add_job(con, uri, NULL, NULL)) == NULL)
+ if ((job = add_job(con, printer, NULL)) == NULL)
return;
/*
* Save and log the job...
*/
-
+
cupsdSaveJob(job);
cupsdLogMessage(CUPSD_LOG_INFO, "Job %d created on \"%s\" by \"%s\".",
cupsArrayAdd(ra, "uri-authentication-supported");
cupsArrayAdd(ra, "uri-security-supported");
}
+ else if (!strcmp(value, "printer-defaults"))
+ {
+ char *name; /* Option name */
+
+
+ for (name = (char *)cupsArrayFirst(CommonDefaults);
+ name;
+ name = (char *)cupsArrayNext(CommonDefaults))
+ cupsArrayAdd(ra, name);
+ }
else if (!strcmp(value, "subscription-template"))
{
cupsArrayAdd(ra, "notify-attributes");
int interval, /* notify-time-interval */
lease; /* notify-lease-duration */
unsigned mask; /* notify-events */
+ ipp_attribute_t *notify_events,/* notify-events(-default) */
+ *notify_lease; /* notify-lease-duration(-default) */
#ifdef DEBUG
dtype = CUPS_PRINTER_CLASS;
printer = NULL;
}
- else if (!cupsdValidateDest(host, resource, &dtype, &printer))
+ else if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
if (printer)
{
- if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
+ NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
jobid = 0;
mask = CUPSD_EVENT_NONE;
+ if (printer)
+ {
+ notify_events = ippFindAttribute(printer->attrs, "notify-events-default",
+ IPP_TAG_KEYWORD);
+ notify_lease = ippFindAttribute(printer->attrs,
+ "notify-lease-duration-default",
+ IPP_TAG_INTEGER);
+
+ if (notify_lease)
+ lease = notify_lease->values[0].integer;
+ }
+ else
+ {
+ notify_events = NULL;
+ notify_lease = NULL;
+ }
+
while (attr && attr->group_tag != IPP_TAG_ZERO)
{
if (!strcmp(attr->name, "notify-recipient") &&
}
else if (!strcmp(attr->name, "notify-events") &&
attr->value_tag == IPP_TAG_KEYWORD)
- {
- for (i = 0; i < attr->num_values; i ++)
- mask |= cupsdEventValue(attr->values[i].string.text);
- }
+ notify_events = attr;
else if (!strcmp(attr->name, "notify-lease-duration") &&
attr->value_tag == IPP_TAG_INTEGER)
lease = attr->values[0].integer;
attr = attr->next;
}
+ if (notify_events)
+ {
+ for (i = 0; i < notify_events->num_values; i ++)
+ mask |= cupsdEventValue(notify_events->values[i].string.text);
+ }
+
if (recipient)
cupsdLogMessage(CUPSD_LOG_DEBUG, "recipient=\"%s\"", recipient);
if (pullmethod)
ipp_attribute_t *uri) /* I - URI of printer or class */
{
http_status_t status; /* Policy status */
- const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI], /* Method portion of URI */
- username[HTTP_MAX_URI], /* Username portion of URI */
- host[HTTP_MAX_URI], /* Host portion of URI */
- resource[HTTP_MAX_URI]; /* Resource portion of URI */
- int port; /* Port portion of URI */
cupsd_printer_t *printer; /* Printer/class */
char filename[1024]; /* Script/PPD filename */
* Do we have a valid URI?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
* Remove old jobs...
*/
- cupsdCancelJobs(dest, NULL, 1);
+ cupsdCancelJobs(printer->name, NULL, 1);
/*
* Remove old subscriptions and send a "deleted printer" event...
cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, printer, NULL,
"%s \"%s\" deleted by \"%s\".",
(dtype & CUPS_PRINTER_CLASS) ? "Class" : "Printer",
- dest, get_username(con));
+ printer->name, get_username(con));
cupsdExpireSubscriptions(printer, NULL);
-
+
/*
* Remove any old PPD or script files...
*/
- snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot, dest);
+ snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot,
+ printer->name);
unlink(filename);
- snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, dest);
+ snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot,
+ printer->name);
unlink(filename);
if (dtype & CUPS_PRINTER_CLASS)
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" deleted by \"%s\".", dest,
- get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" deleted by \"%s\".",
+ printer->name, get_username(con));
cupsdDeletePrinter(printer, 0);
cupsdSaveAllClasses();
}
else
{
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" deleted by \"%s\".", dest,
- get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" deleted by \"%s\".",
+ printer->name, get_username(con));
cupsdDeletePrinter(printer, 0);
cupsdSaveAllPrinters();
const char *dest; /* Destination */
cups_ptype_t dtype; /* Destination type (printer or class) */
cups_ptype_t dmask; /* Destination type mask */
- char method[HTTP_MAX_URI], /* Method portion of URI */
+ char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+ sizeof(scheme), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(resource, "/") ||
dmask = CUPS_PRINTER_CLASS;
printer = NULL;
}
- else if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ else if ((dest = cupsdValidateDest(uri->values[0].string.text, &dtype,
+ &printer)) == NULL)
{
/*
* Bad URI...
if (printer)
{
- if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con, NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(printer->op_policy_ptr, con,
+ NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
int interval; /* Poll interval */
- cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_subscription_attrs(con=%p[%d])",
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "get_notifications(con=%p[%d])",
con, con->http.fd);
/*
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI],
- /* Method portion of URI */
- username[HTTP_MAX_URI],
- /* Username portion of URI */
- host[HTTP_MAX_URI],
- /* Host portion of URI */
- resource[HTTP_MAX_URI];
- /* Resource portion of URI */
- int port; /* Port portion of URI */
cupsd_printer_t *printer; /* Printer/class */
cups_array_t *ra; /* Requested attributes array */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if (!cupsdValidateDest(host, resource, &dtype, &printer))
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
cups_array_t *ra; /* Requested attributes array */
ipp_attribute_t *attr; /* Attribute */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI],
- /* Method portion of URI */
+ char scheme[HTTP_MAX_URI],
+ /* Scheme portion of URI */
username[HTTP_MAX_URI],
/* Username portion of URI */
host[HTTP_MAX_URI],
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+ sizeof(scheme), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(resource, "/") ||
return;
}
}
- else if (!cupsdValidateDest(host, resource, &dtype, &printer))
+ else if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
const char *src; /* Source printer/class */
cups_ptype_t stype, /* Source type (printer or class) */
dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI], /* Method portion of URI */
+ char scheme[HTTP_MAX_URI], /* Scheme portion of URI */
username[HTTP_MAX_URI], /* Username portion of URI */
host[HTTP_MAX_URI], /* Host portion of URI */
resource[HTTP_MAX_URI]; /* Resource portion of URI */
_("job-printer-uri attribute missing!"));
return;
}
-
- httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
- if (!cupsdValidateDest(host, resource, &dtype, &dprinter))
+ if (!cupsdValidateDest(attr->values[0].string.text, &dtype, &dprinter))
{
/*
* Bad URI...
* Check policy...
*/
- if ((status = cupsdCheckPolicy(dprinter->op_policy_ptr, con, NULL)) != HTTP_OK)
+ if ((status = cupsdCheckPolicy(dprinter->op_policy_ptr, con,
+ NULL)) != HTTP_OK)
{
send_http_error(con, status);
return;
* See if we have a job URI or a printer URI...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, scheme,
+ sizeof(scheme), username, sizeof(username), host,
sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(uri->name, "printer-uri"))
* Move all jobs...
*/
- if ((src = cupsdValidateDest(host, resource, &stype, &sprinter)) == NULL)
+ if ((src = cupsdValidateDest(uri->values[0].string.text, &stype,
+ &sprinter)) == NULL)
{
/*
* Bad URI...
{
ipp_attribute_t *attr; /* Current attribute */
ipp_attribute_t *format; /* Document-format attribute */
+ const char *default_format; /* document-format-default value */
cupsd_job_t *job; /* New job */
char filename[1024]; /* Job filename */
mime_type_t *filetype; /* Type of file */
return;
}
+ /*
+ * Is the destination valid?
+ */
+
+ if (!cupsdValidateDest(uri->values[0].string.text, NULL, &printer))
+ {
+ /*
+ * Bad URI...
+ */
+
+ send_ipp_status(con, IPP_NOT_FOUND,
+ _("The printer or class was not found."));
+ return;
+ }
+
/*
* Is it a format we support?
*/
* Grab format from client...
*/
- if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super, type) != 2)
+ if (sscanf(format->values[0].string.text, "%15[^/]/%31[^;]", super,
+ type) != 2)
{
send_ipp_status(con, IPP_BAD_REQUEST,
_("Could not scan type \"%s\"!"),
return;
}
}
+ else if ((default_format = cupsGetOption("document-format",
+ printer->num_options,
+ printer->options)) != NULL)
+ {
+ /*
+ * Use default document format...
+ */
+
+ if (sscanf(default_format, "%15[^/]/%31[^;]", super, type) != 2)
+ {
+ send_ipp_status(con, IPP_BAD_REQUEST,
+ _("Could not scan type \"%s\"!"),
+ default_format);
+ return;
+ }
+ }
else
{
/*
- * No document format attribute? Auto-type it!
+ * Auto-type it!
*/
strcpy(super, "application");
doc_name ? doc_name->values[0].string.text : NULL,
&compression);
- if (filetype)
- {
- /*
- * Replace the document-format attribute value with the auto-typed one.
- */
+ if (!filetype)
+ filetype = mimeType(MimeDatabase, super, type);
+ }
+ else
+ filetype = mimeType(MimeDatabase, super, type);
- snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
- filetype->type);
+ if (filetype &&
+ (!format ||
+ (!strcmp(super, "application") && !strcmp(type, "octet-stream"))))
+ {
+ /*
+ * Replace the document-format attribute value with the auto-typed or
+ * default one.
+ */
- if (format)
- {
- _cupsStrFree(format->values[0].string.text);
+ snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
+ filetype->type);
- format->values[0].string.text = _cupsStrAlloc(mimetype);
- }
- else
- ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
- "document-format", NULL, mimetype);
+ if (format)
+ {
+ _cupsStrFree(format->values[0].string.text);
+
+ format->values[0].string.text = _cupsStrAlloc(mimetype);
}
else
- filetype = mimeType(MimeDatabase, super, type);
+ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
+ "document-format", NULL, mimetype);
}
- else
- filetype = mimeType(MimeDatabase, super, type);
-
- if (!filetype)
+ else if (!filetype)
{
send_ipp_status(con, IPP_DOCUMENT_FORMAT,
_("Unsupported format \'%s/%s\'!"), super, type);
* Create the job object...
*/
- if ((job = add_job(con, uri, &printer, filetype)) == NULL)
+ if ((job = add_job(con, printer, filetype)) == NULL)
return;
/*
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI], /* Method portion of URI */
- username[HTTP_MAX_URI], /* Username portion of URI */
- host[HTTP_MAX_URI], /* Host portion of URI */
- resource[HTTP_MAX_URI]; /* Resource portion of URI */
- int port; /* Port portion of URI */
- const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
ipp_attribute_t *attr; /* printer-state-message text */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
cupsdSaveAllClasses();
cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" rejecting jobs (\"%s\").",
- name, get_username(con));
+ printer->name, get_username(con));
}
else
{
cupsdSaveAllPrinters();
cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" rejecting jobs (\"%s\").",
- name, get_username(con));
+ printer->name, get_username(con));
}
/*
*/
static void
-save_auth_info(cupsd_client_t *con, /* I - Client connection */
- cupsd_job_t *job) /* I - Job */
+save_auth_info(
+ cupsd_client_t *con, /* I - Client connection */
+ cupsd_job_t *job, /* I - Job */
+ ipp_attribute_t *auth_info) /* I - auth-info attribute, if any */
{
int i; /* Looping var */
char filename[1024]; /* Job authentication filename */
cups_file_t *fp; /* Job authentication file */
- char line[1024]; /* Line for file */
+ char line[2048]; /* Line for file */
/*
* This function saves the in-memory authentication information for
* a job so that it can be used to authenticate with a remote host.
* The information is stored in a file that is readable only by the
- * root user. The username and password are Base-64 encoded, each
- * on a separate line, followed by random number (up to 1024) of
- * newlines to limit the amount of information that is exposed.
+ * root user. The fields are Base-64 encoded, each on a separate line,
+ * followed by random number (up to 1024) of newlines to limit the
+ * amount of information that is exposed.
*
* Because of the potential for exposing of authentication information,
* this functionality is only enabled when running cupsd as root.
fchown(cupsFileNumber(fp), 0, 0);
fchmod(cupsFileNumber(fp), 0400);
- /*
- * Write the authenticated username...
- */
+ if (auth_info)
+ {
+ /*
+ * Write 1 to 4 auth values...
+ */
- httpEncode64_2(line, sizeof(line), con->username, strlen(con->username));
- cupsFilePrintf(fp, "%s\n", line);
+ for (i = 0; i < auth_info->num_values; i ++)
+ {
+ httpEncode64_2(line, sizeof(line), auth_info->values[i].string.text,
+ strlen(auth_info->values[i].string.text));
+ cupsFilePrintf(fp, "%s\n", line);
+ }
+ }
+ else
+ {
+ /*
+ * Write the authenticated username...
+ */
- /*
- * Write the authenticated password...
- */
+ httpEncode64_2(line, sizeof(line), con->username, strlen(con->username));
+ cupsFilePrintf(fp, "%s\n", line);
- httpEncode64_2(line, sizeof(line), con->password, strlen(con->password));
- cupsFilePrintf(fp, "%s\n", line);
+ /*
+ * Write the authenticated password...
+ */
+
+ httpEncode64_2(line, sizeof(line), con->password, strlen(con->password));
+ cupsFilePrintf(fp, "%s\n", line);
+ }
/*
* Write a random number of newlines to the end of the file...
*/
cupsFileClose(fp);
+
+#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5_H)
+ save_krb5_creds(con, job);
+#endif /* HAVE_GSSAPI && HAVE_KRB5_H */
+}
+
+
+#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5_H)
+/*
+ * 'save_krb5_creds()' - Save Kerberos credentials for the job.
+ */
+
+static void
+save_krb5_creds(cupsd_client_t *con, /* I - Client connection */
+ cupsd_job_t *job) /* I - Job */
+{
+# ifndef __APPLE__
+ krb5_context krb_context; /* Kerberos context */
+ krb5_ccache ccache; /* Credentials cache */
+ OM_uint32 major_status, /* Major status code */
+ minor_status; /* Minor status code */
+
+
+ /*
+ * Setup a cached context for the job filters to use...
+ */
+
+ if (krb5_init_context(&krb_context))
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to initialize Kerberos context");
+ return;
+ }
+
+# ifdef HAVE_HEIMDAL
+ if (krb5_cc_gen_new(krb_context, &krb5_fcc_ops, &ccache))
+# else
+ if (krb5_cc_gen_new(krb_context, &ccache))
+# endif /* HAVE_HEIMDAL */
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create new credentials");
+ return;
+ }
+
+ major_status = gss_krb5_copy_ccache(&minor_status, con->gss_delegated_cred,
+ ccache);
+
+ if (GSS_ERROR(major_status))
+ {
+ cupsdLogGSSMessage(CUPSD_LOG_ERROR, major_status, minor_status,
+ "Unable to import client credentials cache");
+ krb5_cc_destroy(krb_context, ccache);
+ return;
+ }
+
+ cupsdSetStringf(&(job->ccname), "KRB5CCNAME=FILE:%s",
+ krb5_cc_get_name(krb_context, ccache));
+ krb5_cc_close(krb_context, ccache);
+# endif /* !__APPLE__ */
}
+#endif /* HAVE_GSSAPI && HAVE_KRB5_H */
/*
{
ipp_attribute_t *attr; /* Current attribute */
ipp_attribute_t *format; /* Document-format attribute */
+ const char *default_format;/* document-format-default value */
int jobid; /* Job ID number */
cupsd_job_t *job; /* Current job */
char job_uri[HTTP_MAX_URI],
return;
}
}
+ else if ((default_format = cupsGetOption("document-format",
+ printer->num_options,
+ printer->options)) != NULL)
+ {
+ /*
+ * Use default document format...
+ */
+
+ if (sscanf(default_format, "%15[^/]/%31[^;]", super, type) != 2)
+ {
+ send_ipp_status(con, IPP_BAD_REQUEST,
+ _("Could not scan type \"%s\"!"),
+ default_format);
+ return;
+ }
+ }
else
{
/*
doc_name ? doc_name->values[0].string.text : NULL,
&compression);
- if (filetype)
- {
- /*
- * Replace the document-format attribute value with the auto-typed one.
- */
-
- snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
- filetype->type);
-
- if (format)
- {
- _cupsStrFree(format->values[0].string.text);
- format->values[0].string.text = _cupsStrAlloc(mimetype);
- }
- else
- ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
- "document-format", NULL, mimetype);
- }
- else
+ if (!filetype)
filetype = mimeType(MimeDatabase, super, type);
}
else
filetype = mimeType(MimeDatabase, super, type);
- if (!filetype)
+ if (filetype &&
+ (!format ||
+ (!strcmp(super, "application") && !strcmp(type, "octet-stream"))))
+ {
+ /*
+ * Replace the document-format attribute value with the auto-typed or
+ * default one.
+ */
+
+ snprintf(mimetype, sizeof(mimetype), "%s/%s", filetype->super,
+ filetype->type);
+
+ if (format)
+ {
+ _cupsStrFree(format->values[0].string.text);
+
+ format->values[0].string.text = _cupsStrAlloc(mimetype);
+ }
+ else
+ ippAddString(con->request, IPP_TAG_JOB, IPP_TAG_MIMETYPE,
+ "document-format", NULL, mimetype);
+ }
+ else if (!filetype)
{
send_ipp_status(con, IPP_DOCUMENT_FORMAT,
_("Unsupported format \'%s/%s\'!"), super, type);
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI],
- /* Method portion of URI */
- username[HTTP_MAX_URI],
- /* Username portion of URI */
- host[HTTP_MAX_URI],
- /* Host portion of URI */
- resource[HTTP_MAX_URI];
- /* Resource portion of URI */
- int port; /* Port portion of URI */
- const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
cupsdWritePrintcap();
cupsdLogMessage(CUPSD_LOG_INFO,
- "Default destination set to \"%s\" by \"%s\".", name,
- get_username(con));
+ "Default destination set to \"%s\" by \"%s\".",
+ printer->name, get_username(con));
/*
* Everything was ok, so return OK status...
attr->values[0].string.text);
cupsdSetString(&printer->error_policy, attr->values[0].string.text);
}
- else if (!strcmp(attr->name, "document-format-default") ||
- !strcmp(attr->name, "notify-lease-duration-default") ||
- !strcmp(attr->name, "notify-events-default"))
- continue;
/*
* Skip any other non-default attributes...
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI],
- /* Method portion of URI */
- username[HTTP_MAX_URI],
- /* Username portion of URI */
- host[HTTP_MAX_URI],
- /* Host portion of URI */
- resource[HTTP_MAX_URI];
- /* Resource portion of URI */
- int port; /* Port portion of URI */
- const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
cupsdStartPrinter(printer, 1);
if (dtype & CUPS_PRINTER_CLASS)
- cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" started by \"%s\".", name,
- get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" started by \"%s\".",
+ printer->name, get_username(con));
else
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" started by \"%s\".", name,
- get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" started by \"%s\".",
+ printer->name, get_username(con));
cupsdCheckJobs();
{
http_status_t status; /* Policy status */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI],
- /* Method portion of URI */
- username[HTTP_MAX_URI],
- /* Username portion of URI */
- host[HTTP_MAX_URI],
- /* Host portion of URI */
- resource[HTTP_MAX_URI];
- /* Resource portion of URI */
- int port; /* Port portion of URI */
- const char *name; /* Printer name */
cupsd_printer_t *printer; /* Printer data */
ipp_attribute_t *attr; /* printer-state-message attribute */
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
cupsdStopPrinter(printer, 1);
if (dtype & CUPS_PRINTER_CLASS)
- cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" stopped by \"%s\".", name,
- get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Class \"%s\" stopped by \"%s\".",
+ printer->name, get_username(con));
else
- cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" stopped by \"%s\".", name,
- get_username(con));
+ cupsdLogMessage(CUPSD_LOG_INFO, "Printer \"%s\" stopped by \"%s\".",
+ printer->name, get_username(con));
/*
* Everything was ok, so return OK status...
ipp_attribute_t *attr; /* Current attribute */
ipp_attribute_t *format; /* Document-format attribute */
cups_ptype_t dtype; /* Destination type (printer or class) */
- char method[HTTP_MAX_URI],
- /* Method portion of URI */
- username[HTTP_MAX_URI],
- /* Username portion of URI */
- host[HTTP_MAX_URI],
- /* Host portion of URI */
- resource[HTTP_MAX_URI];
- /* Resource portion of URI */
- int port; /* Port portion of URI */
char super[MIME_MAX_SUPER],
/* Supertype of file */
type[MIME_MAX_TYPE];
* Is the destination valid?
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
- sizeof(method), username, sizeof(username), host,
- sizeof(host), &port, resource, sizeof(resource));
-
- if (cupsdValidateDest(host, resource, &dtype, &printer) == NULL)
+ if (!cupsdValidateDest(uri->values[0].string.text, &dtype, &printer))
{
/*
* Bad URI...
*/
for (ptr = name; *ptr; ptr ++)
- if ((*ptr >= 0 && *ptr <= ' ') || *ptr == 127 || *ptr == '/' || *ptr == '#')
+ if ((*ptr > 0 && *ptr <= ' ') || *ptr == 127 || *ptr == '/' || *ptr == '#')
return (0);
/*
/*
- * End of "$Id: ipp.c 6145 2006-12-06 20:10:16Z mike $".
+ * End of "$Id: ipp.c 6318 2007-03-06 04:36:55Z mike $".
*/