~ubuntu-branches/ubuntu/intrepid/logrotate/intrepid

« back to all changes in this revision

Viewing changes to debian/patches/rh-selinux.patch

  • Committer: Bazaar Package Importer
  • Author(s): Paul Martin
  • Date: 2006-04-08 23:02:19 UTC
  • mfrom: (3.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20060408230219-7moi9qw2g42w1nye
Tags: 3.7.1-3
* Patch debian/control to fix FTBFS on kfreebsd-amd64. Perhaps we need
  a build-depends macro for !kfreebsd. (Closes: #361465)
* Use and depend on debhelper version 5.
* Switch from dpatch to quilt.
* cpp-crossbuild.patch: change from using $(CPP) to $(CC) -E.
  Thanks to NIIBE Yutaka. (Closes: #284040)
* dst.patch: fix mktime initialisation so that daylight savings is
  taken into account. Thanks to Holger Weiss. (Closes: #278591)
* man-333996.patch: fix typos in logrotate.8 where "then" should be
  "than". Thanks to Adrian Knoth. (Closes: #333996)
* manpage.patch: Apply missed fixes from #101272. Thanks to J S Bygott.
  (Closes: #335060)
* script-argument.patch: Allow the use of $1 in scripts again.
  (Closes: #330783)
* README.Debian: Document that sysklogd does its own log rotation.
  (Closes: #308963)
* README.Debian: Document how scripts are called. (Closes: #308920)
* Update the copyright file.
* debian/control: remove versioned dependency on cron. The version of
  cron forbidden pre-dates woody (currently "oldstable") by several
  years. This versioned dependency is preventing logrotate being
  installed with bcron. (Closes: #304038, #349150)
* debian/rules: Fix backports, allowing them to use selinux.
  (Closes: #340363)
* uncompressChild-warning.patch: Fix a "might be used uninitialised" 
  warning from gcc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Add selinux_getenforce() calls to work when not in enforcing mode
 
2
- use security_getenforce() instead of selinux_getenforcemode
 
3
From RedHat patches.
 
4
 
 
5
Index: logrotate-3.7.1/logrotate.c
 
6
===================================================================
 
7
--- logrotate-3.7.1.orig/logrotate.c    2006-04-08 20:42:37.114533654 +0100
 
8
+++ logrotate-3.7.1/logrotate.c 2006-04-08 20:44:17.311634566 +0100
 
9
@@ -17,6 +17,7 @@
 
10
 #include <selinux/selinux.h>
 
11
 static security_context_t prev_context=NULL;
 
12
 int selinux_enabled=0;
 
13
+int selinux_enforce=0;
 
14
 #endif
 
15
 
 
16
 #include "basenames.h"
 
17
@@ -293,38 +294,43 @@
 
18
            return 1;
 
19
        }
 
20
 #ifdef WITH_SELINUX
 
21
-       if ((selinux_enabled=(is_selinux_enabled()>0)))
 
22
-         {
 
23
-           security_context_t oldContext;
 
24
-           if (fgetfilecon(fdcurr, &oldContext) >=0) {
 
25
-             if (getfscreatecon(&prev_context) < 0) {
 
26
-               message(MESS_ERROR, "error getting default context: %s\n", 
 
27
-                       strerror(errno));
 
28
-               freecon(oldContext);
 
29
-               return 1;
 
30
-             }
 
31
-             if (setfscreatecon(oldContext) < 0) {
 
32
-               message(MESS_ERROR, "error setting file context %s to %s: %s\n", 
 
33
-                       saveLog, oldContext,strerror(errno));
 
34
-               freecon(oldContext);
 
35
-               return 1;
 
36
-             }
 
37
-             freecon(oldContext);
 
38
-           } else {
 
39
-             message(MESS_ERROR, "error getting file context %s: %s\n", currLog,
 
40
-                     strerror(errno));
 
41
-             return 1;
 
42
-           }
 
43
-         }
 
44
+       if (selinux_enabled) {
 
45
+               security_context_t oldContext;
 
46
+               if (fgetfilecon(fdcurr, &oldContext) >=0) {
 
47
+                       if (getfscreatecon(&prev_context) < 0) {
 
48
+                               message(MESS_ERROR, "error getting default context: %s\n", 
 
49
+                                       strerror(errno));
 
50
+                               if (selinux_enforce) {
 
51
+                                       freecon(oldContext);
 
52
+                                       return 1;
 
53
+                               }
 
54
+                       }
 
55
+                       if (setfscreatecon(oldContext) < 0) {
 
56
+                               message(MESS_ERROR, "error setting file context %s to %s: %s\n", 
 
57
+                                       saveLog, oldContext,strerror(errno));
 
58
+                               if (selinux_enforce) {
 
59
+                                       freecon(oldContext);
 
60
+                                       return 1;
 
61
+                               }
 
62
+                       }
 
63
+                       freecon(oldContext);
 
64
+               } else {
 
65
+                       message(MESS_ERROR, "error getting file context %s: %s\n", currLog,
 
66
+                               strerror(errno));
 
67
+                       if (selinux_enforce) {
 
68
+                               return 1;
 
69
+                       }
 
70
+               }
 
71
+       }
 
72
 #endif
 
73
        fdsave = open(saveLog, O_WRONLY | O_CREAT | O_TRUNC,sb->st_mode);
 
74
 #ifdef WITH_SELINUX
 
75
        if (selinux_enabled) {
 
76
-         setfscreatecon(prev_context);
 
77
-         if (prev_context!= NULL) {
 
78
-           freecon(prev_context);
 
79
-           prev_context=NULL;
 
80
-         }
 
81
+               setfscreatecon(prev_context);
 
82
+               if (prev_context!= NULL) {
 
83
+                       freecon(prev_context);
 
84
+                       prev_context=NULL;
 
85
+               }
 
86
        }
 
87
 #endif
 
88
        if (fdsave < 0) {
 
89
@@ -672,28 +678,34 @@
 
90
            (log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext);
 
91
     
 
92
 #ifdef WITH_SELINUX
 
93
-    if ((selinux_enabled=(is_selinux_enabled()>0))) {
 
94
-      security_context_t oldContext=NULL;
 
95
-      if (getfilecon(log->files[logNum], &oldContext)>0) {
 
96
-       if (getfscreatecon(&prev_context) < 0) {
 
97
-         message(MESS_ERROR, "error getting default context: %s\n", 
 
98
-                 strerror(errno));
 
99
-         freecon(oldContext);
 
100
-         return 1;
 
101
-       }
 
102
-       if (setfscreatecon(oldContext) < 0) {
 
103
-         message(MESS_ERROR, "error setting file context %s to %s: %s\n", 
 
104
-                 log->files[logNum], oldContext,strerror(errno));
 
105
-         freecon(oldContext);
 
106
-         return 1;
 
107
-       }
 
108
-       freecon(oldContext);
 
109
-      } else {
 
110
-       message(MESS_ERROR, "error getting file context %s: %s\n", 
 
111
-               log->files[logNum], 
 
112
-               strerror(errno));
 
113
-       return 1;
 
114
-      }
 
115
+    if (selinux_enabled) {
 
116
+           security_context_t oldContext=NULL;
 
117
+           if (getfilecon(log->files[logNum], &oldContext)>0) {
 
118
+                   if (getfscreatecon(&prev_context) < 0) {
 
119
+                           message(MESS_ERROR, "error getting default context: %s\n", 
 
120
+                                   strerror(errno));
 
121
+                           if (selinux_enforce) {
 
122
+                                   freecon(oldContext);
 
123
+                                   return 1;
 
124
+                           }
 
125
+                   }
 
126
+                   if (setfscreatecon(oldContext) < 0) {
 
127
+                           message(MESS_ERROR, "error setting file context %s to %s: %s\n", 
 
128
+                                   log->files[logNum], oldContext,strerror(errno));
 
129
+                           if (selinux_enforce) {
 
130
+                                   freecon(oldContext);
 
131
+                                   return 1;
 
132
+                           }
 
133
+                   }
 
134
+                   freecon(oldContext);
 
135
+           } else {
 
136
+                   message(MESS_ERROR, "error getting file context %s: %s\n", 
 
137
+                           log->files[logNum], 
 
138
+                           strerror(errno));
 
139
+                   if (selinux_enforce) {
 
140
+                           return 1;
 
141
+                   }
 
142
+           }
 
143
     }
 
144
 #endif
 
145
     for (i = rotateCount + logStart - 1; (i >= 0) && !hasErrors; i--) {
 
146
@@ -883,11 +895,11 @@
 
147
     
 
148
 #ifdef WITH_SELINUX
 
149
        if (selinux_enabled) {
 
150
-         setfscreatecon(prev_context);
 
151
-         if (prev_context!= NULL) {
 
152
-           freecon(prev_context);
 
153
-           prev_context=NULL;
 
154
-         }
 
155
+               setfscreatecon(prev_context);
 
156
+               if (prev_context!= NULL) {
 
157
+                       freecon(prev_context);
 
158
+                       prev_context=NULL;
 
159
+               }
 
160
        }
 
161
 #endif
 
162
     free(dirName);
 
163
@@ -1249,6 +1261,10 @@
 
164
        exit(1);
 
165
     }
 
166
 
 
167
+#ifdef WITH_SELINUX
 
168
+    selinux_enabled=(is_selinux_enabled()>0);
 
169
+    selinux_enforce=security_getenforce();
 
170
+#endif
 
171
     for (file = files; *file; file++) {
 
172
        if (readConfigPath(*file, &defConfig, &logs, &numLogs)) {
 
173
            exit(1);