summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/Makefile3
-rw-r--r--usr.sbin/ppp/auth.c4
-rw-r--r--usr.sbin/ppp/chat.c8
-rw-r--r--usr.sbin/ppp/command.c71
-rw-r--r--usr.sbin/ppp/defs.h4
-rw-r--r--usr.sbin/ppp/main.c82
-rw-r--r--usr.sbin/ppp/modem.c1
7 files changed, 141 insertions, 32 deletions
diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile
index c0af19d..7d4ba53 100644
--- a/usr.sbin/ppp/Makefile
+++ b/usr.sbin/ppp/Makefile
@@ -1,10 +1,11 @@
-# $Id: Makefile,v 1.1.1.1 1995/01/31 06:29:55 amurai Exp $
+# $Id: Makefile,v 1.2 1995/02/26 12:17:08 amurai Exp $
PROG= ppp
SRCS= async.c auth.c ccp.c chap.c chat.c command.c filter.c fsm.c hdlc.c \
ip.c ipcp.c lcp.c lqr.c log.c main.c mbuf.c md5c.c modem.c os.c \
pap.c pred.c route.c slcompress.c timer.c systems.c uucplock.c vars.c \
vjcomp.c arp.c
+#CFLAGS+= -DHAVE_SHELL_CMD_WITH_ANY_MODE
MAN8= ppp.8
BINMODE=4555
BINOWN= root
diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c
index c2efa7b..3d76d5c 100644
--- a/usr.sbin/ppp/auth.c
+++ b/usr.sbin/ppp/auth.c
@@ -17,10 +17,10 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: auth.c,v 1.3 1995/02/27 10:57:38 amurai Exp $
+ * $Id: auth.c,v 1.4 1995/05/30 03:50:25 rgrimes Exp $
*
* TODO:
- * o Imprement check against with registerd IP addresses.
+ * o Implement check against with registered IP addresses.
*/
#include "fsm.h"
#include "lcpproto.h"
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c
index ebfefe8..5d49a1b 100644
--- a/usr.sbin/ppp/chat.c
+++ b/usr.sbin/ppp/chat.c
@@ -18,7 +18,7 @@
* Columbus, OH 43221
* (614)451-1883
*
- * $Id: chat.c,v 1.3 1995/03/11 15:18:37 amurai Exp $
+ * $Id: chat.c,v 1.4 1995/05/30 03:50:29 rgrimes Exp $
*
* TODO:
* o Support more UUCP compatible control sequences.
@@ -373,7 +373,11 @@ char *str;
} else {
(void) ExpandString(str, buff+2, 1);
}
- LogPrintf(LOG_CHAT, "sending: %s\n", buff+2);
+ if (strstr(str, "\\P")) { /* Do not log the password itself. */
+ LogPrintf(LOG_CHAT, "sending: %s\n", str);
+ } else {
+ LogPrintf(LOG_CHAT, "sending: %s\n", buff+2);
+ }
cp = buff;
if (DEV_IS_SYNC)
bcopy("\377\003", buff, 2); /* Prepend HDLC header */
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index ee2754c..e7c005a 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -36,6 +36,7 @@
#include <arpa/inet.h>
#include <net/route.h>
#include "os.h"
+#include <paths.h>
extern int MakeArgs();
extern void Cleanup(), TtyTermMode(), PacketMode();
@@ -46,6 +47,7 @@ extern int LoadCommand(), SaveCommand();
extern int ChangeParity(char *);
extern int SelectSystem();
extern int ShowRoute();
+extern void TtyOldMode(), TtyCommandMode();
extern struct pppvars pppVars;
struct in_addr ifnetmask;
@@ -53,6 +55,7 @@ struct in_addr ifnetmask;
static int ShowCommand(), TerminalCommand(), QuitCommand();
static int CloseCommand(), DialCommand(), DownCommand();
static int SetCommand(), AddCommand(), DeleteCommand();
+static int ShellCommand();
static int
HelpCommand(list, argc, argv, plist)
@@ -93,11 +96,11 @@ IsInteractive()
char *mes = NULL;
if (mode & MODE_AUTO)
- mes = "Working as auto mode.";
+ mes = "Working in auto mode.";
else if (mode & MODE_DIRECT)
- mes = "Working as direct mode.";
+ mes = "Working in direct mode.";
else if (mode & MODE_DEDICATED)
- mes = "Workring as dedicated mode.";
+ mes = "Working in dedicated mode.";
if (mes) {
printf("%s\n", mes);
return(0);
@@ -137,6 +140,66 @@ char **argv;
return(1);
}
+static int
+ShellCommand(cmdlist, argc, argv)
+struct cmdtab *cmdlist;
+int argc;
+char **argv;
+{
+ const char *shell;
+ pid_t shpid;
+
+ if((shell = getenv("SHELL")) == 0) {
+ shell = _PATH_BSHELL;
+ }
+
+#ifndef HAVE_SHELL_CMD_WITH_ANY_MODE
+ if( mode != MODE_INTER) {
+ fprintf(stdout,
+ "Can start an shell only in interactive mode\n");
+ return(1);
+ }
+#else
+ if(argc == 0 && !(mode & MODE_INTER)) {
+ fprintf(stderr,
+ "Can start an interactive shell only in interactive mode\n");
+ return(1);
+ }
+#endif /* HAVE_SHELL_CMD_WITH_ANY_MODE */
+
+ if((shpid = fork()) == 0) {
+ int i;
+ for(i = 3; i < getdtablesize(); i++)
+ (void)close(i);
+
+ /*
+ * We are running setuid, we should change to
+ * real user for avoiding security problems.
+ */
+ setgid( getgid() );
+ setuid( getuid() );
+
+ TtyOldMode();
+ if(argc > 0)
+ execvp(argv[0], argv);
+ else
+ execl(shell, shell, NULL);
+
+ fprintf(stdout, "exec() of %s failed\n", argc > 0? argv[0]: shell);
+ exit(255);
+ }
+ if( shpid == (pid_t)-1 ) {
+ fprintf(stdout, "Fork failed\n");
+ } else {
+ int status;
+ (void)waitpid(shpid, &status, 0);
+ }
+
+ TtyCommandMode(1);
+
+ return(0);
+}
+
static char StrOption[] = "option ..";
static char StrRemote[] = "[remote]";
char StrNull[] = "";
@@ -168,6 +231,8 @@ struct cmdtab Commands[] = {
"Save settings", StrNull},
{ "set", "setup", SetCommand, LOCAL_AUTH,
"Set parameters", "var value"},
+ { "shell", "!", ShellCommand, LOCAL_AUTH,
+ "Run a subshell", "[sh command]"},
{ "show", NULL, ShowCommand, LOCAL_AUTH,
"Show status and statictics", "var"},
{ "term", NULL, TerminalCommand,LOCAL_AUTH,
diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h
index c85feb9..b5dc08a 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:$
+ * $Id: defs.h,v 1.2 1995/02/26 12:17:25 amurai Exp $
*
* TODO:
*/
@@ -38,7 +38,7 @@
*/
#define LOGFILE "/var/log/ppp.log" /* Name of log file */
#ifdef __FreeBSD__
-#define MODEM_DEV "/dev/cua01" /* name of tty device */
+#define MODEM_DEV "/dev/cuaa1" /* name of tty device */
#else
#define MODEM_DEV "/dev/tty01" /* name of tty device */
#endif
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index e6aae6e..4367750 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -59,6 +59,7 @@ extern void DecodeCommand(), Prompt();
extern int IsInteractive();
extern struct in_addr ifnetmask;
static void DoLoop(void);
+static void TerminalStop();
static struct termios oldtio; /* Original tty mode */
static struct termios comtio; /* Command level tty mode */
@@ -91,8 +92,9 @@ TtyInit()
/*
* Set tty into command mode. We allow canonical input and echo processing.
*/
-static void
-TtyCommandMode()
+void
+TtyCommandMode(prompt)
+int prompt;
{
struct termios newtio;
int stat;
@@ -100,7 +102,7 @@ TtyCommandMode()
if (!(mode & MODE_INTER))
return;
tcgetattr(0, &newtio);
- newtio.c_lflag |= (ECHO|ICANON);
+ newtio.c_lflag |= (ECHO|ISIG|ICANON);
newtio.c_iflag = oldtio.c_iflag;
newtio.c_oflag |= OPOST;
tcsetattr(0, TCSADRAIN, &newtio);
@@ -108,7 +110,7 @@ TtyCommandMode()
stat |= O_NONBLOCK;
fcntl(0, F_SETFL, stat);
TermMode = 0;
- Prompt(0);
+ if(prompt) Prompt(0);
}
/*
@@ -127,18 +129,23 @@ TtyTermMode()
}
void
-Cleanup(excode)
-int excode;
+TtyOldMode()
{
int stat;
- OsLinkdown();
-#ifdef notdef
stat = fcntl(0, F_GETFL, 0);
stat &= ~O_NONBLOCK;
fcntl(0, F_SETFL, stat);
tcsetattr(0, TCSANOW, &oldtio);
-#endif
+}
+
+void
+Cleanup(excode)
+int excode;
+{
+ int stat;
+
+ OsLinkdown();
OsCloseLink(1);
sleep(1);
if (mode & MODE_AUTO)
@@ -148,12 +155,7 @@ int excode;
LogClose();
if (server > 0)
close(server);
-#ifndef notdef
- stat = fcntl(0, F_GETFL, 0);
- stat &= ~O_NONBLOCK;
- fcntl(0, F_SETFL, stat);
- tcsetattr(0, TCSANOW, &oldtio);
-#endif
+ TtyOldMode();
exit(excode);
}
@@ -162,7 +164,6 @@ static void
Hangup()
{
LogPrintf(LOG_PHASE, "SIGHUP\n");
- signal(SIGHUP, Hangup);
Cleanup(EX_HANGUP);
}
@@ -174,10 +175,30 @@ CloseSession()
Cleanup(EX_TERM);
}
+
+static void
+TerminalCont()
+{
+ (void)signal(SIGCONT, SIG_DFL);
+ (void)signal(SIGTSTP, TerminalStop);
+ TtyCommandMode(getpgrp() == tcgetpgrp(0));
+}
+
+static void
+TerminalStop(signo)
+int signo;
+{
+ (void)signal(SIGCONT, TerminalCont);
+ TtyOldMode();
+ signal(SIGTSTP, SIG_DFL);
+ kill(getpid(), signo);
+}
+
+
void
Usage()
{
- fprintf(stderr, "Usage: ppp [-auto | -direct -dedicated] [system]\n");
+ fprintf(stderr, "Usage: ppp [-auto | -direct | -dedicated] [system]\n");
exit(EX_START);
}
@@ -280,6 +301,7 @@ char **argv;
signal(SIGHUP, Hangup);
signal(SIGTERM, CloseSession);
signal(SIGINT, CloseSession);
+ signal(SIGQUIT, CloseSession);
#ifdef SIGSEGV
signal(SIGSEGV, Hangup);
#endif
@@ -289,6 +311,18 @@ char **argv;
#ifdef SIGALRM
signal(SIGALRM, SIG_IGN);
#endif
+ if(mode & MODE_INTER)
+ {
+#ifdef SIGTSTP
+ signal(SIGTSTP, TerminalStop);
+#endif
+#ifdef SIGTTIN
+ signal(SIGTTIN, TerminalStop);
+#endif
+#ifdef SIGTTOU
+ signal(SIGTTOU, SIG_IGN);
+#endif
+ }
if (dstsystem) {
if (SelectSystem(dstsystem, CONFFILE) < 0) {
@@ -348,7 +382,7 @@ char **argv;
} else {
server = -1;
TtyInit();
- TtyCommandMode();
+ TtyCommandMode(1);
}
LogPrintf(LOG_PHASE, "PPP Started.\n");
@@ -383,7 +417,7 @@ PacketMode()
else
LcpOpen(VarOpenMode);
if ((mode & (MODE_INTER|MODE_AUTO)) == MODE_INTER) {
- TtyCommandMode();
+ TtyCommandMode(1);
fprintf(stderr, "Packet mode.\r\n");
}
}
@@ -391,7 +425,7 @@ PacketMode()
static void
ShowHelp()
{
- fprintf(stderr, "Following commands are available\r\n");
+ fprintf(stderr, "The following commands are available:\r\n");
fprintf(stderr, " ~p\tEnter to Packet mode\r\n");
fprintf(stderr, " ~.\tTerminate program\r\n");
}
@@ -475,7 +509,7 @@ ReadTty()
#endif
case '.':
TermMode = 1;
- TtyCommandMode();
+ TtyCommandMode(1);
break;
default:
if (write(modem, &ch, n) < 0)
@@ -554,6 +588,9 @@ DoLoop()
u_char rbuff[MAX_MRU];
int dial_up;
int qlen;
+ pid_t pgroup;
+
+ pgroup = getpgrp();
if (mode & MODE_DIRECT) {
modem = OpenModem(mode);
@@ -699,7 +736,8 @@ DoLoop()
Prompt(0);
}
- if ((mode & MODE_INTER) && FD_ISSET(netfd, &rfds)) {
+ if ((mode & MODE_INTER) && FD_ISSET(netfd, &rfds) &&
+ pgroup == tcgetpgrp(0)) {
/* something to read from tty */
ReadTty();
}
diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c
index 917c083..8c90251 100644
--- a/usr.sbin/ppp/modem.c
+++ b/usr.sbin/ppp/modem.c
@@ -767,6 +767,7 @@ ShowModemStatus()
ioctl(modem, TIOCOUTQ, &nb);
printf("outq: %d\n", nb);
#endif
+ printf("outqlen: %d\n", ModemQlen());
printf("DialScript = %s\n", VarDialScript);
printf("LoginScript = %s\n", VarLoginScript);
printf("PhoneNumber = %s\n", VarPhone);
OpenPOWER on IntegriCloud