~ubuntu-branches/ubuntu/vivid/logrotate/vivid

« back to all changes in this revision

Viewing changes to debian/patches/compressutime.patch

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2008-11-07 14:57:09 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081107145709-s8ktufsiktmkuidl
Tags: 3.7.7-1ubuntu1
* Merge with Debian experimental (LP: #64964). Remaining Ubuntu changes:
  - debian/control: Drop mailx to Suggests for Ubuntu; it's only used on
    request, and we don't configure an MTA by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
Preserve mtime/atime on compression. (Closes: #286957)
2
2
 
3
 
--- ./logrotate.c       2005-09-03 14:07:42.000000000 +0100
4
 
+++ /tmp/dpep-work.m2M7hf/logrotate-3.7.1/logrotate.c   2005-09-03 14:08:14.000000000 +0100
5
 
@@ -12,6 +12,8 @@
6
 
 #include <time.h>
 
3
Index: logrotate-3.7.7/logrotate.c
 
4
===================================================================
 
5
--- logrotate-3.7.7.orig/logrotate.c    2008-11-07 01:05:42.151555014 +0000
 
6
+++ logrotate-3.7.7/logrotate.c 2008-11-07 01:08:18.323555342 +0000
 
7
@@ -14,6 +14,8 @@
7
8
 #include <unistd.h>
8
9
 #include <glob.h>
 
10
 #include <locale.h>
9
11
+#include <sys/types.h>
10
12
+#include <utime.h>
11
13
 
12
14
 #ifdef WITH_SELINUX
13
15
 #include <selinux/selinux.h>
14
 
@@ -120,6 +122,7 @@
15
 
 static int compressLogFile(char * name, logInfo * log, struct stat *sb) {
16
 
     char * compressedName;
17
 
     const char ** fullCommand;
 
16
@@ -218,6 +220,7 @@
 
17
 {
 
18
     char *compressedName;
 
19
     const char **fullCommand;
18
20
+    struct utimbuf utim;
19
21
     int inFile;
20
22
     int outFile;
21
23
     int i;
22
 
@@ -190,6 +193,12 @@
23
 
        message(MESS_ERROR, "failed to compress log %s\n", name);
 
24
@@ -269,6 +272,12 @@
24
25
        return 1;
25
26
     }
26
 
+   
 
27
 
27
28
+    utim.actime = sb->st_atime;
28
29
+    utim.modtime = sb->st_mtime;
29
30
+    utime(compressedName,&utim);
30
31
+    /* If we can't change atime/mtime, it's not a disaster.
31
32
+       It might possibly fail under SELinux. */
32
 
 
33
 
     unlink(name);
34
 
 
 
33
+
 
34
     shred_file(name, log);
 
35
 
 
36
     return 0;