aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael K. Johnson <johnsonm@redhat.com>1999-12-03 21:12:14 +0000
committerMichael K. Johnson <johnsonm@redhat.com>1999-12-03 21:12:14 +0000
commit11365d7a305b084757ff2af36c394dd12da84526 (patch)
treee00d7683b01a4d237fb7dcfcb8b4bf8cf221cdbf
parent8c5148a89899f544a4c95aaa0125b239aed86298 (diff)
downloadinitscripts-11365d7a305b084757ff2af36c394dd12da84526.tar
initscripts-11365d7a305b084757ff2af36c394dd12da84526.tar.gz
initscripts-11365d7a305b084757ff2af36c394dd12da84526.tar.bz2
initscripts-11365d7a305b084757ff2af36c394dd12da84526.tar.xz
initscripts-11365d7a305b084757ff2af36c394dd12da84526.zip
open fds, get lock/pid file names right
-rw-r--r--src/ppp-watch.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/ppp-watch.c b/src/ppp-watch.c
index 14ddc3fa..5092c812 100644
--- a/src/ppp-watch.c
+++ b/src/ppp-watch.c
@@ -300,6 +300,14 @@ shvarfilesGet(char *interfaceName) {
ifcfg->parent = svNewFile(ifcfgParentName);
}
+ /* don't keep the file descriptors around, they can become
+ * stdout for children
+ */
+ close (ifcfg->fd); ifcfg->fd = 0;
+ if (ifcfg->parent) {
+ close (ifcfg->parent->fd); ifcfg->parent->fd = 0;
+ }
+
return ifcfg;
}
@@ -398,7 +406,7 @@ clean:
int
main(int argc, char **argv) {
int status, waited;
- char *device, *physicalDevice = NULL;
+ char *device, *real_device, *physicalDevice = NULL;
char *theBoot = NULL;
shvarFile *ifcfg;
sigset_t sigs;
@@ -427,7 +435,13 @@ main(int argc, char **argv) {
theBoot = argv[2];
}
- doPidFile(device);
+ ifcfg = shvarfilesGet(device);
+ if (!ifcfg) cleanExit(28);
+
+ real_device = svGetValue(ifcfg, "DEVICE");
+ if (!real_device) real_device = device;
+
+ doPidFile(real_device);
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
@@ -463,10 +477,6 @@ main(int argc, char **argv) {
sigdelset(&sigs, SIGCHLD);
if (theBoot) sigdelset(&sigs, SIGALRM);
-
- ifcfg = shvarfilesGet(device);
- if (!ifcfg) cleanExit(28);
-
fork_exec(0, "/etc/sysconfig/network-scripts/ifup-ppp", "daemon", device, theBoot);
temp = svGetValue(ifcfg, "RETRYTIMEOUT");
if (temp) {
@@ -486,7 +496,7 @@ main(int argc, char **argv) {
dieing = 1;
if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; }
- physicalDevice = pppLogicalToPhysical(&pppdPid, device);
+ physicalDevice = pppLogicalToPhysical(&pppdPid, real_device);
if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; }
if (!pppdPid) cleanExit(35);
kill(pppdPid, sendsig);
@@ -503,7 +513,7 @@ main(int argc, char **argv) {
if (ifcfg->parent) svCloseFile(ifcfg->parent);
svCloseFile(ifcfg);
ifcfg = shvarfilesGet(device);
- physicalDevice = pppLogicalToPhysical(&pppdPid, device);
+ physicalDevice = pppLogicalToPhysical(&pppdPid, real_device);
if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; }
kill(pppdPid, SIGTERM);
/* redial when SIGCHLD arrives, even if !PERSIST */
@@ -522,7 +532,7 @@ main(int argc, char **argv) {
timeout = 2;
}
}
- physicalDevice = pppLogicalToPhysical(NULL, device);
+ physicalDevice = pppLogicalToPhysical(NULL, real_device);
if (physicalDevice) {
if (interfaceStatus(physicalDevice)) {
/* device is up */