Add LOG_WARN alias

Along with syslogp(), this is ia killer vendor lock-in feature.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-06 13:35:44 +01:00
parent 31d7298516
commit fc4b804a6d
7 changed files with 20 additions and 24 deletions

View File

@ -236,6 +236,8 @@ Critical conditions, e.g., hard device errors.
Errors.
.It Dv LOG_WARNING
Warning messages.
.It Dv LOG_WARN
Warning messages, alias.
.It Dv LOG_NOTICE
Conditions that are not error conditions,
but should possibly be handled specially.

View File

@ -218,8 +218,7 @@ static enum LOGSRC GetKernelLogSrc(void)
* issue an error message and simply shut-off console
* logging completely.
*/
Syslog(LOG_WARNING, "Cannot set console log level - disabling "
"console output.");
Syslog(LOG_WARN, "Cannot set console log level - disabling console output.");
}
/*
@ -230,15 +229,12 @@ static enum LOGSRC GetKernelLogSrc(void)
((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT))) {
/* Initialize kernel logging. */
ksyslog(1, NULL, 0);
Syslog(LOG_INFO, "klogd v%s, log source = ksyslog "
"started.",
PACKAGE_VERSION);
Syslog(LOG_INFO, "klogd v%s, log source = ksyslog started.", PACKAGE_VERSION);
return kernel;
}
if ((kmsg = open(_PATH_KLOG, O_RDONLY)) < 0) {
fprintf(stderr, "klogd: Cannot open proc file system, "
"%d - %s.\n",
fprintf(stderr, "klogd: Cannot open proc file system, %d - %s.\n",
errno, strerror(errno));
ksyslog(7, NULL, 0);
exit(1);
@ -293,7 +289,7 @@ extern void Syslog(int priority, char *fmt, ...)
priority = LOG_ERR;
break;
case '4':
priority = LOG_WARNING;
priority = LOG_WARN;
break;
case '5':
priority = LOG_NOTICE;
@ -565,8 +561,7 @@ static void LogKernelLine(void)
if (errno == EINTR)
return;
fprintf(stderr,
"klogd: Error return from sys_sycall: %d - %s\n",
fprintf(stderr, "klogd: Error return from sys_sycall: %d - %s\n",
errno, strerror(errno));
return;
}
@ -695,9 +690,7 @@ int main(int argc, char *argv[])
if (log_level != NULL) {
if ((strlen(log_level) > 1) ||
(strchr("12345678", *log_level) == NULL)) {
fprintf(stderr, "klogd: Invalid console logging "
"level <%s> specified.\n",
log_level);
fprintf(stderr, "klogd: Invalid console logging level <%s>.\n", log_level);
return 1;
}
console_log_level = *log_level - '0';

View File

@ -24,8 +24,8 @@
#define SYSKLOGD_KLOGD_H_
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include "syslog.h"
extern int InitKsyms(char *);
extern int InitMsyms(void);

View File

@ -99,7 +99,7 @@ int InitKsyms(char *mapfile)
*/
if (mapfile == NULL) {
if ((mapfile = FindSymbolFile()) == NULL) {
Syslog(LOG_WARNING, "Cannot find a map file.");
Syslog(LOG_WARN, "Cannot find a map file.");
if (debugging)
fputs("Cannot find a map file.\n", stderr);
return 0;
@ -107,7 +107,7 @@ int InitKsyms(char *mapfile)
}
if ((sym_file = fopen(mapfile, "r")) == NULL) {
Syslog(LOG_WARNING, "Cannot open map file: %s.", mapfile);
Syslog(LOG_WARN, "Cannot open map file: %s.", mapfile);
if (debugging)
fprintf(stderr, "Cannot open map file: %s.\n", mapfile);
return 0;
@ -144,12 +144,12 @@ int InitKsyms(char *mapfile)
Syslog(LOG_INFO, "Loaded %d symbols from %s.", num_syms, mapfile);
switch (version) {
case -1:
Syslog(LOG_WARNING, "Symbols do not match kernel version.");
Syslog(LOG_WARN, "Symbols do not match kernel version.");
num_syms = 0;
break;
case 0:
Syslog(LOG_WARNING, "Cannot verify that symbols match "
Syslog(LOG_WARN, "Cannot verify that symbols match "
"kernel version.");
break;
@ -599,7 +599,7 @@ char *ExpandKadds(char *line, char *el)
*/
if (i_am_paranoid &&
(strstr(line, "Oops:") != NULL) && !InitMsyms())
Syslog(LOG_WARNING, "Cannot load kernel module symbols.\n");
Syslog(LOG_WARN, "Cannot load kernel module symbols.\n");
/*
* Early return if there do not appear to be any kernel

View File

@ -242,7 +242,7 @@ struct Module *AddModule(const char *module)
if (num_modules == 0) {
sym_array_modules = (struct Module *)malloc(sizeof(struct Module));
if (sym_array_modules == NULL) {
Syslog(LOG_WARNING, "Cannot allocate Module array.\n");
Syslog(LOG_WARN, "Cannot allocate Module array.\n");
return NULL;
}
mp = sym_array_modules;
@ -250,7 +250,7 @@ struct Module *AddModule(const char *module)
/* Allocate space for the module. */
mp = realloc(sym_array_modules, (num_modules + 1) * sizeof(struct Module));
if (mp == NULL) {
Syslog(LOG_WARNING, "Cannot allocate Module array.\n");
Syslog(LOG_WARN, "Cannot allocate Module array.\n");
return NULL;
}

View File

@ -63,6 +63,7 @@
#define LOG_ALERT 1 /* action must be taken immediately */
#define LOG_CRIT 2 /* critical conditions */
#define LOG_ERR 3 /* error conditions */
#define LOG_WARN 4 /* warning conditions, alias */
#define LOG_WARNING 4 /* warning conditions */
#define LOG_NOTICE 5 /* normal but significant condition */
#define LOG_INFO 6 /* informational */

View File

@ -1641,12 +1641,12 @@ void fprintlog(struct filed *f, struct buf_msg *buffer)
logit("Failure resolving %s:%s: %s\n", host, service, gai_strerror(err));
logit("Retries: %d\n", f->f_prevcount);
if (--f->f_prevcount < 0) {
flog(LOG_SYSLOG | LOG_WARNING, "Still cannot find %s, "
flog(LOG_SYSLOG | LOG_WARN, "Still cannot find %s, "
"giving up: %s", host, gai_strerror(err));
logit("Giving up.\n");
f->f_type = F_UNUSED;
} else {
flog(LOG_SYSLOG | LOG_WARNING, "Still cannot find %s, "
flog(LOG_SYSLOG | LOG_WARN, "Still cannot find %s, "
"will try again later: %s", host, gai_strerror(err));
logit("Left retries: %d\n", f->f_prevcount);
}
@ -2606,7 +2606,7 @@ static struct filed *cfline(char *line)
err = nslookup(p, service, &ai);
if (err) {
flog(LOG_SYSLOG | LOG_WARNING, "Cannot find %s, "
flog(LOG_SYSLOG | LOG_WARN, "Cannot find %s, "
"will try again later: %s", p, gai_strerror(err));
/*
* The host might be unknown due to an inaccessible