aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>1998-03-25 18:38:59 +0000
committerBrian Somers <brian@FreeBSD.org>1998-03-25 18:38:59 +0000
commit5cf4388bdf4c4e693f048a9d8563b298c16e8cb5 (patch)
treeb2fe599f6ffe402fde23d4265dc8ee19f71cda9b /usr.sbin/ppp
parent75b8d2834b1394303146ade9388440a4808170b3 (diff)
Notes
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/bundle.c30
-rw-r--r--usr.sbin/ppp/bundle.h6
-rw-r--r--usr.sbin/ppp/defs.c4
-rw-r--r--usr.sbin/ppp/defs.h7
-rw-r--r--usr.sbin/ppp/main.c37
5 files changed, 40 insertions, 44 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c
index b8dff317277d..491ae10116c4 100644
--- a/usr.sbin/ppp/bundle.c
+++ b/usr.sbin/ppp/bundle.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.c,v 1.1.2.31 1998/03/20 19:47:40 brian Exp $
+ * $Id: bundle.c,v 1.1.2.32 1998/03/25 00:59:28 brian Exp $
*/
#include <sys/param.h>
@@ -182,6 +182,19 @@ bundle_LayerStart(void *v, struct fsm *fp)
bundle_NewPhase(bundle, PHASE_ESTABLISH);
}
+
+static void
+bundle_Notify(struct bundle *bundle, char c)
+{
+ if (bundle->notify.fd != -1) {
+ if (write(bundle->notify.fd, &c, 1) == 1)
+ LogPrintf(LogPHASE, "Parent notified of success.\n");
+ else
+ LogPrintf(LogPHASE, "Failed to notify parent of success.\n");
+ close(bundle->notify.fd);
+ bundle->notify.fd = -1;
+ }
+}
static void
bundle_LayerUp(void *v, struct fsm *fp)
{
@@ -204,16 +217,7 @@ bundle_LayerUp(void *v, struct fsm *fp)
if (fp->proto == PROTO_IPCP) {
bundle_StartIdleTimer(bundle);
- if (mode & MODE_BACKGROUND && BGFiledes[1] != -1) {
- char c = EX_NORMAL;
-
- if (write(BGFiledes[1], &c, 1) == 1)
- LogPrintf(LogPHASE, "Parent notified of success.\n");
- else
- LogPrintf(LogPHASE, "Failed to notify parent of success.\n");
- close(BGFiledes[1]);
- BGFiledes[1] = -1;
- }
+ bundle_Notify(bundle, EX_NORMAL);
}
}
@@ -477,9 +481,9 @@ bundle_Create(const char *prefix)
bundle.filter.dial.name = "DIAL";
bundle.filter.alive.name = "ALIVE";
bundle.filter.alive.logok = 1;
-
memset(&bundle.idle.timer, '\0', sizeof bundle.idle.timer);
bundle.idle.done = 0;
+ bundle.notify.fd = -1;
/* Clean out any leftover crud */
bundle_CleanInterface(&bundle);
@@ -534,6 +538,8 @@ bundle_Destroy(struct bundle *bundle)
while (dl)
dl = datalink_Destroy(dl);
+ bundle_Notify(bundle, EX_ERRDEAD);
+
bundle->ifname = NULL;
}
diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h
index 4ff73c21eaad..2dc3df0bc609 100644
--- a/usr.sbin/ppp/bundle.h
+++ b/usr.sbin/ppp/bundle.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.h,v 1.1.2.19 1998/03/18 23:15:31 brian Exp $
+ * $Id: bundle.h,v 1.1.2.20 1998/03/20 19:47:42 brian Exp $
*/
#define PHASE_DEAD 0 /* Link is dead */
@@ -71,6 +71,10 @@ struct bundle {
struct pppTimer timer; /* timeout after cfg.idle_timeout */
time_t done;
} idle;
+
+ struct {
+ int fd; /* write status here */
+ } notify;
};
#define descriptor2bundle(d) \
diff --git a/usr.sbin/ppp/defs.c b/usr.sbin/ppp/defs.c
index 50ddcd73964e..a89cde1393ad 100644
--- a/usr.sbin/ppp/defs.c
+++ b/usr.sbin/ppp/defs.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: defs.c,v 1.11.4.3 1998/02/10 03:23:15 brian Exp $
+ * $Id: defs.c,v 1.11.4.4 1998/03/24 18:46:49 brian Exp $
*/
#include <sys/param.h>
@@ -44,8 +44,6 @@
#include "vars.h"
int mode = MODE_INTER;
-int BGFiledes[2] = { -1, -1 };
-
static char dstsystem[50];
void
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index 77628ac7b094..ffa9a84148a1 100644
--- a/usr.sbin/ppp/defs.h
+++ b/usr.sbin/ppp/defs.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: defs.h,v 1.29.2.5 1998/03/09 19:24:56 brian Exp $
+ * $Id: defs.h,v 1.29.2.6 1998/03/09 19:26:37 brian Exp $
*
* TODO:
*/
@@ -77,13 +77,8 @@
#define EX_NOLOGIN 13
extern int mode;
-extern int BGFiledes[2];
-extern int tun_in;
-extern int tun_out;
-extern int netfd;
extern void SetLabel(const char *);
extern const char *GetLabel(void);
extern void randinit(void);
extern int GetShortHost(void);
-extern void DropClient(int);
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 4d394d3a5de1..241d3351065b 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.121.2.37 1998/03/25 00:59:38 brian Exp $
+ * $Id: main.c,v 1.121.2.38 1998/03/25 18:38:24 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@@ -113,15 +113,6 @@ AbortProgram(int excode)
prompt_Drop(&prompt, 1);
ServerClose();
ID0unlink(pid_filename);
- if (mode & MODE_BACKGROUND && BGFiledes[1] != -1) {
- char c = EX_ERRDEAD;
-
- if (write(BGFiledes[1], &c, 1) == 1)
- LogPrintf(LogPHASE, "Parent notified of failure.\n");
- else
- LogPrintf(LogPHASE, "Failed to notify parent of failure.\n");
- close(BGFiledes[1]);
- }
LogPrintf(LogPHASE, "PPP Terminated (%s).\n", ex_desc(excode));
prompt_TtyOldMode(&prompt);
bundle_Close(SignalBundle, NULL, 1);
@@ -421,26 +412,26 @@ main(int argc, char **argv)
}
if (mode & MODE_DAEMON) {
- if (mode & MODE_BACKGROUND) {
- if (pipe(BGFiledes)) {
- LogPrintf(LogERROR, "pipe: %s\n", strerror(errno));
- Cleanup(EX_SOCK);
- }
- }
-
if (!(mode & MODE_DIRECT)) {
+ int bgpipe[2];
pid_t bgpid;
+ if (mode & MODE_BACKGROUND && pipe(bgpipe)) {
+ LogPrintf(LogERROR, "pipe: %s\n", strerror(errno));
+ Cleanup(EX_SOCK);
+ }
+
bgpid = fork();
if (bgpid == -1) {
LogPrintf(LogERROR, "fork: %s\n", strerror(errno));
Cleanup(EX_SOCK);
}
+
if (bgpid) {
char c = EX_NORMAL;
if (mode & MODE_BACKGROUND) {
- close(BGFiledes[1]);
+ close(bgpipe[1]);
BGPid = bgpid;
/* If we get a signal, kill the child */
signal(SIGHUP, KillChild);
@@ -449,7 +440,7 @@ main(int argc, char **argv)
signal(SIGQUIT, KillChild);
/* Wait for our child to close its pipe before we exit */
- if (read(BGFiledes[0], &c, 1) != 1) {
+ if (read(bgpipe[0], &c, 1) != 1) {
prompt_Printf(&prompt, "Child exit, no status.\n");
LogPrintf(LogPHASE, "Parent: Child exit, no status.\n");
} else if (c == EX_NORMAL) {
@@ -460,11 +451,13 @@ main(int argc, char **argv)
LogPrintf(LogPHASE, "Parent: Child failed (%s).\n",
ex_desc((int) c));
}
- close(BGFiledes[0]);
+ close(bgpipe[0]);
}
return c;
- } else if (mode & MODE_BACKGROUND)
- close(BGFiledes[0]);
+ } else if (mode & MODE_BACKGROUND) {
+ close(bgpipe[0]);
+ bundle->notify.fd = bgpipe[1];
+ }
}
prompt_Init(&prompt, PROMPT_NONE);