diff options
author | Brian Somers <brian@FreeBSD.org> | 1999-09-06 08:16:33 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 1999-09-06 08:16:33 +0000 |
commit | b4f63b0b8b2f16453b945bbaeb714eb7d73f2c1a (patch) | |
tree | 52351e4d2fdb2bcc8013d8565f93371334d9b8e7 | |
parent | ecab1f682479e3dcbfae05aedf29a9adac47afad (diff) | |
download | src-b4f63b0b8b2f16453b945bbaeb714eb7d73f2c1a.tar.gz src-b4f63b0b8b2f16453b945bbaeb714eb7d73f2c1a.zip |
When logging warning messages, there are now three scenarios:
o If a prompt is executing the command, only display the warning to
that prompt
o If a prompt is executing a ``load'' command, display the warning
to all prompts *and* syslog
o Otherwise, display the warning to all prompts *and* syslog.
Notes
Notes:
svn path=/head/; revision=51005
-rw-r--r-- | usr.sbin/ppp/log.c | 10 | ||||
-rw-r--r-- | usr.sbin/ppp/log.h | 1 | ||||
-rw-r--r-- | usr.sbin/ppp/prompt.c | 7 | ||||
-rw-r--r-- | usr.sbin/ppp/systems.c | 11 |
4 files changed, 24 insertions, 5 deletions
diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c index b017488829f8..7c45d17f7521 100644 --- a/usr.sbin/ppp/log.c +++ b/usr.sbin/ppp/log.c @@ -72,6 +72,7 @@ static u_long LogMask = MSK(LogPHASE); static u_long LogMaskLocal = MSK(LogERROR) | MSK(LogALERT) | MSK(LogWARN); static int LogTunno = -1; static struct prompt *promptlist; /* Where to log local stuff */ +struct prompt *log_PromptContext; int log_PromptListChanged; struct prompt * @@ -307,20 +308,23 @@ log_Printf(int lev, const char *fmt,...) if (log_IsKept(lev)) { char nfmt[200]; - if ((log_IsKept(lev) & LOG_KEPT_LOCAL) && promptlist) { + if (promptlist && (log_IsKept(lev) & LOG_KEPT_LOCAL)) { if ((log_IsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1) snprintf(nfmt, sizeof nfmt, "%s%d: %s: %s", TUN_NAME, LogTunno, log_Name(lev), fmt); else snprintf(nfmt, sizeof nfmt, "%s: %s", log_Name(lev), fmt); - for (prompt = promptlist; prompt; prompt = prompt->next) + if (log_PromptContext && lev == LogWARN) + /* Warnings just go to the current prompt */ + prompt_vPrintf(log_PromptContext, nfmt, ap); + else for (prompt = promptlist; prompt; prompt = prompt->next) if (lev > LogMAXCONF || (prompt->logmask & MSK(lev))) prompt_vPrintf(prompt, nfmt, ap); } if ((log_IsKept(lev) & LOG_KEPT_SYSLOG) && - (lev != LogWARN || !promptlist)) { + (lev != LogWARN || !log_PromptContext)) { if ((log_IsKept(LogTUN) & LOG_KEPT_SYSLOG) && LogTunno != -1) snprintf(nfmt, sizeof nfmt, "%s%d: %s: %s", TUN_NAME, LogTunno, log_Name(lev), fmt); diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h index ede99204ba2c..70fe4c2e6514 100644 --- a/usr.sbin/ppp/log.h +++ b/usr.sbin/ppp/log.h @@ -87,6 +87,7 @@ extern int log_ShowLevel(struct cmdargs const *); extern int log_SetLevel(struct cmdargs const *); extern int log_ShowWho(struct cmdargs const *); +extern struct prompt *log_PromptContext; extern int log_PromptListChanged; extern void log_RegisterPrompt(struct prompt *); extern void log_UnRegisterPrompt(struct prompt *); diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c index 631fe8984e4f..5e39f00ff5fd 100644 --- a/usr.sbin/ppp/prompt.c +++ b/usr.sbin/ppp/prompt.c @@ -173,6 +173,7 @@ static void prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) { struct prompt *p = descriptor2prompt(d); + struct prompt *op; int n; char ch; char linebuff[LINE_LEN]; @@ -186,8 +187,12 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) linebuff[n] = '\0'; p->nonewline = 1; /* Maybe command_Decode does a prompt */ prompt_Required(p); - if (n) + if (n) { + if ((op = log_PromptContext) == NULL) + log_PromptContext = p; command_Decode(bundle, linebuff, n, p, p->src.from); + log_PromptContext = op; + } } else if (n <= 0) { log_Printf(LogPHASE, "%s: Client connection closed.\n", p->src.from); if (!p->owner) diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c index 5e160f681439..db29092fc1d2 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -267,6 +267,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file, int allowcmd; int indent; char arg[LINE_LEN]; + struct prompt *op; if (*file == '/') snprintf(filename, sizeof filename, "%s", file); @@ -342,9 +343,17 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file, argc = command_Interpret(cp, len, argv); allowcmd = argc > 0 && !strcasecmp(argv[0], "allow"); if ((!(how == SYSTEM_EXEC) && allowcmd) || - ((how == SYSTEM_EXEC) && !allowcmd)) + ((how == SYSTEM_EXEC) && !allowcmd)) { + /* + * Disable any context so that warnings are given to everyone, + * including syslog. + */ + op = log_PromptContext; + log_PromptContext = NULL; command_Run(bundle, argc, (char const *const *)argv, prompt, name, cx); + log_PromptContext = op; + } } fclose(fp); /* everything read - get out */ |