~ubuntu-branches/ubuntu/utopic/cups/utopic

« back to all changes in this revision

Viewing changes to .pc/no-conffile-timestamp.patch/scheduler/job.c

  • Committer: Package Import Robot
  • Author(s): Didier Raboud, Till Kamppeter, Steve Langasek, Didier Raboud
  • Date: 2014-01-03 18:42:39 UTC
  • mfrom: (1.3.2)
  • mto: This revision was merged to the branch mainline in revision 142.
  • Revision ID: package-import@ubuntu.com-20140103184239-juzq32ckr7ra49b3
* New 1.7.0 upstream release

[ Till Kamppeter ]
* Refresh most patches with quilt
* Removed usb-backend-do-not-crash-if-usb-disabled-in-bios and
  cupsd-no-crash-on-avahi-threaded-poll-shutdown patches as they got
  applied upstream
* Removed drop-arch-specifics-from-doc patch as it is not needed
  anymore
* Updated drop_unnecessary_dependencies, manpage-hyphen-minus,
  manpage-translations and ppd-poll-with-client-conf patches manually
  to apply to the new CUPS version
* Added error counting exception from
  usb-backend-do-not-crash-if-usb-disabled-in-bios to
  tests-ignore-warnings
* Install the newly added ippfind utility and its manpage in
  cups-client
* Added pwg.h to libcups2-dev package
* Call dh_auto_clean only if the file Makedefs is present, to avoid a
  FTBFS
* Added color management extensions from Joe Simon's GSoC 2013
  project.
* Patch cups-files.conf to activate CUPS daemon syncing of files when
  closing, so that config files (like printers.conf) do not
  mysteriously disappear (LP: #1157972)
* In the AppArmor profile, allow execution of programs in
  /etc/cups/interfaces/, needed to make CUPS working with queues based
  on System V interface scripts, especially PPD-less queues
  auto-generated by cups-browsed from cups-filters 1.0.41 on.
* Silenced AppArmor noise from udev.conf in syslog (LP: #1229766)

[ Steve Langasek ]
* Add cups-filters (>= 1.0.42) as alternative to foomatic-filters
  (which is deprecated) in package relationships

[ Didier Raboud ]
* Remove Roger Leigh from uploaders on his request with thanks for his
  past work!
* Switch avahi LSB Should-Start dependency to be avahi-daemon; also
  bump package relationship to >= 0.6.31-3~ (Closes: #731608)
* Refresh the manpage translation files
* Move the USB backend quirk rules file to cups-server-common
* Add 38 new 1.7.0 libcups2 symbols
* Mark one C++ libcupsppdc1 symbol as optional as it isn't exported in
  1.7.0 anymore
* Import Fedora patches:
  - to avoid sign-extending CRCs in gz decompression
  - to build with full read-only relocations
  - to fix job history logging (upstream patch)
  - to set the internal default for SyncOnClose to Yes, instead of
    only configuring it to Yes
  - to fix a stringpool corruption issue
  - to prevent USB timeouts causing incorrect print output
* Import Fedora patch updates:
  - to dont-use-dbus-from-two-threads patch so it removes a call to
    avahi_threaded_poll_stop()
  - to avoid_stale_lockfile_in_dbus_notifier patch to call _exit when
    handling SIGTERM
* Move manpage-translations patch at the very end of the patch series
  to have it include all our patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * "$Id: job.c 11173 2013-07-23 12:31:34Z msweet $"
 
2
 * "$Id: job.c 11147 2013-07-17 02:54:31Z msweet $"
3
3
 *
4
4
 *   Job management routines for the CUPS scheduler.
5
5
 *
598
598
 
599
599
  memset(job->filters, 0, sizeof(job->filters));
600
600
 
601
 
 
602
601
  if (job->printer->raw)
603
602
  {
604
603
   /*
672
671
                   "FINAL_CONTENT_TYPE=%s/%s", filter->dst->super,
673
672
                   filter->dst->type);
674
673
      }
 
674
      else
 
675
        snprintf(final_content_type, sizeof(final_content_type),
 
676
                 "FINAL_CONTENT_TYPE=printer/%s", job->printer->name);
675
677
    }
676
678
 
677
679
   /*
941
943
                          IPP_TAG_LANGUAGE);
942
944
 
943
945
#ifdef __APPLE__
944
 
  strcpy(apple_language, "APPLE_LANGUAGE=");
 
946
  strlcpy(apple_language, "APPLE_LANGUAGE=", sizeof(apple_language));
945
947
  _cupsAppleLanguage(attr->values[0].string.text,
946
948
                     apple_language + 15, sizeof(apple_language) - 15);
947
949
#endif /* __APPLE__ */
954
956
        * the POSIX locale...
955
957
        */
956
958
 
957
 
        strcpy(lang, "LANG=C");
 
959
        strlcpy(lang, "LANG=C", sizeof(lang));
958
960
        break;
959
961
 
960
962
    case 2 :
1012
1014
      * All of these strcpy's are safe because we allocated the psr string...
1013
1015
      */
1014
1016
 
1015
 
      strcpy(printer_state_reasons, "PRINTER_STATE_REASONS=");
 
1017
      strlcpy(printer_state_reasons, "PRINTER_STATE_REASONS=", psrlen);
1016
1018
      for (psrptr = printer_state_reasons + 22, i = 0;
1017
1019
           i < job->printer->num_reasons;
1018
1020
           i ++)
1019
1021
      {
1020
1022
        if (i)
1021
1023
          *psrptr++ = ',';
1022
 
        strcpy(psrptr, job->printer->reasons[i]);
 
1024
        strlcpy(psrptr, job->printer->reasons[i],
 
1025
                psrlen - (psrptr - printer_state_reasons));
1023
1026
        psrptr += strlen(psrptr);
1024
1027
      }
1025
1028
    }
1131
1134
  * Now create processes for all of the filters...
1132
1135
  */
1133
1136
 
1134
 
  cupsdSetPrinterReasons(job->printer, "-cups-missing-filter-warning,"
1135
 
                                       "cups-insecure-filter-warning");
1136
 
 
1137
1137
  for (i = 0, slot = 0, filter = (mime_filter_t *)cupsArrayFirst(filters);
1138
1138
       filter;
1139
1139
       i ++, filter = (mime_filter_t *)cupsArrayNext(filters))
1892
1892
                                                 fileid);
1893
1893
        }
1894
1894
 
 
1895
        if (compressions)
 
1896
          job->compressions = compressions;
 
1897
 
 
1898
        if (filetypes)
 
1899
          job->filetypes = filetypes;
 
1900
 
1895
1901
        if (!compressions || !filetypes)
1896
1902
        {
1897
1903
          cupsdLogMessage(CUPSD_LOG_ERROR,
1901
1907
          ippDelete(job->attrs);
1902
1908
          job->attrs = NULL;
1903
1909
 
1904
 
          if (compressions)
1905
 
            free(compressions);
1906
 
 
1907
 
          if (filetypes)
1908
 
            free(filetypes);
1909
 
 
1910
1910
          if (job->compressions)
1911
1911
          {
1912
1912
            free(job->compressions);
1923
1923
          return (0);
1924
1924
        }
1925
1925
 
1926
 
        job->compressions = compressions;
1927
 
        job->filetypes    = filetypes;
1928
 
        job->num_files    = fileid;
 
1926
        job->num_files = fileid;
1929
1927
      }
1930
1928
 
1931
1929
      job->filetypes[fileid - 1] = mimeFileType(MimeDatabase, jobfile, NULL,
3068
3066
        job_state = IPP_JOB_COMPLETED;
3069
3067
        message   = "Job completed.";
3070
3068
 
3071
 
        ippSetString(job->attrs, &job->reasons, 0,
3072
 
                     "job-completed-successfully");
 
3069
        if (!job->status)
 
3070
          ippSetString(job->attrs, &job->reasons, 0,
 
3071
                       "job-completed-successfully");
3073
3072
        break;
3074
3073
 
3075
3074
    case IPP_JOB_STOPPED :
3255
3254
            * Hold the job...
3256
3255
            */
3257
3256
 
3258
 
            cupsdSetJobHoldUntil(job, "indefinite", 1);
3259
 
            ippSetString(job->attrs, &job->reasons, 0,
3260
 
                         "job-hold-until-specified");
3261
 
 
3262
 
            job_state = IPP_JOB_HELD;
3263
 
            message   = "Job held indefinitely due to backend errors; please "
 
3257
            const char *reason = ippGetString(job->reasons, 0, NULL);
 
3258
 
 
3259
            cupsdLogJob(job, CUPSD_LOG_DEBUG, "job-state-reasons=\"%s\"",
 
3260
                        reason);
 
3261
 
 
3262
            if (!reason || strncmp(reason, "account-", 8))
 
3263
            {
 
3264
              cupsdSetJobHoldUntil(job, "indefinite", 1);
 
3265
 
 
3266
              ippSetString(job->attrs, &job->reasons, 0,
 
3267
                           "job-hold-until-specified");
 
3268
              message = "Job held indefinitely due to backend errors; please "
3264
3269
                        "consult the error_log file for details.";
 
3270
            }
 
3271
            else if (!strcmp(reason, "account-info-needed"))
 
3272
            {
 
3273
              cupsdSetJobHoldUntil(job, "indefinite", 0);
 
3274
 
 
3275
              message = "Job held indefinitely - account information is "
 
3276
                        "required.";
 
3277
            }
 
3278
            else if (!strcmp(reason, "account-closed"))
 
3279
            {
 
3280
              cupsdSetJobHoldUntil(job, "indefinite", 0);
 
3281
 
 
3282
              message = "Job held indefinitely - account has been closed.";
 
3283
            }
 
3284
            else if (!strcmp(reason, "account-limit-reached"))
 
3285
            {
 
3286
              cupsdSetJobHoldUntil(job, "indefinite", 0);
 
3287
 
 
3288
              message = "Job held indefinitely - account limit has been "
 
3289
                        "reached.";
 
3290
            }
 
3291
            else
 
3292
            {
 
3293
              cupsdSetJobHoldUntil(job, "indefinite", 0);
 
3294
 
 
3295
              message = "Job held indefinitely - account authorization failed.";
 
3296
            }
 
3297
 
 
3298
            job_state = IPP_JOB_HELD;
3265
3299
          }
3266
3300
          break;
3267
3301
 
3295
3329
            job_state = IPP_JOB_HELD;
3296
3330
            message   = "Job held for authentication.";
3297
3331
 
3298
 
            ippSetString(job->attrs, &job->reasons, 0,
3299
 
                         "cups-held-for-authentication");
 
3332
            if (strncmp(job->reasons->values[0].string.text, "account-", 8))
 
3333
              ippSetString(job->attrs, &job->reasons, 0,
 
3334
                           "cups-held-for-authentication");
3300
3335
          }
3301
3336
          break;
3302
3337
 
3480
3515
                        "com.apple.print.DocumentTicket.PMSpoolFormat",
3481
3516
                        IPP_TAG_ZERO) &&
3482
3517
      !ippFindAttribute(job->attrs, "APPrinterPreset", IPP_TAG_ZERO) &&
3483
 
      (ippFindAttribute(job->attrs, "output-mode", IPP_TAG_ZERO) ||
3484
 
       ippFindAttribute(job->attrs, "print-color-mode", IPP_TAG_ZERO) ||
 
3518
      (ippFindAttribute(job->attrs, "print-color-mode", IPP_TAG_ZERO) ||
3485
3519
       ippFindAttribute(job->attrs, "print-quality", IPP_TAG_ZERO)))
3486
3520
  {
3487
3521
   /*
3488
 
    * Map output-mode and print-quality to a preset...
 
3522
    * Map print-color-mode and print-quality to a preset...
3489
3523
    */
3490
3524
 
3491
3525
    if ((attr = ippFindAttribute(job->attrs, "print-color-mode",
3492
 
                                 IPP_TAG_KEYWORD)) == NULL)
3493
 
      attr = ippFindAttribute(job->attrs, "output-mode", IPP_TAG_KEYWORD);
3494
 
 
3495
 
    if (attr && !strcmp(attr->values[0].string.text, "monochrome"))
 
3526
                                 IPP_TAG_KEYWORD)) != NULL &&
 
3527
        !strcmp(attr->values[0].string.text, "monochrome"))
3496
3528
      print_color_mode = _PWG_PRINT_COLOR_MODE_MONOCHROME;
3497
3529
    else
3498
3530
      print_color_mode = _PWG_PRINT_COLOR_MODE_COLOR;
3679
3711
          attr->value_tag == IPP_TAG_MIMETYPE ||
3680
3712
          attr->value_tag == IPP_TAG_NAMELANG ||
3681
3713
          attr->value_tag == IPP_TAG_TEXTLANG ||
3682
 
          (attr->value_tag == IPP_TAG_URI && strcmp(attr->name, "job-uuid")) ||
 
3714
          (attr->value_tag == IPP_TAG_URI && strcmp(attr->name, "job-uuid") &&
 
3715
           strcmp(attr->name, "job-authorization-uri")) ||
3683
3716
          attr->value_tag == IPP_TAG_URISCHEME ||
3684
3717
          attr->value_tag == IPP_TAG_BEGIN_COLLECTION) /* Not yet supported */
3685
3718
        continue;
3694
3727
        continue;
3695
3728
 
3696
3729
      if (!strncmp(attr->name, "job-", 4) &&
 
3730
          strcmp(attr->name, "job-account-id") &&
 
3731
          strcmp(attr->name, "job-accounting-user-id") &&
 
3732
          strcmp(attr->name, "job-authorization-uri") &&
3697
3733
          strcmp(attr->name, "job-billing") &&
3698
3734
          strcmp(attr->name, "job-impressions") &&
3699
3735
          strcmp(attr->name, "job-originating-host-name") &&
 
3736
          strcmp(attr->name, "job-password") &&
 
3737
          strcmp(attr->name, "job-password-encryption") &&
3700
3738
          strcmp(attr->name, "job-uuid") &&
3701
3739
          !(job->printer->type & CUPS_PRINTER_REMOTE))
3702
3740
        continue;
3803
3841
  for (i = num_pwgppds, pwgppd = pwgppds; i > 0; i --, pwgppd ++)
3804
3842
  {
3805
3843
    *optptr++ = ' ';
3806
 
    strcpy(optptr, pwgppd->name);
 
3844
    strlcpy(optptr, pwgppd->name, optlength - (optptr - options));
3807
3845
    optptr += strlen(optptr);
3808
3846
    *optptr++ = '=';
3809
 
    strcpy(optptr, pwgppd->value);
 
3847
    strlcpy(optptr, pwgppd->value, optlength - (optptr - options));
3810
3848
    optptr += strlen(optptr);
3811
3849
  }
3812
3850
 
4182
4220
                      line, linenum);
4183
4221
  }
4184
4222
 
 
4223
  if (job)
 
4224
  {
 
4225
    cupsdLogMessage(CUPSD_LOG_ERROR,
 
4226
                    "Missing </Job> directive on line %d.", linenum);
 
4227
    cupsdDeleteJob(job, CUPSD_JOB_PURGE);
 
4228
  }
 
4229
 
4185
4230
  cupsFileClose(fp);
4186
4231
}
4187
4232
 
4343
4388
  {
4344
4389
    snprintf(filename, sizeof(filename), "%s/d%05d-%03d", RequestRoot,
4345
4390
             job->id, i);
4346
 
    if (Classification)
4347
 
      cupsdRemoveFile(filename);
4348
 
    else
4349
 
      unlink(filename);
 
4391
    cupsdUnlinkOrRemoveFile(filename);
4350
4392
  }
4351
4393
 
4352
4394
  free(job->filetypes);
4377
4419
 
4378
4420
  snprintf(filename, sizeof(filename), "%s/c%05d", RequestRoot,
4379
4421
           job->id);
4380
 
  if (Classification)
4381
 
    cupsdRemoveFile(filename);
4382
 
  else
4383
 
    unlink(filename);
 
4422
  cupsdUnlinkOrRemoveFile(filename);
4384
4423
 
4385
4424
  LastEvent |= CUPSD_EVENT_PRINTER_STATE_CHANGED;
4386
4425
}
4440
4479
start_job(cupsd_job_t     *job,         /* I - Job ID */
4441
4480
          cupsd_printer_t *printer)     /* I - Printer to print job */
4442
4481
{
 
4482
  const char    *filename;              /* Support filename */
 
4483
 
 
4484
 
4443
4485
  cupsdLogMessage(CUPSD_LOG_DEBUG2, "start_job(job=%p(%d), printer=%p(%s))",
4444
4486
                  job, job->id, printer, printer->name);
4445
4487
 
4494
4536
    job->cancel_time = 0;
4495
4537
 
4496
4538
 /*
 
4539
  * Check for support files...
 
4540
  */
 
4541
 
 
4542
  cupsdSetPrinterReasons(job->printer, "-cups-missing-filter-warning,"
 
4543
                                       "cups-insecure-filter-warning");
 
4544
 
 
4545
  if (printer->pc)
 
4546
  {
 
4547
    for (filename = (const char *)cupsArrayFirst(printer->pc->support_files);
 
4548
         filename;
 
4549
         filename = (const char *)cupsArrayNext(printer->pc->support_files))
 
4550
    {
 
4551
      if (_cupsFileCheck(filename, _CUPS_FILE_CHECK_FILE, !RunUser,
 
4552
                         cupsdLogFCMessage, printer))
 
4553
        break;
 
4554
    }
 
4555
  }
 
4556
 
 
4557
 /*
4497
4558
  * Setup the last exit status and security profiles...
4498
4559
  */
4499
4560
 
4741
4802
        cupsdAddEvent(CUPSD_EVENT_JOB_PROGRESS, job->printer, job,
4742
4803
                      "Printed %d page(s).", job->sheets->values[0].integer);
4743
4804
    }
 
4805
    else if (loglevel == CUPSD_LOG_JOBSTATE)
 
4806
    {
 
4807
     /*
 
4808
      * Support "keyword" to set job-state-reasons to the specified keyword.
 
4809
      * This is sufficient for the current paid printing stuff.
 
4810
      */
 
4811
 
 
4812
      cupsdLogJob(job, CUPSD_LOG_DEBUG, "JOBSTATE: %s", message);
 
4813
 
 
4814
      ippSetString(job->attrs, &job->reasons, 0, message);
 
4815
    }
4744
4816
    else if (loglevel == CUPSD_LOG_STATE)
4745
4817
    {
4746
4818
      cupsdLogJob(job, CUPSD_LOG_DEBUG, "STATE: %s", message);
4781
4853
      cups_option_t     *attrs;         /* Attributes */
4782
4854
      const char        *attr;          /* Attribute */
4783
4855
 
4784
 
 
4785
4856
      cupsdLogJob(job, CUPSD_LOG_DEBUG, "ATTR: %s", message);
4786
4857
 
4787
4858
      num_attrs = cupsParseOptions(message, 0, &attrs);
4788
4859
 
 
4860
      if ((attr = cupsGetOption("auth-info-default", num_attrs,
 
4861
                                attrs)) != NULL)
 
4862
      {
 
4863
        job->printer->num_options = cupsAddOption("auth-info", attr,
 
4864
                                                  job->printer->num_options,
 
4865
                                                  &(job->printer->options));
 
4866
        cupsdSetPrinterAttrs(job->printer);
 
4867
 
 
4868
        cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
 
4869
      }
 
4870
 
4789
4871
      if ((attr = cupsGetOption("auth-info-required", num_attrs,
4790
4872
                                attrs)) != NULL)
4791
4873
      {
5121
5203
 
5122
5204
 
5123
5205
/*
5124
 
 * End of "$Id: job.c 11173 2013-07-23 12:31:34Z msweet $".
 
5206
 * End of "$Id: job.c 11147 2013-07-17 02:54:31Z msweet $".
5125
5207
 */