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

View File

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

View File

@ -99,7 +99,7 @@ int InitKsyms(char *mapfile)
*/ */
if (mapfile == NULL) { if (mapfile == NULL) {
if ((mapfile = FindSymbolFile()) == NULL) { if ((mapfile = FindSymbolFile()) == NULL) {
Syslog(LOG_WARNING, "Cannot find a map file."); Syslog(LOG_WARN, "Cannot find a map file.");
if (debugging) if (debugging)
fputs("Cannot find a map file.\n", stderr); fputs("Cannot find a map file.\n", stderr);
return 0; return 0;
@ -107,7 +107,7 @@ int InitKsyms(char *mapfile)
} }
if ((sym_file = fopen(mapfile, "r")) == NULL) { 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) if (debugging)
fprintf(stderr, "Cannot open map file: %s.\n", mapfile); fprintf(stderr, "Cannot open map file: %s.\n", mapfile);
return 0; return 0;
@ -144,12 +144,12 @@ int InitKsyms(char *mapfile)
Syslog(LOG_INFO, "Loaded %d symbols from %s.", num_syms, mapfile); Syslog(LOG_INFO, "Loaded %d symbols from %s.", num_syms, mapfile);
switch (version) { switch (version) {
case -1: case -1:
Syslog(LOG_WARNING, "Symbols do not match kernel version."); Syslog(LOG_WARN, "Symbols do not match kernel version.");
num_syms = 0; num_syms = 0;
break; break;
case 0: case 0:
Syslog(LOG_WARNING, "Cannot verify that symbols match " Syslog(LOG_WARN, "Cannot verify that symbols match "
"kernel version."); "kernel version.");
break; break;
@ -599,7 +599,7 @@ char *ExpandKadds(char *line, char *el)
*/ */
if (i_am_paranoid && if (i_am_paranoid &&
(strstr(line, "Oops:") != NULL) && !InitMsyms()) (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 * 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) { if (num_modules == 0) {
sym_array_modules = (struct Module *)malloc(sizeof(struct Module)); sym_array_modules = (struct Module *)malloc(sizeof(struct Module));
if (sym_array_modules == NULL) { if (sym_array_modules == NULL) {
Syslog(LOG_WARNING, "Cannot allocate Module array.\n"); Syslog(LOG_WARN, "Cannot allocate Module array.\n");
return NULL; return NULL;
} }
mp = sym_array_modules; mp = sym_array_modules;
@ -250,7 +250,7 @@ struct Module *AddModule(const char *module)
/* Allocate space for the module. */ /* Allocate space for the module. */
mp = realloc(sym_array_modules, (num_modules + 1) * sizeof(struct Module)); mp = realloc(sym_array_modules, (num_modules + 1) * sizeof(struct Module));
if (mp == NULL) { if (mp == NULL) {
Syslog(LOG_WARNING, "Cannot allocate Module array.\n"); Syslog(LOG_WARN, "Cannot allocate Module array.\n");
return NULL; return NULL;
} }

View File

@ -63,6 +63,7 @@
#define LOG_ALERT 1 /* action must be taken immediately */ #define LOG_ALERT 1 /* action must be taken immediately */
#define LOG_CRIT 2 /* critical conditions */ #define LOG_CRIT 2 /* critical conditions */
#define LOG_ERR 3 /* error conditions */ #define LOG_ERR 3 /* error conditions */
#define LOG_WARN 4 /* warning conditions, alias */
#define LOG_WARNING 4 /* warning conditions */ #define LOG_WARNING 4 /* warning conditions */
#define LOG_NOTICE 5 /* normal but significant condition */ #define LOG_NOTICE 5 /* normal but significant condition */
#define LOG_INFO 6 /* informational */ #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("Failure resolving %s:%s: %s\n", host, service, gai_strerror(err));
logit("Retries: %d\n", f->f_prevcount); logit("Retries: %d\n", f->f_prevcount);
if (--f->f_prevcount < 0) { 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)); "giving up: %s", host, gai_strerror(err));
logit("Giving up.\n"); logit("Giving up.\n");
f->f_type = F_UNUSED; f->f_type = F_UNUSED;
} else { } 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)); "will try again later: %s", host, gai_strerror(err));
logit("Left retries: %d\n", f->f_prevcount); logit("Left retries: %d\n", f->f_prevcount);
} }
@ -2606,7 +2606,7 @@ static struct filed *cfline(char *line)
err = nslookup(p, service, &ai); err = nslookup(p, service, &ai);
if (err) { 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)); "will try again later: %s", p, gai_strerror(err));
/* /*
* The host might be unknown due to an inaccessible * The host might be unknown due to an inaccessible