rpms/ypserv/devel ypserv-2.21-pidfile.patch, NONE, 1.1 ypserv-yppasswdd.init, 1.5, 1.6 ypserv-ypserv.init, 1.7, 1.8 ypserv-ypxfrd.init, 1.4, 1.5 ypserv.spec, 1.48, 1.49
Karel Klíč
kklic at fedoraproject.org
Thu Jan 21 18:12:03 UTC 2010
Author: kklic
Update of /cvs/pkgs/rpms/ypserv/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv28503
Modified Files:
ypserv-yppasswdd.init ypserv-ypserv.init ypserv-ypxfrd.init
ypserv.spec
Added Files:
ypserv-2.21-pidfile.patch
Log Message:
Improved initscripts
ypserv-2.21-pidfile.patch:
ypxfrd.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
--- NEW FILE ypserv-2.21-pidfile.patch ---
diff -up ypserv-2.21/rpc.ypxfrd/ypxfrd.c.pidfile ypserv-2.21/rpc.ypxfrd/ypxfrd.c
--- ypserv-2.21/rpc.ypxfrd/ypxfrd.c.pidfile 2010-01-21 18:07:46.000000000 +0100
+++ ypserv-2.21/rpc.ypxfrd/ypxfrd.c 2010-01-21 18:49:27.107770454 +0100
@@ -59,6 +59,14 @@
#include "log_msg.h"
#include "compat.h"
+#ifdef HAVE_PATHS_H
+#include <paths.h>
+#endif
+#ifndef _PATH_VARRUN
+#define _PATH_VARRUN "/etc/"
+#endif
+#define _YPXFRD_PIDFILE _PATH_VARRUN"ypxfrd.pid"
+
extern void ypxfrd_freebsd_prog_1(struct svc_req *, SVCXPRT *);
int _rpcpmstart = 0;
@@ -118,6 +126,7 @@ static void
sig_quit (int sig UNUSED)
{
pmap_unset (YPXFRD_FREEBSD_PROG, YPXFRD_FREEBSD_VERS);
+ unlink (_YPXFRD_PIDFILE);
exit (0);
}
@@ -133,6 +142,69 @@ sig_hup (int sig UNUSED)
cached_filehandles = 0;
}
+/* Create a pidfile on startup */
+static void
+create_pidfile (void)
+{
+ int fd, left, written;
+ pid_t pid;
+ char pbuf[50], *ptr;
+ struct flock lock;
+
+ fd = open (_YPXFRD_PIDFILE, O_CREAT | O_RDWR,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (fd < 0)
+ {
+ log_msg ("cannot create pidfile %s", _YPXFRD_PIDFILE);
+ if (debug_flag)
+ log_msg ("\n");
+ }
+
+ lock.l_type = F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+
+ /* Is the pidfile locked by another ypserv ? */
+ if (fcntl (fd, F_GETLK, &lock) < 0)
+ {
+ log_msg ("fcntl error");
+ if (debug_flag)
+ log_msg ("\n");
+ }
+ if (lock.l_type == F_UNLCK)
+ pid = 0; /* false, region is not locked by another proc */
+ else
+ pid = lock.l_pid; /* true, return pid of lock owner */
+
+ if (0 != pid)
+ {
+ log_msg ("rpc.ypxfrd already running (pid %d) - exiting", pid);
+ if (debug_flag)
+ log_msg ("\n");
+ exit (1);
+ }
+
+ /* write lock */
+ lock.l_type = F_WRLCK;
+ lock.l_start = 0;
+ lock.l_whence = SEEK_SET;
+ lock.l_len = 0;
+ if (0 != fcntl (fd, F_SETLK, &lock))
+ log_msg ("cannot lock pidfile");
+ sprintf (pbuf, "%ld\n", (long) getpid ());
+ left = strlen (pbuf);
+ ptr = pbuf;
+ while (left > 0)
+ {
+ if ((written = write (fd, ptr, left)) <= 0)
+ return; /* error */
+ left -= written;
+ ptr += written;
+ }
+ return;
+}
+
static void
Usage (int exitcode)
{
@@ -272,6 +344,8 @@ main (int argc, char **argv)
}
}
+ create_pidfile ();
+
/* Change current directory to database location */
if (chdir(path_ypdb) < 0)
{
@@ -448,6 +522,7 @@ main (int argc, char **argv)
svc_run();
log_msg("svc_run returned");
+ unlink (_YPXFRD_PIDFILE);
exit(1);
/* NOTREACHED */
}
Index: ypserv-yppasswdd.init
===================================================================
RCS file: /cvs/pkgs/rpms/ypserv/devel/ypserv-yppasswdd.init,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -p -r1.5 -r1.6
--- ypserv-yppasswdd.init 15 Sep 2007 17:36:54 -0000 1.5
+++ ypserv-yppasswdd.init 21 Jan 2010 18:12:03 -0000 1.6
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
#
-# yppasswdd: Starts the yp-passwdd, the YP password changing server
+# yppasswdd: Starts the YP password changing server
#
# Version: @(#) /etc/init.d/yppasswdd 1.0
#
@@ -8,18 +8,28 @@
# description: yppasswdd is the RPC server that lets users change their \
# passwords in the presence of NIS (a.k.a. YP). It must be \
# run on the NIS master server for that NIS domain. The client \
-# program is knwon as yppasswd in most cases.
+# program is known as yppasswd in most cases.
# processname: rpc.yppasswdd
+#
+# See https://fedoraproject.org/wiki/Packaging:SysVInitScript for
+# the guidelines document.
# Source function library.
[ -f /etc/rc.d/init.d/functions ] || exit 0
. /etc/rc.d/init.d/functions
-# getting the YP-Domainname
+# getting the YP domain name
. /etc/sysconfig/network
+execname="rpc.yppasswdd"
+exec="/usr/sbin/$execname"
+prog="yppasswdd"
+
# Get the settings
-. /etc/sysconfig/yppasswdd
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+pidfile=/var/run/$prog.pid
if [ "$ETCDIR" ]; then
YPPASSWDD_ARGS="$YPPASSWDD_ARGS -D $ETCDIR"
@@ -33,52 +43,86 @@ if [ "$SHADOWFILE" ]; then
YPPASSWDD_ARGS="$YPPASSWDD_ARGS -s $SHADOWFILE"
fi
-
-RETVAL=0
-
start() {
- echo -n $"Starting YP passwd service: "
- daemon rpc.yppasswdd $YPPASSWDD_ARGS
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/yppasswdd
- return $RETVAL
+ [ $UID -eq 0 ] || exit 4
+ [ -x $exec ] || exit 5
+ echo -n $"Starting YP passwd service: "
+ daemon --pidfile=$pidfile $exec $YPPASSWDD_ARGS
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
}
stop() {
- echo -n $"Stopping YP passwd service: "
- killproc rpc.yppasswdd
- RETVAL=$?
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/yppasswdd
- echo
- return $RETVAL
+ [ $UID -eq 0 ] || exit 4
+ [ -x $exec ] || exit 5
+ echo -n $"Stopping YP passwd service: "
+ killproc -p $pidfile $execname
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status -p $pidfile -l $prog $execname
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+usage() {
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
}
# See how we were called.
case "$1" in
- start)
- start
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
;;
- stop)
- stop
+ restart)
+ $1
;;
- status)
- status rpc.yppasswdd
- RETVAL=$?
- ;;
- restart|reload)
- stop
- start
- ;;
- condrestart)
- if [ -f /var/lock/subsys/yppasswdd ]; then
- stop
- start
- fi
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
- exit 1
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ usage)
+ $1
+ ;;
+ *)
+ usage
+ exit 2
esac
-
-exit $RETVAL
+exit $?
Index: ypserv-ypserv.init
===================================================================
RCS file: /cvs/pkgs/rpms/ypserv/devel/ypserv-ypserv.init,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- ypserv-ypserv.init 15 Sep 2007 17:36:54 -0000 1.7
+++ ypserv-ypserv.init 21 Jan 2010 18:12:03 -0000 1.8
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# ypserv: Starts the yp-server
#
@@ -13,67 +13,113 @@
# server, and is not needed on NIS clients.
# processname: ypserv
# config: /etc/ypserv.conf
+#
+# See https://fedoraproject.org/wiki/Packaging:SysVInitScript for
+# the guidelines document.
# Source function library.
[ -f /etc/rc.d/init.d/functions ] || exit 0
. /etc/rc.d/init.d/functions
-# getting the YP-Domainname
-. /etc/sysconfig/network
+# getting the YP domain name
+[ -e /etc/sysconfig/network ] && . /etc/sysconfig/network
-RETVAL=0
+exec="/usr/sbin/ypserv"
+prog="ypserv"
+lockfile=/var/lock/subsys/$prog
start() {
- DOMAINNAME=`domainname`
- if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
- if [ -n "$NISDOMAIN" ]; then
- action $"Setting NIS domain name $NISDOMAIN: " domainname $NISDOMAIN
- else
- exit 1
- fi
+ [ $UID -eq 0 ] || exit 4
+ [ -x $exec ] || exit 5
+ DOMAINNAME=`domainname`
+ if [ "$DOMAINNAME" = "(none)" -o "$DOMAINNAME" = "" ]; then
+ if [ -n "$NISDOMAIN" ]; then
+ action $"Setting NIS domain name $NISDOMAIN: " domainname $NISDOMAIN
+ else
+ exit 1
fi
- echo -n $"Starting YP server services: "
- daemon ypserv $YPSERV_ARGS
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ypserv
- return $RETVAL
+ fi
+ echo -n $"Starting YP server services: "
+ daemon $exec $YPSERV_ARGS
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
}
stop() {
- echo -n $"Stopping YP server services: "
- killproc ypserv
- RETVAL=$?
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ypserv
- echo
- return $RETVAL
+ [ $UID -eq 0 ] || exit 4
+ [ -x $exec ] || exit 5
+ echo -n $"Stopping YP server services: "
+ killproc $prog
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ echo -n $"Reloading securenets and ypserv.conf file:"
+ killproc $prog -HUP
+ retval=$?
+ echo
+ return $retval
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+usage() {
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
}
# See how we were called.
case "$1" in
- start)
- start
+ start)
+ rh_status_q && exit 0
+ $1
;;
- stop)
- stop
+ stop)
+ rh_status_q || exit 0
+ $1
;;
- status)
- status ypserv
- RETVAL=$?
- ;;
- restart|reload)
- stop
- start
- ;;
- condrestart)
- if [ -f /var/lock/subsys/ypserv ]; then
- stop
- start
- fi
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
- exit 1
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ usage)
+ $1
+ ;;
+ *)
+ usage
+ exit 2
esac
-
-exit $RETVAL
+exit $?
Index: ypserv-ypxfrd.init
===================================================================
RCS file: /cvs/pkgs/rpms/ypserv/devel/ypserv-ypxfrd.init,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -r1.4 -r1.5
--- ypserv-ypxfrd.init 15 Sep 2007 17:36:54 -0000 1.4
+++ ypserv-ypxfrd.init 21 Jan 2010 18:12:03 -0000 1.5
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# ypxfrd: Starts the ypxfrd daemon
#
@@ -8,59 +8,108 @@
# description: ypxfrd should be started in addition to ypserv to accelerate \
# transferring yp maps.
# processname: ypxfrd
+#
+# See https://fedoraproject.org/wiki/Packaging:SysVInitScript for
+# the guidelines document.
# Source function library.
[ -f /etc/rc.d/init.d/functions ] || exit 0
. /etc/rc.d/init.d/functions
-# getting the YP-Domainname
+# getting the YP domain name
. /etc/sysconfig/network
-RETVAL=0
+execname="rpc.ypxfrd"
+exec="/usr/sbin/$execname"
+prog="ypxfrd"
+
+lockfile=/var/lock/subsys/$prog
+pidfile=/var/run/$prog.pid
start() {
- echo -n $"Starting YP map server: "
- daemon rpc.ypxfrd $YPXFRD_ARGS
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ypxfrd
- return $RETVAL
+ [ $UID -eq 0 ] || exit 4
+ [ -x $exec ] || exit 5
+ echo -n $"Starting YP map server: "
+ daemon --pidfile=$pidfile $exec $YPXFRD_ARGS
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
}
stop() {
- echo -n $"Stopping YP map server: "
- killproc rpc.ypxfrd
- RETVAL=$?
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ypxfrd
- echo
- return $RETVAL
+ [ $UID -eq 0 ] || exit 4
+ [ -x $exec ] || exit 5
+ echo -n $"Stopping YP map server: "
+ killproc -p $pidfile $execname
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ echo -n $"Reloading securenets and ypserv.conf file:"
+ killproc -p $pidfile $execname -HUP
+ retval=$?
+ echo
+ return $retval
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status -p $pidfile -l $prog $execname
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+usage() {
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
}
# See how we were called.
case "$1" in
- start)
- start
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
;;
- stop)
- stop
+ reload)
+ rh_status_q || exit 7
+ $1
;;
- status)
- status rpc.ypxfrd
- RETVAL=$?
- ;;
- restart|reload)
- stop
- start
- ;;
- condrestart)
- if [ -f /var/lock/subsys/ypxfrd ]; then
- stop
- start
- fi
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
- exit 1
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ usage)
+ $1
+ ;;
+ *)
+ usage
+ exit 2
esac
-
-exit $RETVAL
+exit $?
Index: ypserv.spec
===================================================================
RCS file: /cvs/pkgs/rpms/ypserv/devel/ypserv.spec,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -p -r1.48 -r1.49
--- ypserv.spec 14 Jan 2010 10:59:19 -0000 1.48
+++ ypserv.spec 21 Jan 2010 18:12:03 -0000 1.49
@@ -4,7 +4,7 @@ Summary: The NIS (Network Information Se
Url: http://www.linux-nis.org/nis/ypserv/index.html
Name: ypserv
Version: 2.21
-Release: 1%{?dist}
+Release: 2%{?dist}
License: GPLv2
Group: System Environment/Daemons
Source0: ftp://ftp.kernel.org/pub/linux/utils/net/NIS/ypserv-%{version}.tar.bz2
@@ -27,6 +27,12 @@ Patch4: ypserv-2.13-ypxfr-zeroresp.patch
Patch5: ypserv-2.19-inval-ports.patch
Patch6: ypserv-2.13-nonedomain.patch
Patch7: ypserv-2.19-slp-warning.patch
+# Modifies rpc.ypxfrd to create pidfile.
+# The patch should be modified before sending it to upstream:
+# create_pidfile() should go to /lib directory, and should be
+# called by all daemons.
+# Not sent to upstream.
+Patch8: ypserv-2.21-pidfile.patch
Obsoletes: yppasswd
BuildRequires: gdbm-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -57,6 +63,7 @@ machines.
%patch5 -p1 -b .ports
%patch6 -p1 -b .nonedomain
%patch7 -p1 -b .slp-warning
+%patch8 -p1 -b .pidfile
%build
cp etc/README etc/README.etc
@@ -142,6 +149,14 @@ exit 0
%{_includedir}/*/*
%changelog
+* Thu Jan 21 2010 Karel Klic <kklic at redhat.com> - 2.21-2
+- Added patch for rpc.ypxfrd to create a pid file
+- Rewrote initscripts to become closer to Packaging:SysVInitScript
+ Fedora guildeline
+- Fixed initscript for ypserv (rhbz#523438)
+- Fixed initscript for yppasswdd (rhbz#523394)
+- Fixed initscript for ypxfrd (rhbz#523397)
+
* Wed Jan 13 2010 Karel Klic <kklic at redhat.com> - 2.21-1
- Updated to new upstream version
- Removed ypserv-2.11-nomap.patch, it has been applied by upstream
More information about the scm-commits
mailing list