aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--initscripts.spec8
-rw-r--r--ppp/ip-up3
-rw-r--r--src/ppp-watch.c32
-rwxr-xr-xsysconfig/network-scripts/ifdown-ppp45
-rwxr-xr-xsysconfig/network-scripts/ifup-ppp71
5 files changed, 56 insertions, 103 deletions
diff --git a/initscripts.spec b/initscripts.spec
index c7fbb43e..23e1094f 100644
--- a/initscripts.spec
+++ b/initscripts.spec
@@ -1,10 +1,10 @@
Summary: The inittab file and the /etc/rc.d scripts.
Name: initscripts
-%define version 4.36
+%define version 4.37
Version: %{version}
Copyright: GPL
Group: System Environment/Base
-Release: 2
+Release: 1
Source: initscripts-%{version}.tar.gz
BuildRoot: /var/tmp/initbld
Requires: mingetty, bash, /bin/awk, /bin/sed, mktemp, e2fsprogs, console-tools
@@ -181,6 +181,7 @@ rm -rf $RPM_BUILD_ROOT
/sbin/loglevel
/sbin/minilogd
/sbin/service
+/sbin/ppp-watch
/usr/man/man1/doexec.1
/usr/man/man1/initlog.1
/usr/man/man1/ipcalc.1
@@ -196,6 +197,9 @@ rm -rf $RPM_BUILD_ROOT
%ghost %attr(0664,root,utmp) /var/run/utmp
%changelog
+* Mon Sep 06 1999 Michael K. Johnson <johnsonm@redhat.com>
+- added ppp-watch to make "ifup ppp*" syncronous
+
* Fri Sep 3 1999 Bill Nottingham <notting@redhat.com>
- require lsof
diff --git a/ppp/ip-up b/ppp/ip-up
index b4b14da6..5fcf524b 100644
--- a/ppp/ip-up
+++ b/ppp/ip-up
@@ -8,9 +8,6 @@ REALDEVICE=$1
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
-echo "$REALDEVICE" > /var/run/ppp-$LOGDEVICE.dev
-chmod a+r /var/run/ppp-$LOGDEVICE.dev
-
[ -x /etc/ppp/ip-up.local ] && /etc/ppp/ip-up.local $*
# Used for clustering heartbeat monitoring stuff.
diff --git a/src/ppp-watch.c b/src/ppp-watch.c
index 2e3cd257..c2002669 100644
--- a/src/ppp-watch.c
+++ b/src/ppp-watch.c
@@ -82,6 +82,7 @@ static int theSighup = 0;
static int theSigio = 0;
static int theSigchld = 0;
+static char *theBoot = NULL;
static void
detach(int now, int parentExitCode) {
@@ -156,14 +157,14 @@ doPidFile(char *device) {
int
-fork_exec(int wait, char *path, char *arg1, char *arg2)
+fork_exec(int wait, char *path, char *arg1, char *arg2, char *arg3)
{
pid_t child;
int status;
if (!(child = fork())) {
/* child */
- execl(path, path, arg1, arg2, 0);
+ execl(path, path, arg1, arg2, arg3, 0);
perror(path);
_exit (1);
}
@@ -184,7 +185,7 @@ fork_exec(int wait, char *path, char *arg1, char *arg2)
static void
cleanExit(int exitCode) {
- fork_exec(1, "/sbin/netreport", "-r", NULL);
+ fork_exec(1, "/sbin/netreport", "-r", NULL, NULL);
detach(1, exitCode);
exit(exitCode);
doPidFile(NULL);
@@ -306,9 +307,11 @@ main(int argc, char **argv) {
int timeout = 30;
char *temp;
struct timeval tv;
+ int dieing = 0;
+ int sendsig;
- if (argc != 2) {
- fprintf (stderr, "usage: ppp-watch [ifcfg-]<logical-name>");
+ if (argc < 2) {
+ fprintf (stderr, "usage: ppp-watch [ifcfg-]<logical-name> [boot]");
exit(30);
}
@@ -334,7 +337,11 @@ main(int argc, char **argv) {
doPidFile(device);
- fork_exec(1, "/sbin/netreport", NULL, NULL);
+ fork_exec(1, "/sbin/netreport", NULL, NULL, NULL);
+
+ if (argc > 2 && !strcmp("boot", argv[2])) {
+ theBoot = argv[2];
+ }
if (!strncmp(argv[1], "ifcfg-", 6)) {
device = argv[1] + 6;
@@ -344,7 +351,7 @@ main(int argc, char **argv) {
ifcfg = shvarfilesGet(device);
if (!ifcfg) cleanExit(28);
- fork_exec(0, "/etc/sysconfig/network-scripts/ifup-ppp", "daemon", device);
+ fork_exec(0, "/etc/sysconfig/network-scripts/ifup-ppp", "daemon", device, theBoot);
temp = svGetValue(ifcfg, "RETRYTIMEOUT");
if (temp) {
timeout = atoi(temp);
@@ -357,10 +364,15 @@ main(int argc, char **argv) {
sigsuspend(&sigs);
if (theSigterm) {
theSigterm = 0;
+
+ if (dieing) sendsig = SIGKILL;
+ else sendsig = SIGTERM;
+ dieing = 1;
+
if (logicalDevice) free(logicalDevice);
logicalDevice = pppLogicalToPhysical(&pppdPid, device);
if (logicalDevice) free(logicalDevice);
- kill(-pppdPid, SIGTERM);
+ kill(-pppdPid, sendsig);
cleanExit(0);
}
if (theSighup) {
@@ -383,7 +395,7 @@ main(int argc, char **argv) {
timeout = atoi(temp);
free(temp);
} else {
- timeout = 30;
+ timeout = 2;
}
}
logicalDevice = pppLogicalToPhysical(NULL, device);
@@ -402,7 +414,7 @@ main(int argc, char **argv) {
if (!WIFEXITED(status)) cleanExit(29);
if (svTrueValue(ifcfg, "PERSIST", 0)) {
- fork_exec(0, "/etc/sysconfig/network-scripts/ifup-ppp", "daemon", device);
+ fork_exec(0, "/etc/sysconfig/network-scripts/ifup-ppp", "daemon", device, theBoot);
temp = svGetValue(ifcfg, "RETRYTIMEOUT");
if (temp) {
timeout = atoi(temp);
diff --git a/sysconfig/network-scripts/ifdown-ppp b/sysconfig/network-scripts/ifdown-ppp
index 6f1d90ca..2e56b0c0 100755
--- a/sysconfig/network-scripts/ifdown-ppp
+++ b/sysconfig/network-scripts/ifdown-ppp
@@ -7,47 +7,24 @@ cd /etc/sysconfig/network-scripts
CONFIG=$1
source_config
-if [ ! -f /var/run/ppp-$DEVICE.pid ]; then
- # ppp isn't running, or we didn't start it
- exit 0
-fi
-
-file=/var/run/ppp-$DEVICE.pid
-
-# signals ifup-ppp not to persist -- must do this before exiting if PPP
-# has not yet started ($file does not exist).
-rm -f /var/run/ppp-$DEVICE.dev
+file=/var/run/pppwatch-$DEVICE.pid
if [ ! -f $file ]; then
+ # ppp isn't running, or we didn't start it
exit 0
fi
-PID=`head -1 $file`
-if [ -z "$PID" ]; then
- exit 1
-fi
-
-# pppd might have chat/wvdial as a child; remember its pid to kill after pppd.
-# (After, not before, so that pppd doesn't just restart it).
-
-CHATPID=`ps axl | awk '$4 ~ /^'"$PID"'$/ {print $3}' 2>/dev/null`
+PID=`cat $file`
+[ -n "$PID" ] || exit 1
-kill $PID > /dev/null 2>&1
-[ -n "$CHATPID" ] && kill $CHATPID > /dev/null 2>&1
-if [ ! -d /proc/$PID ]; then
- exit 0
-fi
+kill -TERM $PID > /dev/null 2>&1
+[ ! -d /proc/$PID ] && exit 0
sleep 2
-if [ ! -d /proc/$PID ]; then
- exit 0
-fi
+[ ! -d /proc/$PID ] && exit 0
-kill -KILL $PID > /dev/null 2>&1
-if [ -d /proc/$PID ]; then
- logger -p daemon.info -t ifdown-ppp "ifdown-ppp unable to kill pppd-$DEVICE" &
-else
- # ip-down won't run in this case
- /etc/sysconfig/network-scripts/ifdown-post $1
-fi
+# killing ppp-watch twice in a row causes it to send a SIGKILL to pppd pgrp
+kill -TERM $PID > /dev/null 2>&1
+# ip-down won't run in this case
+/etc/sysconfig/network-scripts/ifdown-post $1
exit 1
diff --git a/sysconfig/network-scripts/ifup-ppp b/sysconfig/network-scripts/ifup-ppp
index 3fd810f7..d058e9b3 100755
--- a/sysconfig/network-scripts/ifup-ppp
+++ b/sysconfig/network-scripts/ifup-ppp
@@ -4,10 +4,8 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
# ifup-post for PPP is handled through /etc/ppp/ip-up
if [ "$1" != daemon ] ; then
- # disconnect stdin, out, err to disassociate from controlling tty
- # so that no HUPs will get through.
- $0 daemon $* </dev/null >/dev/null 2>/dev/null &
- exit 0
+ # let ppp-watch do the right thing
+ exec /sbin/ppp-watch "$@"
fi
shift
@@ -87,54 +85,19 @@ else
CHATSCRIPT=
fi
-while : ; do
- (logger -p daemon.info -t ifup-ppp \
- "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
+(logger -p daemon.info -t ifup-ppp \
+ "pppd started for $DEVICE on $MODEMPORT at $LINESPEED" &)&
- if [ -n "$WVDIALSECT" ] ; then
- /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
- remotename $DEVICE ipparam $DEVICE \
- ${PPPOPTIONS} \
- linkname $DEVICE \
- connect "/usr/bin/wvdial --chat $WVDIALSECT"
- else
- /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
- remotename $DEVICE ipparam $DEVICE \
- ${PPPOPTIONS} \
- linkname $DEVICE \
- connect "/usr/sbin/chat $chatdbg -f $CHATSCRIPT"
- fi
-
- # exit if we're not supposed to persist or our lock file has disappeared
- if [ "$PERSIST" != "yes" -o ! -f /var/run/ppp-$DEVICE.dev ]; then
- rm -f /var/run/ppp-$DEVICE.dev
- exit 0
- fi
-
- size=`wc -c < /var/run/ppp-$DEVICE.dev`
-
- if [ $size = 0 ]; then
- # pppd never connected
- timeout=$RETRYTIMEOUT
- else
- # pppd connected and then disconnected
- timeout=$DISCONNECTTIMEOUT
- fi
-
- [ -z "$timeout" ] && {
- timeout=30
- }
-
- sleep $timeout || {
- # sleep was killed
- rm -f /var/run/ppp-$DEVICE.dev
- rm -f /var/run/ppp-$DEVICE.pid
- exit 0
- }
-
- # exit if our lock file disappeared while we slept
- if [ ! -f /var/run/ppp-$DEVICE.dev ]; then
- rm -f /var/run/ppp-$DEVICE.pid
- exit 0
- fi
-done
+if [ -n "$WVDIALSECT" ] ; then
+ exec /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
+ remotename $DEVICE ipparam $DEVICE \
+ ${PPPOPTIONS} \
+ linkname $DEVICE \
+ connect "/usr/bin/wvdial --chat $WVDIALSECT"
+else
+ exec /usr/sbin/pppd -detach $opts $MODEMPORT $LINESPEED \
+ remotename $DEVICE ipparam $DEVICE \
+ ${PPPOPTIONS} \
+ linkname $DEVICE \
+ connect "/usr/sbin/chat $chatdbg -f $CHATSCRIPT"
+fi