summaryrefslogtreecommitdiff
path: root/scheduler
diff options
context:
space:
mode:
Diffstat (limited to 'scheduler')
-rw-r--r--scheduler/conf.c8
-rw-r--r--scheduler/cups-lpd.c10
-rw-r--r--scheduler/ipp.c5
-rw-r--r--scheduler/job.c2
-rw-r--r--scheduler/main.c37
-rw-r--r--scheduler/printers.c56
-rw-r--r--scheduler/printers.h3
-rw-r--r--scheduler/process.c1
-rw-r--r--scheduler/sysman.c19
9 files changed, 93 insertions, 48 deletions
diff --git a/scheduler/conf.c b/scheduler/conf.c
index 36f043f..3897073 100644
--- a/scheduler/conf.c
+++ b/scheduler/conf.c
@@ -2987,7 +2987,7 @@ read_cupsd_conf(cups_file_t *fp) /* I - File to read from */
else if (!_cups_strcasecmp(line, "SSLOptions"))
{
/*
- * SSLOptions [AllowRC4] [AllowSSL3] [None]
+ * SSLOptions [AllowRC4] [AllowSSL3] [AllowDH] [DenyCBC] [DenyTLS1.0] [None]
*/
int options = 0; /* SSL/TLS options */
@@ -3018,6 +3018,12 @@ read_cupsd_conf(cups_file_t *fp) /* I - File to read from */
options |= _HTTP_TLS_ALLOW_RC4;
else if (!_cups_strcasecmp(start, "AllowSSL3"))
options |= _HTTP_TLS_ALLOW_SSL3;
+ else if (!_cups_strcasecmp(start, "AllowDH"))
+ options |= _HTTP_TLS_ALLOW_DH;
+ else if (!_cups_strcasecmp(start, "DenyCBC"))
+ options |= _HTTP_TLS_DENY_CBC;
+ else if (!_cups_strcasecmp(start, "DenyTLS1.0"))
+ options |= _HTTP_TLS_DENY_TLS10;
else if (!_cups_strcasecmp(start, "None"))
options = 0;
else if (_cups_strcasecmp(start, "NoEmptyFragments"))
diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c
index 8d2ea49..5d5e6f8 100644
--- a/scheduler/cups-lpd.c
+++ b/scheduler/cups-lpd.c
@@ -29,7 +29,7 @@
# include <inttypes.h>
#endif /* HAVE_INTTYPES_H */
#ifdef __APPLE__
-# include <vproc.h>
+# include <xpc/xpc.h>
#endif /* __APPLE__ */
@@ -97,8 +97,10 @@ main(int argc, /* I - Number of command-line arguments */
hostip[256], /* IP address */
*hostfamily; /* Address family */
int hostlookups; /* Do hostname lookups? */
+
+
#ifdef __APPLE__
- vproc_transaction_t vtran = vproc_transaction_begin(NULL);
+ xpc_transaction_begin();
#endif /* __APPLE__ */
@@ -217,7 +219,7 @@ main(int argc, /* I - Number of command-line arguments */
putchar(1);
#ifdef __APPLE__
- vproc_transaction_end(NULL, vtran);
+ xpc_transaction_end();
#endif /* __APPLE__ */
return (1);
@@ -313,7 +315,7 @@ main(int argc, /* I - Number of command-line arguments */
closelog();
#ifdef __APPLE__
- vproc_transaction_end(NULL, vtran);
+ xpc_transaction_end();
#endif /* __APPLE__ */
return (status);
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 2525e58..49a05a4 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -5366,7 +5366,7 @@ create_local_bg_thread(
}
}
else
- cupsdLogMessage(CUPSD_LOG_ERROR, "%s: PPD creation failed.", printer->name);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "%s: PPD creation failed: %s", printer->name, cupsLastErrorString());
return (NULL);
}
@@ -5479,6 +5479,9 @@ create_local_printer(
return;
}
+ printer->shared = 0;
+ printer->temporary = 1;
+
cupsdSetDeviceURI(printer, ippGetString(device_uri, 0, NULL));
if (printer_geo_location)
diff --git a/scheduler/job.c b/scheduler/job.c
index 7824015..a8ba54c 100644
--- a/scheduler/job.c
+++ b/scheduler/job.c
@@ -2745,7 +2745,7 @@ cupsdSetJobState(
job->dirty = 1;
cupsdMarkDirty(CUPSD_DIRTY_JOBS);
}
- else if (!JobHistory && !job->printer)
+ else if (!job->printer)
{
/*
* Delete the job immediately if not actively printing...
diff --git a/scheduler/main.c b/scheduler/main.c
index bdb27a6..4a66cbc 100644
--- a/scheduler/main.c
+++ b/scheduler/main.c
@@ -88,6 +88,8 @@ static int dead_children = 0;
/* Dead children? */
static int stop_scheduler = 0;
/* Should the scheduler stop? */
+static time_t local_timeout = 0;
+ /* Next local printer timeout */
/*
@@ -701,6 +703,7 @@ main(int argc, /* I - Number of command-line args */
current_time = time(NULL);
event_time = current_time;
expire_time = current_time;
+ local_timeout = current_time + 60;
fds = 1;
report_time = 0;
senddoc_time = current_time;
@@ -957,6 +960,13 @@ main(int argc, /* I - Number of command-line args */
expire_time = current_time;
}
+ /*
+ * Delete stale local printers...
+ */
+
+ if (current_time >= local_timeout)
+ cupsdDeleteTemporaryPrinters(0);
+
#ifndef HAVE_AUTHORIZATION_H
/*
* Update the root certificate once every 5 minutes if we have client
@@ -1152,6 +1162,12 @@ main(int argc, /* I - Number of command-line args */
cupsdFreeAllJobs();
+ /*
+ * Delete all temporary printers...
+ */
+
+ cupsdDeleteTemporaryPrinters(1);
+
#ifdef __APPLE__
/*
* Stop monitoring system event monitoring...
@@ -1595,6 +1611,7 @@ select_timeout(int fds) /* I - Number of descriptors returned */
time_t now; /* Current time */
cupsd_client_t *con; /* Client information */
cupsd_job_t *job; /* Job information */
+ cupsd_printer_t *printer; /* Printer information */
const char *why; /* Debugging aid */
@@ -1631,13 +1648,13 @@ select_timeout(int fds) /* I - Number of descriptors returned */
#ifdef __APPLE__
/*
- * When going to sleep, wake up to cancel jobs that don't complete in time.
+ * When going to sleep, wake up to abort jobs that don't complete in time.
*/
if (SleepJobs > 0 && SleepJobs < timeout)
{
timeout = SleepJobs;
- why = "cancel jobs before sleeping";
+ why = "abort jobs before sleeping";
}
#endif /* __APPLE__ */
@@ -1719,6 +1736,22 @@ select_timeout(int fds) /* I - Number of descriptors returned */
}
}
+ /*
+ * Check for temporary printers that need to be deleted...
+ */
+
+ for (printer = (cupsd_printer_t *)cupsArrayFirst(Printers); printer; printer = (cupsd_printer_t *)cupsArrayNext(Printers))
+ {
+ if (printer->temporary && !printer->job && local_timeout > (printer->state_time + 60))
+ local_timeout = printer->state_time + 60;
+ }
+
+ if (timeout > local_timeout)
+ {
+ timeout = local_timeout;
+ why = "delete stale local printers";
+ }
+
#ifdef HAVE_MALLINFO
/*
* Log memory usage every minute...
diff --git a/scheduler/printers.c b/scheduler/printers.c
index e17d331..dca0962 100644
--- a/scheduler/printers.c
+++ b/scheduler/printers.c
@@ -756,11 +756,6 @@ cupsdDeletePrinter(
* Remove any old PPD or script files...
*/
- snprintf(filename, sizeof(filename), "%s/interfaces/%s", ServerRoot, p->name);
- unlink(filename);
- snprintf(filename, sizeof(filename), "%s/interfaces/%s.O", ServerRoot, p->name);
- unlink(filename);
-
snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd", ServerRoot, p->name);
unlink(filename);
snprintf(filename, sizeof(filename), "%s/ppd/%s.ppd.O", ServerRoot, p->name);
@@ -840,6 +835,32 @@ cupsdDeletePrinter(
/*
+ * 'cupsdDeleteTemporaryPrinters()' - Delete unneeded temporary printers.
+ */
+
+void
+cupsdDeleteTemporaryPrinters(int force) /* I - Force deletion instead of auto? */
+{
+ cupsd_printer_t *p; /* Current printer */
+ time_t unused_time; /* Last time for printer state change */
+
+
+ /*
+ * Allow temporary printers to stick around for 60 seconds after the last job
+ * completes.
+ */
+
+ unused_time = time(NULL) - 60;
+
+ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; p = (cupsd_printer_t *)cupsArrayNext(Printers))
+ {
+ if (p->temporary && (force || p->state_time < unused_time))
+ cupsdDeletePrinter(p, 0);
+ }
+}
+
+
+/*
* 'cupsdFindDest()' - Find a destination in the list.
*/
@@ -4979,31 +5000,6 @@ load_ppd(cupsd_printer_t *p) /* I - Printer */
p->type |= CUPS_PRINTER_REMOTE;
/*
- * Point the printer-uri-supported attribute to the
- * remote printer...
- */
-
- if (strchr(p->device_uri, '?'))
- {
- /*
- * Strip trailing "?options" from URI...
- */
-
- char resource[HTTP_MAX_URI], /* New URI */
- *ptr; /* Pointer into URI */
-
- strlcpy(resource, p->device_uri, sizeof(resource));
- if ((ptr = strchr(resource, '?')) != NULL)
- *ptr = '\0';
-
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
- "printer-uri-supported", NULL, resource);
- }
- else
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
- "printer-uri-supported", NULL, p->device_uri);
-
- /*
* Then set the make-and-model accordingly...
*/
diff --git a/scheduler/printers.h b/scheduler/printers.h
index c63b471..e1d9910 100644
--- a/scheduler/printers.h
+++ b/scheduler/printers.h
@@ -1,7 +1,7 @@
/*
* Printer definitions for the CUPS scheduler.
*
- * Copyright 2007-2016 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -156,6 +156,7 @@ extern cupsd_printer_t *cupsdAddPrinter(const char *name);
extern void cupsdCreateCommonData(void);
extern void cupsdDeleteAllPrinters(void);
extern int cupsdDeletePrinter(cupsd_printer_t *p, int update);
+extern void cupsdDeleteTemporaryPrinters(int force);
extern cupsd_printer_t *cupsdFindDest(const char *name);
extern cupsd_printer_t *cupsdFindPrinter(const char *name);
extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p,
diff --git a/scheduler/process.c b/scheduler/process.c
index 27e8010..584b82e 100644
--- a/scheduler/process.c
+++ b/scheduler/process.c
@@ -125,6 +125,7 @@ cupsdCreateProfile(int job_id, /* I - Job ID or 0 for none */
if (LogLevel >= CUPSD_LOG_DEBUG)
cupsFilePuts(fp, "(debug deny)\n");
cupsFilePuts(fp, "(import \"system.sb\")\n");
+ cupsFilePuts(fp, "(import \"com.apple.corefoundation.sb\")\n");
cupsFilePuts(fp, "(system-network)\n");
cupsFilePuts(fp, "(allow mach-per-user-lookup)\n");
cupsFilePuts(fp, "(allow ipc-posix-sem)\n");
diff --git a/scheduler/sysman.c b/scheduler/sysman.c
index 1a46c30..8b43975 100644
--- a/scheduler/sysman.c
+++ b/scheduler/sysman.c
@@ -18,7 +18,7 @@
#include "cupsd.h"
#ifdef __APPLE__
-# include <vproc.h>
+# include <xpc/xpc.h>
# include <IOKit/pwr_mgt/IOPMLib.h>
#endif /* __APPLE__ */
@@ -129,7 +129,7 @@ cupsdSetBusyState(void)
"Active clients, printing jobs, and dirty files"
};
#ifdef __APPLE__
- static vproc_transaction_t vtran = 0; /* Current busy transaction */
+ static int tran = 0; /* Current busy transaction */
static IOPMAssertionID keep_awake = 0;/* Keep the system awake while printing */
#endif /* __APPLE__ */
@@ -172,12 +172,15 @@ cupsdSetBusyState(void)
busy = newbusy;
#ifdef __APPLE__
- if (busy && !vtran)
- vtran = vproc_transaction_begin(NULL);
- else if (!busy && vtran)
+ if (busy && !tran)
{
- vproc_transaction_end(NULL, vtran);
- vtran = 0;
+ xpc_transaction_begin();
+ tran = 1;
+ }
+ else if (!busy && tran)
+ {
+ xpc_transaction_end();
+ tran = 0;
}
#endif /* __APPLE__ */
}
@@ -350,7 +353,7 @@ cupsdStartSystemMonitor(void)
pthread_mutex_init(&SysEventThreadMutex, NULL);
pthread_cond_init(&SysEventThreadCond, NULL);
- pthread_create(&SysEventThread, NULL, (void *(*)())sysEventThreadEntry, NULL);
+ pthread_create(&SysEventThread, NULL, (void *(*)(void *))sysEventThreadEntry, NULL);
/*
* Monitor for power source changes via dispatch queue...