diff options
author | brian <brian@FreeBSD.org> | 1997-11-13 14:43:20 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-11-13 14:43:20 +0000 |
commit | 1b096d24d96081ff46460353a825801f161ba97a (patch) | |
tree | bf625cfae5f3ec15d8d579813e0dd6f06a0157a5 /usr.sbin/ppp | |
parent | f38c8654e56487fbac49838d797ac4687ff69200 (diff) | |
download | FreeBSD-src-1b096d24d96081ff46460353a825801f161ba97a.zip FreeBSD-src-1b096d24d96081ff46460353a825801f161ba97a.tar.gz |
Fix command logging (broken with the "allow" command).
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/command.c | 32 | ||||
-rw-r--r-- | usr.sbin/ppp/command.h | 6 | ||||
-rw-r--r-- | usr.sbin/ppp/main.c | 13 | ||||
-rw-r--r-- | usr.sbin/ppp/systems.c | 5 |
4 files changed, 33 insertions, 23 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 025fda0..5156962 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.100 1997/11/12 16:34:50 brian Exp $ + * $Id: command.c,v 1.101 1997/11/12 18:47:28 brian Exp $ * */ #include <sys/param.h> @@ -707,23 +707,39 @@ InterpretCommand(char *buff, int nb, int *argc, char ***argv) } void -RunCommand(int argc, char **argv, int prompt) +RunCommand(int argc, char **argv, const char *label) { - if (argc > 0) + if (argc > 0) { + if (LogIsKept(LogCOMMAND)) { + static char buf[LINE_LEN]; + int f, n; + + *buf = '\0'; + if (label) { + strcpy(buf, label); + strcat(buf, ": "); + } + n = strlen(buf); + for (f = 0; f < argc; f++) { + if (n < sizeof(buf)-1 && f) + buf[n++] = ' '; + strncpy(buf+n, argv[f], sizeof(buf)-n-1); + n += strlen(buf+n); + } + LogPrintf(LogCOMMAND, "%s\n", buf); + } FindExec(Commands, argc, argv); - - if (prompt) - Prompt(); + } } void -DecodeCommand(char *buff, int nb, int prompt) +DecodeCommand(char *buff, int nb, const char *label) { int argc; char **argv; InterpretCommand(buff, nb, &argc, &argv); - RunCommand(argc, argv, prompt); + RunCommand(argc, argv, label); } static int diff --git a/usr.sbin/ppp/command.h b/usr.sbin/ppp/command.h index 37eddc4..16954ee 100644 --- a/usr.sbin/ppp/command.h +++ b/usr.sbin/ppp/command.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.h,v 1.9 1997/11/04 01:17:00 brian Exp $ + * $Id: command.h,v 1.10 1997/11/11 22:58:10 brian Exp $ * * TODO: */ @@ -49,5 +49,5 @@ extern int SetVariable(struct cmdtab const *, int, char **, int); extern void Prompt(void); extern int IsInteractive(int); extern void InterpretCommand(char *, int, int *, char ***); -extern void RunCommand(int, char **, int); -extern void DecodeCommand(char *, int, int); +extern void RunCommand(int, char **, const char *label); +extern void DecodeCommand(char *, int, const char *label); diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 0da1bf5..abe04a3 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.94 1997/11/13 12:09:53 brian Exp $ + * $Id: main.c,v 1.95 1997/11/13 12:10:50 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -562,14 +562,9 @@ ReadTty() aft_cmd = 1; if (linebuff[n-1] == '\n') linebuff[--n] = '\0'; - if (n) { - if (IsInteractive(0)) - LogPrintf(LogCOMMAND, "%s\n", linebuff); - else - LogPrintf(LogCOMMAND, "Client: %s\n", linebuff); - DecodeCommand(linebuff, n, 1); - } else - Prompt(); + if (n) + DecodeCommand(linebuff, n, IsInteractive(0) ? NULL : "Client"); + Prompt(); } else { LogPrintf(LogPHASE, "client connection closed.\n"); oVarTerm = VarTerm; diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c index b7ed109..53ad8de 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: systems.c,v 1.24 1997/11/12 15:50:38 brian Exp $ + * $Id: systems.c,v 1.25 1997/11/12 16:34:51 brian Exp $ * * TODO: */ @@ -298,11 +298,10 @@ ReadSystem(const char *name, const char *file, int doexec) InterpretCommand(cp, len, &argc, &argv); allowcmd = argc > 0 && !strcasecmp(*argv, "allow"); if ((!doexec && allowcmd) || (doexec && !allowcmd)) { - LogPrintf(LogCOMMAND, "%s: %s\n", name, cp); olauth = VarLocalAuth; if (VarLocalAuth == LOCAL_NO_AUTH) VarLocalAuth = LOCAL_AUTH; - RunCommand(argc, argv, 0); + RunCommand(argc, argv, name); VarLocalAuth = olauth; } } else if (*cp == '#') { |