~ubuntu-branches/ubuntu/hardy/logrotate/hardy-updates

« back to all changes in this revision

Viewing changes to debian/patches/60-compressowner.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Paul Martin
  • Date: 2005-09-03 13:37:53 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050903133753-j413n48ft2od5fai
Tags: 3.7.1-2
* Patches:
  + 40-compressutime: Preserve mtime/atime on compression.
    (Closes: #286957)
  + 40-scripterrors: Give error messages identifying log file on
    script errors. (Closes: #122691, #195790, #222050, #306020)

* Patch debian/control to fix FTBFS on kfreebsd-i386. (Closes:
  #320331).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh -e
2
 
## 60-compressowner.dpatch by Paul Martin <pm@debian.org>
3
 
##
4
 
## All lines beginning with `## DP:' are a description of the patch.
5
 
## DP: No description.
6
 
 
7
 
if [ $# -lt 1 ]; then
8
 
    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
9
 
    exit 1
10
 
fi
11
 
 
12
 
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
13
 
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
14
 
 
15
 
case "$1" in
16
 
    -patch) patch -p1 ${patch_opts} < $0;;
17
 
    -unpatch) patch -R -p1 ${patch_opts} < $0;;
18
 
    *)
19
 
        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
20
 
        exit 1;;
21
 
esac
22
 
 
23
 
exit 0
24
 
 
25
 
@DPATCH@
26
 
diff -urNad /home/pm/deb/logrotate/logrotate-3.7/logrotate.c logrotate-3.7/logrotate.c
27
 
--- /home/pm/deb/logrotate/logrotate-3.7/logrotate.c    2004-05-10 19:30:36.000000000 +0100
28
 
+++ logrotate-3.7/logrotate.c   2004-05-10 19:31:04.000000000 +0100
29
 
@@ -128,6 +128,7 @@
30
 
     int outFile;
31
 
     int i;
32
 
     int status;
33
 
+    struct stat sb;
34
 
 
35
 
     fullCommand = alloca(sizeof(*fullCommand) * 
36
 
                         (log->compress_options_count + 2));
37
 
@@ -145,12 +146,22 @@
38
 
        return 1;
39
 
     }
40
 
     
41
 
-    if ((outFile = open(compressedName, O_RDWR | O_CREAT | O_TRUNC, 0666)) < 0) {
42
 
+    fstat(inFile, &sb);
43
 
+
44
 
+    if ((outFile = open(compressedName, O_RDWR | O_CREAT | O_TRUNC, sb.st_mode)) < 0) {
45
 
        message(MESS_ERROR, "unable to open %s for compressed output\n", 
46
 
                compressedName);
47
 
        close(inFile);
48
 
        return 1;
49
 
     }
50
 
+    
51
 
+    if (fchown(outFile, sb.st_uid, sb.st_gid)) {
52
 
+       message(MESS_ERROR, "unable to change owner of output file %s\n",
53
 
+               compressedName);
54
 
+       close(inFile);
55
 
+       close(outFile);
56
 
+       return 1;
57
 
+    }
58
 
 
59
 
     message(MESS_DEBUG, "compressing log with: %s\n", fullCommand[0]);
60