diff options
Diffstat (limited to 'usr.sbin/ppp')
-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 b017488..7c45d17 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 ede9920..70fe4c2 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 631fe89..5e39f00 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 5e160f6..db29092 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 */ |