summaryrefslogtreecommitdiff
path: root/scheduler
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2009-03-07 16:36:03 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2009-03-07 16:36:03 +0000
commit1340db2dab0b5ac933dec4796637ca3baa10bb4b (patch)
treed6c9ec39af99e162ee755e6369b5c222d6349cd6 /scheduler
parentb9faaae17cfc7cd8dfd6e82cf607c05b2f4def68 (diff)
Merge changes from CUPS 1.4svn-r8414.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1277 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'scheduler')
-rw-r--r--scheduler/cupsd.h4
-rw-r--r--scheduler/cupsfilter.c40
-rw-r--r--scheduler/ipp.c6
-rw-r--r--scheduler/job.c61
-rw-r--r--scheduler/main.c22
-rw-r--r--scheduler/printers.c10
-rw-r--r--scheduler/process.c2
7 files changed, 104 insertions, 41 deletions
diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h
index e9d8df1f0..8da2d9616 100644
--- a/scheduler/cupsd.h
+++ b/scheduler/cupsd.h
@@ -152,8 +152,10 @@ typedef void (*cupsd_selfunc_t)(void *data);
* Globals...
*/
-VAR int TestConfigFile VALUE(0);
+VAR int TestConfigFile VALUE(0),
/* Test the cupsd.conf file? */
+ UseProfiles VALUE(1);
+ /* Use security profiles for child procs? */
VAR int MaxFDs VALUE(0);
/* Maximum number of files */
diff --git a/scheduler/cupsfilter.c b/scheduler/cupsfilter.c
index d3c30210a..17f6f89ea 100644
--- a/scheduler/cupsfilter.c
+++ b/scheduler/cupsfilter.c
@@ -86,7 +86,8 @@ static int compare_pids(mime_filter_t *a, mime_filter_t *b);
static char *escape_options(int num_options, cups_option_t *options);
static int exec_filter(const char *filter, char **argv,
char **envp, int infd, int outfd);
-static int exec_filters(cups_array_t *filters, const char *infile,
+static int exec_filters(mime_type_t *srctype,
+ cups_array_t *filters, const char *infile,
const char *outfile, const char *ppdfile,
const char *printer, const char *user,
const char *title, int num_options,
@@ -133,7 +134,8 @@ main(int argc, /* I - Number of command-line args */
const char *ppdfile; /* PPD file */
const char *title, /* Title string */
*user; /* Username */
- int removeppd, /* Remove PPD file */
+ int all_filters, /* Use all filters */
+ removeppd, /* Remove PPD file */
removeinfile; /* Remove input file */
int status; /* Execution status */
@@ -159,6 +161,7 @@ main(int argc, /* I - Number of command-line args */
ppdfile = NULL;
title = NULL;
user = cupsUser();
+ all_filters = 0;
removeppd = 0;
removeinfile = 0;
@@ -213,6 +216,10 @@ main(int argc, /* I - Number of command-line args */
removeinfile = 1;
break;
+ case 'e' : /* Use every filter from the PPD file */
+ all_filters = 1;
+ break;
+
case 'f' : /* Specify input file... */
i ++;
if (i < argc && !infile)
@@ -380,8 +387,16 @@ main(int argc, /* I - Number of command-line args */
return (1);
}
- printer_type = add_printer_filters(command, mime, printer, ppdfile,
- &prefilter_type);
+ if (all_filters)
+ {
+ printer_type = add_printer_filters(command, mime, printer, ppdfile,
+ &prefilter_type);
+ }
+ else
+ {
+ printer_type = mimeType(mime, "application", "vnd.cups-postscript");
+ prefilter_type = NULL;
+ }
/*
* Get the source and destination types...
@@ -429,6 +444,8 @@ main(int argc, /* I - Number of command-line args */
filters = cupsArrayNew(NULL, NULL);
cupsArrayAdd(filters, &GZIPFilter);
+ GZIPFilter.src = src;
+ GZIPFilter.dst = dst;
}
else if ((filters = mimeFilter(mime, src, dst, &cost)) == NULL)
{
@@ -456,7 +473,8 @@ main(int argc, /* I - Number of command-line args */
filter;
filter = (mime_filter_t *)cupsArrayNext(filters))
{
- if ((prefilter = mimeFilterLookup(mime, filter->src, prefilter_type)))
+ if ((prefilter = mimeFilterLookup(mime, filter->src,
+ prefilter_type)) != NULL)
cupsArrayAdd(prefilters, prefilter);
cupsArrayAdd(prefilters, filter);
@@ -470,7 +488,7 @@ main(int argc, /* I - Number of command-line args */
* Do it!
*/
- status = exec_filters(filters, infile, outfile, ppdfile, printer, user,
+ status = exec_filters(src, filters, infile, outfile, ppdfile, printer, user,
title, num_options, options);
/*
@@ -610,6 +628,8 @@ add_printer_filters(
if (ppdattr->value)
add_printer_filter(command, mime, *prefilter_type, ppdattr->value);
}
+ else
+ *prefilter_type = NULL;
return (printer_type);
}
@@ -789,7 +809,8 @@ exec_filter(const char *filter, /* I - Filter to execute */
*/
static int /* O - 0 on success, 1 on error */
-exec_filters(cups_array_t *filters, /* I - Array of filters to run */
+exec_filters(mime_type_t *srctype, /* I - Source type */
+ cups_array_t *filters, /* I - Array of filters to run */
const char *infile, /* I - File to filter */
const char *outfile, /* I - File to create */
const char *ppdfile, /* I - PPD file, if any */
@@ -833,9 +854,8 @@ exec_filters(cups_array_t *filters, /* I - Array of filters to run */
optstr = escape_options(num_options, options);
- filter = cupsArrayFirst(filters);
snprintf(content_type, sizeof(content_type), "CONTENT_TYPE=%s/%s",
- filter->src->super, filter->src->type);
+ srctype->super, srctype->type);
snprintf(cups_datadir, sizeof(cups_datadir), "CUPS_DATADIR=%s", DataDir);
snprintf(cups_fontpath, sizeof(cups_fontpath), "CUPS_FONTPATH=%s", FontPath);
snprintf(cups_serverbin, sizeof(cups_serverbin), "CUPS_SERVERBIN=%s",
@@ -1285,6 +1305,7 @@ usage(const char *command, /* I - Command name */
"Options:\n"
"\n"
" -c cupsd.conf Set cupsd.conf file to use\n"
+ " -e Use every filter from the PPD file\n"
" -j job-id[,N] Filter file N from the specified job (default is file 1)\n"
" -n copies Set number of copies\n"
" -o name=value Set option(s)\n"
@@ -1296,6 +1317,7 @@ usage(const char *command, /* I - Command name */
"\n"
"Options:\n"
"\n"
+ " -e Use every filter from the PPD file\n"
" -f filename Set file to be converted (otherwise stdin)\n"
" -o filename Set file to be generated (otherwise stdout)\n"
" -i mime/type Set input MIME type (otherwise auto-typed)\n"
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 3fc1f33b0..c0160e2e9 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -360,7 +360,8 @@ cupsdProcessIPPRequest(
*/
attr = con->request->attrs;
- if (attr && !strcmp(attr->name, "attributes-charset") &&
+ if (attr && attr->name &&
+ !strcmp(attr->name, "attributes-charset") &&
(attr->value_tag & IPP_TAG_MASK) == IPP_TAG_CHARSET)
charset = attr;
else
@@ -369,7 +370,8 @@ cupsdProcessIPPRequest(
if (attr)
attr = attr->next;
- if (attr && !strcmp(attr->name, "attributes-natural-language") &&
+ if (attr && attr->name &&
+ !strcmp(attr->name, "attributes-natural-language") &&
(attr->value_tag & IPP_TAG_MASK) == IPP_TAG_LANGUAGE)
language = attr;
else
diff --git a/scheduler/job.c b/scheduler/job.c
index 25ddffd9f..cd185c473 100644
--- a/scheduler/job.c
+++ b/scheduler/job.c
@@ -22,7 +22,6 @@
* cupsdCleanJobs() - Clean out old jobs.
* cupsdContinueJob() - Continue printing with the next file in a job.
* cupsdDeleteJob() - Free all memory used by a job.
- * cupsdFinishJob() - Finish a job.
* cupsdFreeAllJobs() - Free all jobs from memory.
* cupsdFindJob() - Find the specified job.
* cupsdGetPrinterJobCount() - Get the number of pending, processing, or held
@@ -491,7 +490,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
FilterLevel -= job->cost;
- filters = NULL;
+ filters = NULL;
if (job->printer->raw)
{
@@ -827,7 +826,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
* Just the language code (ll)...
*/
- snprintf(lang, sizeof(lang), "LANG=%s.UTF8",
+ snprintf(lang, sizeof(lang), "LANG=%s.UTF-8",
attr->values[0].string.text);
break;
@@ -836,7 +835,7 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
* Language and country code (ll-cc)...
*/
- snprintf(lang, sizeof(lang), "LANG=%c%c_%c%c.UTF8",
+ snprintf(lang, sizeof(lang), "LANG=%c%c_%c%c.UTF-8",
attr->values[0].string.text[0],
attr->values[0].string.text[1],
toupper(attr->values[0].string.text[3] & 255),
@@ -2481,9 +2480,40 @@ finalize_job(cupsd_job_t *job) /* I - Job */
* Process the exit status...
*/
- printer_state = IPP_PRINTER_IDLE;
- job_state = IPP_JOB_COMPLETED;
- message = "Job completed.";
+ if (job->printer->state == IPP_PRINTER_PROCESSING)
+ printer_state = IPP_PRINTER_IDLE;
+ else
+ printer_state = job->printer->state;
+
+ switch (job_state = job->state_value)
+ {
+ case IPP_JOB_PENDING :
+ message = "Job paused.";
+ break;
+
+ case IPP_JOB_HELD :
+ message = "Job held.";
+ break;
+
+ default :
+ case IPP_JOB_PROCESSING :
+ case IPP_JOB_COMPLETED :
+ job_state = IPP_JOB_COMPLETED;
+ message = "Job completed.";
+ break;
+
+ case IPP_JOB_STOPPED :
+ message = "Job stopped.";
+ break;
+
+ case IPP_JOB_CANCELED :
+ message = "Job canceled.";
+ break;
+
+ case IPP_JOB_ABORTED :
+ message = "Job aborted.";
+ break;
+ }
if (job->status < 0)
{
@@ -2741,8 +2771,8 @@ get_options(cupsd_job_t *job, /* I - Job */
optptr = options;
*optptr = '\0';
- snprintf(title, sizeof(title), "%s-%d", job->printer->name, job->id);
- strcpy(copies, "1");
+ snprintf(title, title_size, "%s-%d", job->printer->name, job->id);
+ strlcpy(copies, "1", copies_size);
for (attr = job->attrs->attrs; attr != NULL; attr = attr->next)
{
@@ -2754,12 +2784,12 @@ get_options(cupsd_job_t *job, /* I - Job */
*/
if (!banner_page)
- sprintf(copies, "%d", attr->values[0].integer);
+ snprintf(copies, copies_size, "%d", attr->values[0].integer);
}
else if (!strcmp(attr->name, "job-name") &&
(attr->value_tag == IPP_TAG_NAME ||
attr->value_tag == IPP_TAG_NAMELANG))
- strlcpy(title, attr->values[0].string.text, sizeof(title));
+ strlcpy(title, attr->values[0].string.text, title_size);
else if (attr->group_tag == IPP_TAG_JOB)
{
/*
@@ -3494,10 +3524,11 @@ start_job(cupsd_job_t *job, /* I - Job ID */
cupsdSetJobState(job, IPP_JOB_PROCESSING, CUPSD_JOB_DEFAULT, NULL);
cupsdSetPrinterState(printer, IPP_PRINTER_PROCESSING, 0);
- job->cost = 0;
- job->progress = 0;
- job->printer = printer;
- printer->job = job;
+ job->cost = 0;
+ job->current_file = 0;
+ job->progress = 0;
+ job->printer = printer;
+ printer->job = job;
/*
* Setup the last exit status and security profiles...
diff --git a/scheduler/main.c b/scheduler/main.c
index 437f0f5ba..ccc395211 100644
--- a/scheduler/main.c
+++ b/scheduler/main.c
@@ -145,8 +145,9 @@ main(int argc, /* I - Number of command-line args */
struct stat statbuf; /* Needed for checking lpsched FIFO */
#endif /* __sgi */
#ifdef __APPLE__
- int run_as_child = 0;
+ int run_as_child = 0,
/* Needed for Mac OS X fork/exec */
+ use_sysman = 1; /* Use system management functions? */
#else
time_t netif_time = 0; /* Time since last network update */
#endif /* __APPLE__ */
@@ -188,6 +189,11 @@ main(int argc, /* I - Number of command-line args */
switch (*opt)
{
#ifdef __APPLE__
+ case 'S' : /* Disable system management functions */
+ puts("Warning: -S (disable system management) for internal testing use only!");
+ use_sysman = 0;
+ break;
+
case 'C' : /* Run as child with config file */
run_as_child = 1;
fg = -1;
@@ -270,11 +276,16 @@ main(int argc, /* I - Number of command-line args */
break;
case 'p' : /* Stop immediately for profiling */
- puts("Warning: -p option is for internal testing use only!");
+ puts("Warning: -p (startup profiling) is for internal testing use only!");
stop_scheduler = 1;
fg = 1;
break;
+ case 'P' : /* Disable security profiles */
+ puts("Warning: -P (disable security profiles) is for internal testing use only!");
+ UseProfiles = 0;
+ break;
+
case 't' : /* Test the cupsd.conf file... */
TestConfigFile = 1;
fg = 1;
@@ -630,7 +641,8 @@ main(int argc, /* I - Number of command-line args */
* Start power management framework...
*/
- cupsdStartSystemMonitor();
+ if (use_sysman)
+ cupsdStartSystemMonitor();
#endif /* __APPLE__ */
/*
@@ -1149,7 +1161,8 @@ main(int argc, /* I - Number of command-line args */
* Stop monitoring system event monitoring...
*/
- cupsdStopSystemMonitor();
+ if (use_sysman)
+ cupsdStopSystemMonitor();
#endif /* __APPLE__ */
#ifdef HAVE_GSSAPI
@@ -1742,6 +1755,7 @@ process_children(void)
cupsdContinueJob(job);
}
}
+ break;
}
}
diff --git a/scheduler/printers.c b/scheduler/printers.c
index c826120f1..47142db2b 100644
--- a/scheduler/printers.c
+++ b/scheduler/printers.c
@@ -2015,7 +2015,7 @@ cupsdSetPrinterAttr(
* Don't allow empty values...
*/
- if (!*value)
+ if (!*value && strcmp(name, "marker-message"))
{
cupsdLogMessage(CUPSD_LOG_ERROR, "Ignoring empty \"%s\" attribute", name);
return;
@@ -2736,10 +2736,6 @@ cupsdSetPrinterReasons(
* Found a match, so remove it...
*/
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdSetPrinterReasons: Removing \"%s\" at index %d",
- reason, i);
-
p->num_reasons --;
_cupsStrFree(p->reasons[i]);
@@ -2779,10 +2775,6 @@ cupsdSetPrinterReasons(
return;
}
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdSetPrinterReasons: Adding \"%s\" at index %d",
- reason, i);
-
p->reasons[i] = _cupsStrAlloc(reason);
p->num_reasons ++;
diff --git a/scheduler/process.c b/scheduler/process.c
index bd548ff06..45d3bcfb6 100644
--- a/scheduler/process.c
+++ b/scheduler/process.c
@@ -83,7 +83,7 @@ cupsdCreateProfile(int job_id) /* I - Job ID or 0 for none */
temp[1024]; /* Quoted TempDir */
- if (RunUser)
+ if (!UseProfiles || RunUser)
{
/*
* Only use sandbox profiles as root...