rpms/apcupsd/devel apcupsd-3.14.1-cloexec.patch, NONE, 1.1 apcupsd-3.14.1-init.patch, NONE, 1.1 apcupsd.spec, 1.19, 1.20 apcupsd-3.14.0-init.patch, 1.2, NONE

Orion Poplawski (orion) fedora-extras-commits at redhat.com
Thu Aug 2 15:16:56 UTC 2007


Author: orion

Update of /cvs/pkgs/rpms/apcupsd/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv19553/devel

Modified Files:
	apcupsd.spec 
Added Files:
	apcupsd-3.14.1-cloexec.patch apcupsd-3.14.1-init.patch 
Removed Files:
	apcupsd-3.14.0-init.patch 
Log Message:
- Add patch to close open file descriptors (bug #247162)
- Stop/restart service as needed on removal/upgrade


apcupsd-3.14.1-cloexec.patch:

--- NEW FILE apcupsd-3.14.1-cloexec.patch ---
--- apcupsd-3.14.1/src/apcnis.c.cloexec	2006-08-13 11:00:15.000000000 -0600
+++ apcupsd-3.14.1/src/apcnis.c	2007-08-01 16:26:35.000000000 -0600
@@ -155,6 +155,9 @@
       sleep(5 * 60);
    }
 
+   /* Close the socket on exec - avoid leaked file descriptors */
+   fcntl(sockfd, F_SETFD, FD_CLOEXEC);
+
    /* Reuse old sockets */
 #ifndef HAVE_MINGW
    if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&turnon, sizeof(turnon)) < 0) {
--- apcupsd-3.14.1/src/apcupsd.c.cloexec	2006-09-23 11:42:47.000000000 -0600
+++ apcupsd-3.14.1/src/apcupsd.c	2007-08-01 16:27:14.000000000 -0600
@@ -280,6 +280,9 @@
       if (ups->event_fd < 0) {
          log_event(ups, LOG_WARNING, "Could not open events file %s: %s\n",
             ups->eventfile, strerror(errno));
+      } else {
+         /* Close the file on exec - avoid leaked file descriptors */
+         fcntl(ups->event_fd, F_SETFD, FD_CLOEXEC);
       }
    }
 
--- apcupsd-3.14.1/src/drivers/usb/linux/linux-usb.c.cloexec	2007-08-01 16:30:28.000000000 -0600
+++ apcupsd-3.14.1/src/drivers/usb/linux/linux-usb.c	2007-08-01 16:42:55.000000000 -0600
@@ -182,8 +182,11 @@
    /* Retry 10 times */
    for (i = 0; i < 10; i++) {
       my_data->fd = open_device(ups->device, ups);
-      if (my_data->fd != -1)
+      if (my_data->fd != -1) {
+         /* Close the device on exec - avoid leaked file descriptors */
+         fcntl(my_data->fd, F_SETFD, FD_CLOEXEC);
          return 1;
+      }
       sleep(1);
    }
 
@@ -206,6 +209,8 @@
             asnprintf(devname, sizeof(devname), "%s%d", hiddev[j], k);
             my_data->fd = open_device(devname, ups);
             if (my_data->fd != -1) {
+               /* Close the device on exec - avoid leaked file descriptors */
+               fcntl(my_data->fd, F_SETFD, FD_CLOEXEC);
                /* Successful open, save device name and return */
                astrncpy(ups->device, devname, sizeof(ups->device));
                return 1;

apcupsd-3.14.1-init.patch:

--- NEW FILE apcupsd-3.14.1-init.patch ---
--- apcupsd-3.14.1/platforms/redhat/apcupsd.in.init	2007-04-23 17:35:33.000000000 -0600
+++ apcupsd-3.14.1/platforms/redhat/apcupsd.in	2007-08-02 09:05:48.000000000 -0600
@@ -3,7 +3,7 @@
 # apcupsd      This shell script takes care of starting and stopping
 #	       the apcupsd UPS monitoring daemon.
 #
-# chkconfig: 2345 60 99
+# chkconfig: - 60 99
 # description: apcupsd monitors power and takes action if necessary
 #
 APCPID=@PIDDIR@/apcupsd.pid
@@ -44,9 +44,11 @@
        ;;
     restart|force-reload)
        $0 stop
-       sleep 15
        $0 start
        ;;
+    condrestart)
+       [ -f /var/lock/subsys/ypbind ] && $0 restart || :
+       ;;
     reload)
        echo "$0: reload not implemented"
        exit 3
@@ -62,7 +64,7 @@
        fi
        ;;
     *)
-       echo "Usage: $0 {start|stop|restart|status}"
+       echo "Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
        ;;
 esac


Index: apcupsd.spec
===================================================================
RCS file: /cvs/pkgs/rpms/apcupsd/devel/apcupsd.spec,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- apcupsd.spec	2 Jul 2007 15:20:26 -0000	1.19
+++ apcupsd.spec	2 Aug 2007 15:16:23 -0000	1.20
@@ -1,6 +1,6 @@
 Name:         apcupsd
 Version:      3.14.1
-Release:      2%{?dist}
+Release:      3%{?dist}
 Summary:      APC UPS Power Control Daemon for Linux
 
 Group:        System Environment/Daemons
@@ -9,8 +9,9 @@
 Source0:      http://downloads.sourceforge.net/apcupsd/%{name}-%{version}.tar.gz
 Source1:      apcupsd.logrotate
 Source2:      apcupsd-httpd.conf
-Patch0:       apcupsd-3.14.0-init.patch
+Patch0:       apcupsd-3.14.1-init.patch
 Patch1:       apcupsd-3.14.1-linux-usb.patch
+Patch2:       apcupsd-3.14.1-cloexec.patch
 BuildRoot:    %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires: glibc-devel >= 2.3, gd-devel > 2.0
@@ -19,6 +20,8 @@
 Requires:      /bin/mail
 Requires(post):  /sbin/chkconfig
 Requires(preun): /sbin/chkconfig
+Requires(preun): /sbin/service
+Requires(postun): /sbin/service
 
 %description
 Apcupsd can be used for controlling most APC UPSes. During a
@@ -55,6 +58,7 @@
 %setup -q
 %patch -p1 -b .init
 %patch1 -p1 -b .linux-usb
+%patch2 -p1 -b .cloexec
 # Don't strip binaries
 sed -i -e 's/^\(.*INSTALL_PROGRAM.*\) -s /\1 /' src{,/cgi}/Makefile.in
 
@@ -155,20 +159,25 @@
 
 
 %post
-# add our links
-if [ "$1" -ge 1 ] ; then
 /sbin/chkconfig --add apcupsd
-fi
-
 
 %preun
-if [ $1 = 0 ] ; then
-        # remove startup links
-        /sbin/chkconfig --del apcupsd
+if [ $1 = 0 ]; then
+   /sbin/service apcupsd stop >/dev/null 2>&1
+   /sbin/chkconfig --del apcupsd
+fi
+
+%postun
+if [ $1 -ge 1 ]; then
+   /sbin/service apcupsd condrestart >/dev/null 2>&1 || :
 fi
 
 
 %changelog
+* Wed Aug  1 2007 - Orion Poplawski <orion at cora.nwra.com> - 3.14.1-3
+- Add patch to close open file descriptors (bug #247162)
+- Stop/restart service as needed on removal/upgrade
+
 * Mon Jun 02 2007 - Orion Poplawski <orion at cora.nwra.com> - 3.14.1-2
 - Add patch for linux USB UPS detection (bug #245864)
 


--- apcupsd-3.14.0-init.patch DELETED ---




More information about the fedora-extras-commits mailing list