Author: arekm                        Date: Fri Mar  2 12:35:32 2012 GMT
Module: packages                      Tag: HEAD
---- Log message:
- rel 16; don't leak fds

---- Files affected:
packages/cronie:
   cronie.spec (1.58 -> 1.59) , cronie-1.4.8-inotify-fix.patch (NONE -> 1.1)  
(NEW)

---- Diffs:

================================================================
Index: packages/cronie/cronie.spec
diff -u packages/cronie/cronie.spec:1.58 packages/cronie/cronie.spec:1.59
--- packages/cronie/cronie.spec:1.58    Sat Feb 11 21:58:16 2012
+++ packages/cronie/cronie.spec Fri Mar  2 13:35:26 2012
@@ -18,7 +18,7 @@
 Summary:       Cron daemon for executing programs at set times
 Name:          cronie
 Version:       1.4.8
-Release:       15
+Release:       16
 License:       MIT and BSD and GPL v2
 Group:         Daemons
 Source0:       
https://fedorahosted.org/releases/c/r/cronie/%{name}-%{version}.tar.gz
@@ -33,6 +33,7 @@
 Patch0:                inotify-nosys.patch
 Patch1:                %{name}-nosyscrontab.patch
 Patch2:                sendmail-path.patch
+Patch3:                cronie-1.4.8-inotify-fix.patch
 URL:           https://fedorahosted.org/cronie/
 %{?with_audit:BuildRequires:   audit-libs-devel}
 BuildRequires: autoconf
@@ -100,6 +101,7 @@
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 %build
 %{__aclocal}
@@ -255,6 +257,9 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.59  2012/03/02 12:35:26  arekm
+- rel 16; don't leak fds
+
 Revision 1.58  2012/02/11 20:58:16  baggins
 - rel 15
 - use __cp macro in trigger, cp may be an alias

================================================================
Index: packages/cronie/cronie-1.4.8-inotify-fix.patch
diff -u /dev/null packages/cronie/cronie-1.4.8-inotify-fix.patch:1.1
--- /dev/null   Fri Mar  2 13:35:32 2012
+++ packages/cronie/cronie-1.4.8-inotify-fix.patch      Fri Mar  2 13:35:26 2012
@@ -0,0 +1,94 @@
+diff --git a/src/cron.c b/src/cron.c
+index 7dc2958..7917589 100644
+--- a/src/cron.c
++++ b/src/cron.c
+@@ -64,11 +64,19 @@ static int DisableInotify;
+ int wd[NUM_WATCHES];
+ const char *watchpaths[NUM_WATCHES] = {SPOOL_DIR, SYS_CROND_DIR, SYSCRONTAB};
+ 
++static void reset_watches(void) {
++      int i;
++
++      for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
++              wd[i] = -2;
++      }
++}
++
+ void set_cron_unwatched(int fd) {
+       int i;
+ 
+       for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
+-              if (wd[i] < 0) {
++              if (wd[i] > 0) {
+                       inotify_rm_watch(fd, wd[i]);
+                       wd[i] = -1;
+               }
+@@ -87,22 +95,21 @@ void set_cron_watched(int fd) {
+       for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
+               int w;
+ 
+-              if (open(watchpaths[i], O_RDONLY | O_NONBLOCK, 0) != -1) {
+-                      w = inotify_add_watch(fd, watchpaths[i],
+-                              IN_CREATE | IN_CLOSE_WRITE | IN_ATTRIB | 
IN_MODIFY | IN_MOVED_TO |
+-                              IN_MOVED_FROM | IN_MOVE_SELF | IN_DELETE | 
IN_DELETE_SELF);
+-                      if (w < 0) {
+-                              if (wd[i] != -1) {
+-                                      log_it("CRON", pid, "This directory or 
file can't be watched",
+-                                              watchpaths[i], errno);
+-                                      log_it("CRON", pid, "INFO", "running 
without inotify support", 0);
+-                              }
+-                              inotify_enabled = 0;
+-                              set_cron_unwatched(fd);
+-                              return;
++              w = inotify_add_watch(fd, watchpaths[i],
++                      IN_CREATE | IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | 
IN_MOVED_TO |
++                      IN_MOVED_FROM | IN_MOVE_SELF | IN_DELETE | 
IN_DELETE_SELF);
++              if (w < 0 && errno != ENOENT) {
++                      if (wd[i] != -1) {
++                              log_it("CRON", pid, "This directory or file 
can't be watched",
++                                      watchpaths[i], errno);
++                              log_it("CRON", pid, "INFO", "running without 
inotify support",
++                                      0);
+                       }
+-                      wd[i] = w;
++                      inotify_enabled = 0;
++                      set_cron_unwatched(fd);
++                      return;
+               }
++              wd[i] = w;
+       }
+ 
+       if (!inotify_enabled) {
+@@ -120,6 +127,7 @@ static void handle_signals(cron_db * database) {
+               /* watches must be reinstated on reload */
+               if (inotify_enabled && (EnableClustering != 1)) {
+                       set_cron_unwatched(database->ifd);
++                      reset_watches();
+                       inotify_enabled = 0;
+               }
+ #endif
+@@ -158,9 +166,6 @@ int main(int argc, char *argv[]) {
+       char *cs;
+       pid_t pid = getpid();
+       long oldGMToff;
+-#if defined WITH_INOTIFY
+-      int i;
+-#endif
+ 
+       ProgramName = argv[0];
+       MailCmd[0] = '\0';
+@@ -261,13 +266,7 @@ int main(int argc, char *argv[]) {
+                       "", 0);
+       }
+       else {
+-              for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
+-                      /* initialize to negative number other than -1
+-                       * so an eventual error is reported for the first time
+-                       */
+-                      wd[i] = -2;
+-              }
+-
++              reset_watches();
+               database.ifd = fd = inotify_init();
+               fcntl(fd, F_SETFD, FD_CLOEXEC);
+               if (fd < 0)
================================================================

---- CVS-web:
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/cronie/cronie.spec?r1=1.58&r2=1.59&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to