Fix command logging (broken with the "allow" command).
This commit is contained in:
parent
f38c8654e5
commit
1b096d24d9
@ -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)
|
||||
FindExec(Commands, argc, argv);
|
||||
if (argc > 0) {
|
||||
if (LogIsKept(LogCOMMAND)) {
|
||||
static char buf[LINE_LEN];
|
||||
int f, n;
|
||||
|
||||
if (prompt)
|
||||
Prompt();
|
||||
*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);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 == '#') {
|
||||
|
Loading…
Reference in New Issue
Block a user