summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/command.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2001-01-26 01:41:34 +0000
committerbrian <brian@FreeBSD.org>2001-01-26 01:41:34 +0000
commit63b65f9457011d370ef859a506f558b2731883d2 (patch)
tree694b69d9cd6e10dc4a8f60f6fc9ebc124e7875db /usr.sbin/ppp/command.c
parenta4be54702c06f4adfd819f74d6f5586d5362b361 (diff)
downloadFreeBSD-src-63b65f9457011d370ef859a506f558b2731883d2.zip
FreeBSD-src-63b65f9457011d370ef859a506f558b2731883d2.tar.gz
Allow ``set server closed'' to close the diagnostic socket.
Allow ``set server open'' to re-open the diagnostic socket. Handle SIGUSR1 by re-opening the diagnostic socket When receiving SIGUSR2 (and in ``set server none''), don't forget the socket details so that ``set server open'' and SIGUSR1 open it again. Don't create the diagnostic socket as uid 0 ! It's far to dangerous.
Diffstat (limited to 'usr.sbin/ppp/command.c')
-rw-r--r--usr.sbin/ppp/command.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 05b25fd..ae68092 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -1287,14 +1287,35 @@ SetServer(struct cmdargs const *arg)
return -1;
}
} else if (strcasecmp(port, "none") == 0) {
+ if (server_Clear(arg->bundle))
+ log_Printf(LogPHASE, "Disabled server socket\n");
+ return 0;
+ } else if (strcasecmp(port, "open") == 0) {
+ switch (server_Reopen(arg->bundle)) {
+ case SERVER_OK:
+ return 0;
+ case SERVER_FAILED:
+ log_Printf(LogPHASE, "Failed to reopen server port\n");
+ return 1;
+ case SERVER_UNSET:
+ log_Printf(LogPHASE, "Cannot reopen unset server socket\n");
+ return 1;
+ default:
+ break;
+ }
+ return -1;
+ } else if (strcasecmp(port, "closed") == 0) {
if (server_Close(arg->bundle))
- log_Printf(LogPHASE, "Disabled server port.\n");
+ log_Printf(LogPHASE, "Closed server socket\n");
+ else
+ log_Printf(LogWARN, "Server socket not open\n");
+
return 0;
} else
return -1;
- strncpy(server.passwd, passwd, sizeof server.passwd - 1);
- server.passwd[sizeof server.passwd - 1] = '\0';
+ strncpy(server.cfg.passwd, passwd, sizeof server.cfg.passwd - 1);
+ server.cfg.passwd[sizeof server.cfg.passwd - 1] = '\0';
if (*port == '/') {
mode_t imask;
@@ -2060,8 +2081,8 @@ static struct cmdtab const SetCommands[] = {
"Redial timeout", "set redial secs[+inc[-incmax]][.next] [attempts]"},
{"sendpipe", NULL, SetVariable, LOCAL_AUTH,
"SENDPIPE value", "set sendpipe value", (const void *)VAR_SENDPIPE},
- {"server", "socket", SetServer, LOCAL_AUTH,
- "server port", "set server|socket TcpPort|LocalName|none password [mask]"},
+ {"server", "socket", SetServer, LOCAL_AUTH, "diagnostic port",
+ "set server|socket TcpPort|LocalName|none|open|closed [password [mask]]"},
{"speed", NULL, SetModemSpeed, LOCAL_AUTH | LOCAL_CX,
"physical speed", "set speed value|sync"},
{"stopped", NULL, SetStoppedTimeout, LOCAL_AUTH | LOCAL_CX,
OpenPOWER on IntegriCloud