cupsdSetString(&p->info, name);
cupsdSetString(&p->hostname, ServerName);
- cupsdSetStringf(&p->uri, "ipp://%s:%d/printers/%s", ServerName, LocalPort, name);
+ cupsdSetStringf(&p->uri, "ipp://%s:%d/printers/%s", ServerName, RemotePort,
+ name);
cupsdSetDeviceURI(p, "file:///dev/null");
p->state = IPP_PRINTER_STOPPED;
"separate-documents-uncollated-copies",
"separate-documents-collated-copies"
};
- static const char * const errors[] = /* printer-error-policy-supported values */
- {
- "abort-job",
- "retry-current-job",
- "retry-job",
- "stop-printer"
- };
static const char * const notify_attrs[] =
{ /* notify-attributes-supported values */
"printer-state-change-time",
ippAddString(CommonData, IPP_TAG_PRINTER, IPP_TAG_KEYWORD | IPP_TAG_COPY,
"pdl-override-supported", NULL, "not-attempted");
- /* printer-error-policy-supported */
- ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME | IPP_TAG_COPY,
- "printer-error-policy-supported",
- sizeof(errors) / sizeof(errors[0]), NULL, errors);
-
/* printer-op-policy-supported */
attr = ippAddStrings(CommonData, IPP_TAG_PRINTER, IPP_TAG_NAME | IPP_TAG_COPY,
"printer-op-policy-supported", cupsArrayCount(Policies),
* Stop printing on this printer...
*/
- cupsdStopPrinter(p, update);
+ cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, update);
+
+ if (p->job)
+ cupsdSetJobState(p->job, IPP_JOB_PENDING, CUPSD_JOB_FORCE,
+ update ? "Job stopped due to printer being deleted." :
+ "Job stopped.");
/*
* If this printer is the next for browsing, point to the next one...
if (value &&
strcmp(value, "com.apple.print.recoverable-warning") &&
strcmp(value, "connecting-to-device") &&
- strcmp(value, "cups-insecure-filter-error") &&
- strcmp(value, "cups-missing-filter-error"))
+ strcmp(value, "cups-insecure-filter-warning") &&
+ strcmp(value, "cups-missing-filter-warning"))
{
for (i = 0 ; i < p->num_reasons; i ++)
if (!strcmp(value, p->reasons[i]))
for (i = 0; i < printer->num_reasons; i ++)
if (strcmp(printer->reasons[i], "com.apple.print.recoverable-warning") &&
strcmp(printer->reasons[i], "connecting-to-device") &&
- strcmp(printer->reasons[i], "cups-insecure-filter-error") &&
- strcmp(printer->reasons[i], "cups-missing-filter-error"))
+ strcmp(printer->reasons[i], "cups-insecure-filter-warning") &&
+ strcmp(printer->reasons[i], "cups-missing-filter-warning"))
cupsFilePutConf(fp, "Reason", printer->reasons[i]);
cupsFilePrintf(fp, "Type %d\n", printer->type);
ipp_attribute_t *attr; /* Attribute data */
cups_option_t *option; /* Current printer option */
char *filter; /* Current filter */
+ static const char * const air_none[] =
+ { /* No authentication */
+ "none"
+ };
static const char * const air_userpass[] =
{ /* Basic/Digest authentication */
"username",
"password"
};
-#ifdef HAVE_GSSAPI
- static const char * const air_negotiate[] =
- { /* Kerberos authentication */
- "negotiate"
- };
-#endif /* HAVE_GSSAPI */
- static const char * const air_none[] =
- { /* No authentication */
- "none"
- };
DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
{
num_air = p->num_auth_info_required;
air = p->auth_info_required;
-
- if (!strcmp(air[0], "username"))
- auth_supported = "basic";
- else
- auth_supported = "negotiate";
}
- else if (!(p->type & CUPS_PRINTER_DISCOVERED))
+ else if ((p->type & CUPS_PRINTER_AUTHENTICATED) &&
+ (p->type & CUPS_PRINTER_DISCOVERED))
{
- if (p->type & CUPS_PRINTER_CLASS)
- snprintf(resource, sizeof(resource), "/classes/%s", p->name);
- else
- snprintf(resource, sizeof(resource), "/printers/%s", p->name);
+ num_air = 2;
+ air = air_userpass;
+ }
- if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL ||
- auth->type == CUPSD_AUTH_NONE)
- auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB);
+ if (p->type & CUPS_PRINTER_CLASS)
+ snprintf(resource, sizeof(resource), "/classes/%s", p->name);
+ else
+ snprintf(resource, sizeof(resource), "/printers/%s", p->name);
- if (auth)
- {
- int auth_type; /* Authentication type */
+ if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL ||
+ auth->type == CUPSD_AUTH_NONE)
+ auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB);
+ if (auth)
+ {
+ int auth_type; /* Authentication type */
- if ((auth_type = auth->type) == CUPSD_AUTH_DEFAULT)
- auth_type = DefaultAuthType;
- if (auth_type == CUPSD_AUTH_BASIC || auth_type == CUPSD_AUTH_BASICDIGEST)
- {
- auth_supported = "basic";
- num_air = 2;
- air = air_userpass;
- }
- else if (auth_type == CUPSD_AUTH_DIGEST)
- {
- auth_supported = "digest";
- num_air = 2;
- air = air_userpass;
- }
+ if ((auth_type = auth->type) == CUPSD_AUTH_DEFAULT)
+ auth_type = DefaultAuthType;
+
+ if (auth_type == CUPSD_AUTH_BASIC || auth_type == CUPSD_AUTH_BASICDIGEST)
+ auth_supported = "basic";
+ else if (auth_type == CUPSD_AUTH_DIGEST)
+ auth_supported = "digest";
#ifdef HAVE_GSSAPI
- else if (auth_type == CUPSD_AUTH_NEGOTIATE)
- {
- auth_supported = "negotiate";
- num_air = 1;
- air = air_negotiate;
- }
+ else if (auth_type == CUPSD_AUTH_NEGOTIATE)
+ auth_supported = "negotiate";
#endif /* HAVE_GSSAPI */
+ if (!(p->type & CUPS_PRINTER_DISCOVERED))
+ {
if (auth_type != CUPSD_AUTH_NONE)
- p->type |= CUPS_PRINTER_AUTHENTICATED;
+ p->type |= CUPS_PRINTER_AUTHENTICATED;
else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
+ p->type &= ~CUPS_PRINTER_AUTHENTICATED;
}
- else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
- }
- else if (p->type & CUPS_PRINTER_AUTHENTICATED)
- {
- num_air = 2;
- air = air_userpass;
}
+ else if (!(p->type & CUPS_PRINTER_DISCOVERED))
+ p->type &= ~CUPS_PRINTER_AUTHENTICATED;
/*
* Create the required IPP attributes for a printer...
* Add filters for printer...
*/
- cupsdSetPrinterReasons(p, "-cups-missing-filter-error");
+ cupsdSetPrinterReasons(p, "-cups-missing-filter-warning,"
+ "cups-insecure-filter-warning");
for (filter = (char *)cupsArrayFirst(p->filters);
filter;
if (BrowseLocalOptions)
length += 12 + strlen(BrowseLocalOptions);
- if (p->num_auth_info_required > 0)
- {
- length += 18; /* auth-info-required */
-
- for (i = 0; i < p->num_auth_info_required; i ++)
- length += strlen(p->auth_info_required[i]) + 1;
- }
-
/*
* Allocate the new string...
*/
}
}
}
-
- if (p->num_auth_info_required > 0)
- {
- strcpy(attrptr, "auth-info-required");
- attrptr += 18;
-
- for (i = 0; i < p->num_auth_info_required; i ++)
- {
- *attrptr++ = i ? ',' : '=';
- strcpy(attrptr, p->auth_info_required[i]);
- attrptr += strlen(attrptr);
- }
- }
- else
- *attrptr = '\0';
}
}
* 'cupsdSetPrinterReasons()' - Set/update the reasons strings.
*/
-void
+int /* O - 1 if something changed, 0 otherwise */
cupsdSetPrinterReasons(
cupsd_printer_t *p, /* I - Printer */
const char *s) /* I - Reasons strings */
{
- int i; /* Looping var */
+ int i, /* Looping var */
+ changed = 0; /* Did something change? */
const char *sptr; /* Pointer into reasons */
char reason[255], /* Reason string */
*rptr; /* Pointer into reason */
_cupsStrFree(p->reasons[i]);
p->num_reasons = 0;
+ changed = 1;
cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
}
if (!strcmp(s, "none"))
- return;
+ return (changed);
/*
* Loop through all of the reasons...
*/
p->num_reasons --;
+ changed = 1;
_cupsStrFree(p->reasons[i]);
if (i < p->num_reasons)
cupsdSetPrinterState(p, IPP_PRINTER_IDLE, 1);
if (strcmp(reason, "connecting-to-device"))
+ {
cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
- if (PrintcapFormat == PRINTCAP_PLIST)
- cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
-
+ if (PrintcapFormat == PRINTCAP_PLIST)
+ cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
+ }
break;
}
}
cupsdLogMessage(CUPSD_LOG_ALERT,
"Too many printer-state-reasons values for %s (%d)",
p->name, i + 1);
- return;
+ return (changed);
}
p->reasons[i] = _cupsStrAlloc(reason);
p->num_reasons ++;
+ changed = 1;
if (!strcmp(reason, "paused") && p->state != IPP_PRINTER_STOPPED)
cupsdSetPrinterState(p, IPP_PRINTER_STOPPED, 1);
if (strcmp(reason, "connecting-to-device"))
+ {
cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
- if (PrintcapFormat == PRINTCAP_PLIST)
- cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
+ if (PrintcapFormat == PRINTCAP_PLIST)
+ cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
+ }
}
}
}
+
+ return (changed);
}
* See if we have a job printing on this printer...
*/
- if (p->job)
+ if (p->job && p->job->state_value == IPP_JOB_PROCESSING)
cupsdSetJobState(p->job, IPP_JOB_PENDING, CUPSD_JOB_DEFAULT,
"Job stopped due to printer being paused.");
}
if (stat(filename, &fileinfo))
{
+ memset(&fileinfo, 0, sizeof(fileinfo));
+
snprintf(p->state_message, sizeof(p->state_message),
"Filter \"%s\" for printer \"%s\" not available: %s",
filename, p->name, strerror(errno));
- cupsdSetPrinterReasons(p, "+cups-missing-filter-error");
+ cupsdSetPrinterReasons(p, "+cups-missing-filter-warning");
cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
- return;
}
/*
* permissions.
*/
- if (fileinfo.st_uid || (fileinfo.st_mode & S_IWOTH) != 0)
+ if (fileinfo.st_uid || (fileinfo.st_mode & (S_ISUID | S_IWOTH)) != 0)
{
if (fileinfo.st_uid)
snprintf(p->state_message, sizeof(p->state_message),
"Filter \"%s\" for printer \"%s\" has insecure permissions "
"(0%o)", filename, p->name, fileinfo.st_mode);
- cupsdSetPrinterReasons(p, "+cups-insecure-filter-error");
+ cupsdSetPrinterReasons(p, "+cups-insecure-filter-warning");
cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
- return;
}
-
- /*
- * Similarly, check that the parent directory is also owned by root and
- * does not have world write permissions.
- */
-
- if ((dirsep = strrchr(filename, '/')) != NULL)
- *dirsep = '\0';
-
- if (stat(filename, &fileinfo))
+ else if (fileinfo.st_mode)
{
- snprintf(p->state_message, sizeof(p->state_message),
- "Filter directory \"%s\" for printer \"%s\" not accessible: %s",
- filename, p->name, strerror(errno));
- cupsdSetPrinterReasons(p, "+cups-missing-filter-error");
+ /*
+ * Similarly, check that the parent directory is also owned by root and
+ * does not have world write permissions.
+ */
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
- return;
- }
- else if (fileinfo.st_uid || (fileinfo.st_mode & S_IWOTH) != 0)
- {
- if (fileinfo.st_uid)
- snprintf(p->state_message, sizeof(p->state_message),
- "Filter directory \"%s\" for printer \"%s\" not owned by "
- "root", filename, p->name);
- else
- snprintf(p->state_message, sizeof(p->state_message),
- "Filter directory \"%s\" for printer \"%s\" has insecure "
- "permissions (0%o)", filename, p->name, fileinfo.st_mode);
+ if ((dirsep = strrchr(filename, '/')) != NULL)
+ *dirsep = '\0';
+
+ if (!stat(filename, &fileinfo) &&
+ (fileinfo.st_uid ||
+ (fileinfo.st_mode & (S_ISUID | S_IWOTH)) != 0))
+ {
+ if (fileinfo.st_uid)
+ snprintf(p->state_message, sizeof(p->state_message),
+ "Filter directory \"%s\" for printer \"%s\" not owned by "
+ "root", filename, p->name);
+ else
+ snprintf(p->state_message, sizeof(p->state_message),
+ "Filter directory \"%s\" for printer \"%s\" has insecure "
+ "permissions (0%o)", filename, p->name, fileinfo.st_mode);
- cupsdSetPrinterReasons(p, "+cups-insecure-filter-error");
+ cupsdSetPrinterReasons(p, "+cups-insecure-filter-warning");
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
- return;
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
+ }
}
}
}
mimeDeleteFilter(MimeDatabase, filter);
}
- cupsdSetPrinterReasons(p, "-cups-insecure-filter-error"
- ",cups-missing-filter-error");
+ cupsdSetPrinterReasons(p, "-cups-insecure-filter-warning"
+ ",cups-missing-filter-warning");
}
val->string.text = _cupsStrAlloc(output_bin->choices[i].choice);
}
- attr = ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "output-bin-default", NULL, output_bin->defchoice);
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, output_bin->defchoice);
}
/*