diff -Nru cups-2.2.10/debian/changelog cups-2.2.10/debian/changelog --- cups-2.2.10/debian/changelog 2019-04-24 17:02:49.000000000 +0200 +++ cups-2.2.10/debian/changelog 2019-05-30 09:51:37.000000000 +0200 @@ -1,3 +1,11 @@ +cups (2.2.10-4ubuntu2) disco; urgency=medium + + * d/p/0045-Fix-an-issue-with-PreserveJobHistory-and-time-values.patch + Fix an issue with `PreserveJobHistory` and time values + (Issue #5538, Closes: #921741, LP: #1747765) + + -- Dariusz Gadomski Thu, 30 May 2019 09:51:37 +0200 + cups (2.2.10-4ubuntu1) disco; urgency=medium * d/p/systemd-service-for-cupsd-after-sssd.patch: Start cupsd after sssd if diff -Nru cups-2.2.10/debian/patches/0045-Fix-an-issue-with-PreserveJobHistory-and-time-values.patch cups-2.2.10/debian/patches/0045-Fix-an-issue-with-PreserveJobHistory-and-time-values.patch --- cups-2.2.10/debian/patches/0045-Fix-an-issue-with-PreserveJobHistory-and-time-values.patch 1970-01-01 01:00:00.000000000 +0100 +++ cups-2.2.10/debian/patches/0045-Fix-an-issue-with-PreserveJobHistory-and-time-values.patch 2019-05-30 09:51:37.000000000 +0200 @@ -0,0 +1,114 @@ +From 917e6f4ff70eed933c80d21eed4c6bfeb2cb68b7 Mon Sep 17 00:00:00 2001 +From: Michael R Sweet +Date: Mon, 11 Mar 2019 13:54:46 -0400 +Subject: Fix an issue with `PreserveJobHistory` and time values (Issue #5538) + +Closes: #921741 +--- + scheduler/job.c | 36 ++++++++++++++++++------------------ + 1 file changed, 18 insertions(+), 18 deletions(-) + +diff --git a/scheduler/job.c b/scheduler/job.c +index cc9283fb8..d4793cbb1 100644 +--- a/scheduler/job.c ++++ b/scheduler/job.c +@@ -437,10 +437,20 @@ cupsdCleanJobs(void) + curtime = time(NULL); + JobHistoryUpdate = 0; + ++ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCleanJobs: curtime=%d", (int)curtime); ++ + for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); + job; + job = (cupsd_job_t *)cupsArrayNext(Jobs)) + { ++ cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCleanJobs: Job %d, state=%d, printer=%p, history_time=%d, file_time=%d", job->id, (int)job->state_value, (void *)job->printer, (int)job->history_time, (int)job->file_time); ++ ++ if ((job->history_time && job->history_time) < JobHistoryUpdate || !JobHistoryUpdate) ++ JobHistoryUpdate = job->history_time; ++ ++ if ((job->file_time && job->file_time < JobHistoryUpdate) || !JobHistoryUpdate) ++ JobHistoryUpdate = job->file_time; ++ + if (job->state_value >= IPP_JOB_CANCELED && !job->printer) + { + /* +@@ -456,21 +466,9 @@ cupsdCleanJobs(void) + else if (job->file_time && job->file_time <= curtime) + { + cupsdLogJob(job, CUPSD_LOG_DEBUG, "Removing document files."); +- cupsdLogJob(job, CUPSD_LOG_DEBUG2, "curtime=%ld, job->file_time=%ld", (long)curtime, (long)job->file_time); + remove_job_files(job); + + cupsdMarkDirty(CUPSD_DIRTY_JOBS); +- +- if (job->history_time < JobHistoryUpdate || !JobHistoryUpdate) +- JobHistoryUpdate = job->history_time; +- } +- else +- { +- if (job->history_time < JobHistoryUpdate || !JobHistoryUpdate) +- JobHistoryUpdate = job->history_time; +- +- if (job->file_time < JobHistoryUpdate || !JobHistoryUpdate) +- JobHistoryUpdate = job->file_time; + } + } + } +@@ -1729,7 +1727,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ + job->completed_time = attr->values[0].integer; + + if (JobHistory < INT_MAX) +- job->history_time = attr->values[0].integer + JobHistory; ++ job->history_time = job->completed_time + JobHistory; + else + job->history_time = INT_MAX; + +@@ -1740,7 +1738,7 @@ cupsdLoadJob(cupsd_job_t *job) /* I - Job */ + JobHistoryUpdate = job->history_time; + + if (JobFiles < INT_MAX) +- job->file_time = attr->values[0].integer + JobFiles; ++ job->file_time = job->completed_time + JobFiles; + else + job->file_time = INT_MAX; + +@@ -2862,8 +2860,10 @@ cupsdUpdateJobs(void) + * Update history/file expiration times... + */ + ++ job->completed_time = attr->values[0].integer; ++ + if (JobHistory < INT_MAX) +- job->history_time = attr->values[0].integer + JobHistory; ++ job->history_time = job->completed_time + JobHistory; + else + job->history_time = INT_MAX; + +@@ -2877,7 +2877,7 @@ cupsdUpdateJobs(void) + JobHistoryUpdate = job->history_time; + + if (JobFiles < INT_MAX) +- job->file_time = attr->values[0].integer + JobFiles; ++ job->file_time = job->completed_time + JobFiles; + else + job->file_time = INT_MAX; + +@@ -4693,7 +4693,7 @@ set_time(cupsd_job_t *job, /* I - Job to update */ + job->completed_time = curtime; + + if (JobHistory < INT_MAX && attr) +- job->history_time = attr->values[0].integer + JobHistory; ++ job->history_time = job->completed_time + JobHistory; + else + job->history_time = INT_MAX; + +@@ -4701,7 +4701,7 @@ set_time(cupsd_job_t *job, /* I - Job to update */ + JobHistoryUpdate = job->history_time; + + if (JobFiles < INT_MAX && attr) +- job->file_time = curtime + JobFiles; ++ job->file_time = job->completed_time + JobFiles; + else + job->file_time = INT_MAX; + diff -Nru cups-2.2.10/debian/patches/series cups-2.2.10/debian/patches/series --- cups-2.2.10/debian/patches/series 2019-04-24 17:02:49.000000000 +0200 +++ cups-2.2.10/debian/patches/series 2019-05-30 09:51:37.000000000 +0200 @@ -42,3 +42,4 @@ 0042-Fix-potential-unaligned-accesses-in-the-string-pool-.patch manpage-translations.patch systemd-service-for-cupsd-after-sssd.patch +0045-Fix-an-issue-with-PreserveJobHistory-and-time-values.patch