]> git.pld-linux.org Git - packages/logrotate.git/commitdiff
- update selinux from fc8
authorElan Ruusamäe <glen@pld-linux.org>
Mon, 14 Apr 2008 10:37:14 +0000 (10:37 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    logrotate-selinux.patch -> 1.3
    logrotate.spec -> 1.85

logrotate-selinux.patch [new file with mode: 0644]
logrotate.spec

diff --git a/logrotate-selinux.patch b/logrotate-selinux.patch
new file mode 100644 (file)
index 0000000..15f219b
--- /dev/null
@@ -0,0 +1,128 @@
+diff -up logrotate-3.7.6/logrotate.c.selinux logrotate-3.7.6/logrotate.c
+--- logrotate-3.7.6/logrotate.c.selinux        2007-08-07 09:14:35.000000000 +0200
++++ logrotate-3.7.6/logrotate.c        2008-01-21 09:32:56.000000000 +0100
+@@ -409,15 +409,17 @@ static int copyTruncate(char *currLog, c
+       }
+ #ifdef WITH_SELINUX
+       if (selinux_enabled) {
+-          security_context_t oldContext;
++          security_context_t oldContext = NULL;
+           if (fgetfilecon_raw(fdcurr, &oldContext) >= 0) {
+               if (getfscreatecon_raw(&prev_context) < 0) {
+                   message(MESS_ERROR,
+                           "getting default context: %s\n",
+                           strerror(errno));
+                   if (selinux_enforce) {
+-                      freecon(oldContext);
+-                      return 1;
++                              if (oldContext != NULL) {
++                                      freecon(oldContext);
++                              }
++                              return 1;
+                   }
+               }
+               if (setfscreatecon_raw(oldContext) < 0) {
+@@ -425,11 +427,15 @@ static int copyTruncate(char *currLog, c
+                           "setting file context %s to %s: %s\n",
+                           saveLog, oldContext, strerror(errno));
+                   if (selinux_enforce) {
+-                      freecon(oldContext);
+-                      return 1;
++                              if (oldContext != NULL) {
++                                      freecon(oldContext);
++                              }
++                              return 1;
+                   }
+               }
+-              freecon(oldContext);
++              if (oldContext != NULL) {
++                      freecon(oldContext);
++              }
+           } else {
+                   if (errno != ENOTSUP) {
+                           message(MESS_ERROR, "getting file context %s: %s\n",
+@@ -899,6 +905,9 @@ int rotateSingleLog(logInfo * log, int l
+     int hasErrors = 0;
+     struct stat sb;
+     int fd;
++#ifdef WITH_SELINUX
++      security_context_t savedContext = NULL;
++#endif
+     if (!state->doRotate)
+       return 0;
+@@ -906,7 +915,57 @@ int rotateSingleLog(logInfo * log, int l
+     if (!hasErrors) {
+       if (!(log->flags & (LOG_FLAG_COPYTRUNCATE | LOG_FLAG_COPY))) {
+-          message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],
++#ifdef WITH_SELINUX
++              if (selinux_enabled) {
++                      security_context_t oldContext = NULL;
++                      int fdcurr = -1;
++
++                      if ((fdcurr = open(log->files[logNum], O_RDWR)) < 0) {
++                              message(MESS_ERROR, "error opening %s: %s\n",
++                                              log->files[logNum],
++                                      strerror(errno));
++                              return 1;
++                      }
++                      if (fgetfilecon_raw(fdcurr, &oldContext) >= 0) {
++                              if (getfscreatecon_raw(&savedContext) < 0) {
++                                      message(MESS_ERROR,
++                                              "getting default context: %s\n",
++                                              strerror(errno));
++                                      if (selinux_enforce) {
++                                              if (oldContext != NULL) {
++                                                      freecon(oldContext);
++                                              }
++                                              return 1;
++                                      }
++                              }
++                              if (setfscreatecon_raw(oldContext) < 0) {
++                                      message(MESS_ERROR,
++                                              "setting file context %s to %s: %s\n",
++                                              log->files[logNum], oldContext, strerror(errno));
++                                      if (selinux_enforce) {
++                                              if (oldContext != NULL) {
++                                                      freecon(oldContext);
++                                              }
++                                              return 1;
++                                      }
++                              }
++                              message(MESS_DEBUG, "fscreate context set to %s\n",
++                                              oldContext);
++                              if (oldContext != NULL) {
++                                      freecon(oldContext);
++                              }
++                      } else {
++                              if (errno != ENOTSUP) {
++                                      message(MESS_ERROR, "getting file context %s: %s\n",
++                                              log->files[logNum], strerror(errno));
++                                      if (selinux_enforce) {
++                                              return 1;
++                                      }
++                              }
++                      }
++              }
++#endif
++              message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],
+                   rotNames->finalName);
+           if (!debug && !hasErrors &&
+@@ -961,6 +1020,15 @@ int rotateSingleLog(logInfo * log, int l
+                     close(fd);
+           }
+       }
++#ifdef WITH_SELINUX
++      if (selinux_enabled) {
++          setfscreatecon_raw(savedContext);
++          if (savedContext != NULL) {
++                      freecon(savedContext);
++                      savedContext = NULL;
++          }
++      }
++#endif
+       if (!hasErrors
+           && log->flags & (LOG_FLAG_COPYTRUNCATE | LOG_FLAG_COPY))
index 21722f9eeede832804de4c6861da3cf853e4ffe0..11d87839ea61165de872647abb6b9d58e029558a 100644 (file)
@@ -1,3 +1,8 @@
+# TODO
+# - bug: when logrotate.status is written truncated (due disk getting full) and
+#   the line is partial, it will complain erronously that the line is too long
+#   while it just doesn't have the second DATE column. and that error should be
+#   ignored as warning not fatal as error.
 #
 # Conditional build:
 %bcond_without selinux         # build without SELinux support
@@ -13,16 +18,17 @@ Summary(tr.UTF-8):  Sistem günlüklerini yönlendirir, sıkıştırır ve mektup
 Summary(uk.UTF-8):     Ротує, компресує, видаляє та відправляє поштою лог-файли
 Name:          logrotate
 Version:       3.7.6
-Release:       2
+Release:       3
 License:       GPL v2
 Group:         Applications/System
-# extracted from FC src.rpm
+# Source0Download: ftp://download.fedora.redhat.com/pub/fedora/linux/updates/8/SRPMS/logrotate-3.7.6-2.2.fc8.src.rpm
 Source0:       %{name}-%{version}.tar.gz
 # Source0-md5: cafaaf07c0688398c80ef234d40ec0e4
 Source1:       %{name}.conf
 Source2:       %{name}.sysconfig
 Patch0:                %{name}-man.patch
 Patch1:                %{name}-cron.patch
+Patch2:                %{name}-selinux.patch
 %{?with_selinux:BuildRequires: libselinux-devel}
 BuildRequires: popt-devel >= 1.3
 Requires(post):        fileutils
@@ -102,6 +108,7 @@ Logrotate призначений для полегшення адміністр
 %setup -q
 %patch0 -p1
 %patch1 -p1
+%patch2 -p1
 
 %build
 %{__make} \
@@ -163,7 +170,7 @@ fi
 %attr(750,root,root) %dir /etc/logrotate.d
 %attr(750,root,root) /etc/cron.daily/logrotate
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/*.conf
-%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/sysconfig/%{name}
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name}
 %attr(640,root,root) %ghost %{statdir}/logrotate.status
 %attr(750,root,logs) %dir /var/log/archive
 %ghost /var/log/archiv
This page took 0.035466 seconds and 4 git commands to generate.