- remove stale pid file on start
This commit is contained in:
parent
75b0755c88
commit
bb9cfff70a
44
radvd-1.1-stale_pid.patch
Normal file
44
radvd-1.1-stale_pid.patch
Normal file
@ -0,0 +1,44 @@
|
||||
diff -up radvd-1.1/radvd.c.stale_pid radvd-1.1/radvd.c
|
||||
--- radvd-1.1/radvd.c.stale_pid 2008-01-24 11:03:17.000000000 +0100
|
||||
+++ radvd-1.1/radvd.c 2008-04-04 15:10:52.000000000 +0200
|
||||
@@ -70,6 +70,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
unsigned char msg[MSG_SIZE];
|
||||
char pidstr[16];
|
||||
+ int ret;
|
||||
int c, log_method;
|
||||
char *logfile, *pidfile;
|
||||
sigset_t oset, nset;
|
||||
@@ -230,10 +231,29 @@ main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
- /* FIXME: not atomic if pidfile is on an NFS mounted volume */
|
||||
- if ((fd = open(pidfile, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0)
|
||||
+ if ((fd = open(pidfile, O_RDONLY, 0)) > 0)
|
||||
{
|
||||
- flog(LOG_ERR, "radvd pid file already exists or cannot be created, terminating: %s", strerror(errno));
|
||||
+ ret = read(fd, pidstr, sizeof(pidstr) - 1);
|
||||
+ if (ret < 0)
|
||||
+ {
|
||||
+ flog(LOG_ERR, "cannot read radvd pid file, terminating: %s", strerror(errno));
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ pidstr[ret] = '\0';
|
||||
+ if (!kill(atol(pidstr), 0))
|
||||
+ {
|
||||
+ flog(LOG_ERR, "radvd already running, terminating.");
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ close(fd);
|
||||
+ fd = open(pidfile, O_CREAT|O_TRUNC|O_WRONLY, 0644);
|
||||
+ }
|
||||
+ else /* FIXME: not atomic if pidfile is on an NFS mounted volume */
|
||||
+ fd = open(pidfile, O_CREAT|O_EXCL|O_WRONLY, 0644);
|
||||
+
|
||||
+ if (fd < 0)
|
||||
+ {
|
||||
+ flog(LOG_ERR, "cannot create radvd pid file, terminating: %s", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
Summary: A Router Advertisement daemon
|
||||
Name: radvd
|
||||
Version: 1.1
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
# The code includes the advertising clause, so it's GPL-incompatible
|
||||
License: BSD-style
|
||||
Group: System Environment/Daemons
|
||||
@ -19,6 +19,7 @@ BuildRequires: flex, byacc
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
|
||||
Patch0: radvd-1.1-string_cmp.patch
|
||||
Patch1: radvd-1.1-stale_pid.patch
|
||||
|
||||
%description
|
||||
radvd is the router advertisement daemon for IPv6. It listens to router
|
||||
@ -33,7 +34,8 @@ services.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b string_cmp
|
||||
%patch0 -p1 -b .string_cmp
|
||||
%patch1 -p1 -b .stale_pid
|
||||
|
||||
%build
|
||||
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIE"
|
||||
@ -95,6 +97,9 @@ fi
|
||||
%{_sbindir}/radvdump
|
||||
|
||||
%changelog
|
||||
* Fri Apr 11 2008 Martin Nagy <mnagy@redhat.com> - 1.1-3
|
||||
- remove stale pid file on start
|
||||
|
||||
* Mon Feb 25 2008 Martin Nagy <mnagy@redhat.com> - 1.1-2
|
||||
- fix up string comparison in init script (#427047)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user