SHA256
1
0
forked from pool/mcelog

- bnc#774226 mcelog + systemd: won't start without MCELOG_ADMIN_EMAIL set

- fix uninitialized variable mail_setup

OBS-URL: https://build.opensuse.org/package/show/Base:System/mcelog?expand=0&rev=25
This commit is contained in:
Thomas Renninger 2012-08-16 14:47:20 +00:00 committed by Git OBS Bridge
parent 7da844b498
commit 8432bbd870
4 changed files with 68 additions and 21 deletions

View File

@ -1,11 +1,22 @@
--- mcelog-1.0pre3.6e4e2a000124/Makefile
---
Makefile | 10 ++-
email.c | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
email.h | 34 ++++++++++
mcelog.c | 93 +++++++++++++++++++++++++++++
mcelog.h | 1
msg.c | 8 ++
6 files changed, 343 insertions(+), 2 deletions(-)
Index: mcelog-1.0pre3.6e4e2a000124/Makefile
===================================================================
--- mcelog-1.0pre3.6e4e2a000124.orig/Makefile
+++ mcelog-1.0pre3.6e4e2a000124/Makefile
@@ -1,3 +1,4 @@
+CONFIG_EMAIL := 1
CFLAGS := -g -Os
prefix := /usr
etcprefix :=
@@ -34,7 +35,8 @@
@@ -34,7 +35,8 @@ OBJ := p4.o k8.o mcelog.o dmi.o tsc.o co
client.o cache.o sysfs.o yellow.o page.o rbtree.o \
xeon75xx.o sandy-bridge.o
DISKDB_OBJ := diskdb.o dimm.o db.o
@ -15,7 +26,7 @@
DOC := mce.pdf
ADD_DEFINES :=
@@ -46,6 +48,12 @@
@@ -46,6 +48,12 @@ OBJ += ${DISKDB_OBJ}
all: dbquery
endif
@ -28,9 +39,11 @@
SRC := $(OBJ:.o=.c)
mcelog: ${OBJ}
--- mcelog-1.0pre3.6e4e2a000124/email.c
Index: mcelog-1.0pre3.6e4e2a000124/email.c
===================================================================
--- /dev/null
+++ mcelog-1.0pre3.6e4e2a000124/email.c
@@ -0,0 +1,184 @@
@@ -0,0 +1,199 @@
+#include <unistd.h>
+#include <signal.h>
+#include <ctype.h>
@ -86,6 +99,21 @@
+ return 0;
+}
+
+int email_env(void)
+{
+ char *email_env = getenv("MCELOG_EMAIL_DEBUG");
+
+ if (email_env)
+ debug=0;
+
+ email_env = getenv("MCELOG_ADMIN_EMAIL");
+ if (email_env) {
+ strncpy(c_recipient, email_env, MAX_STRING_LEN - 1);
+ return 1;
+ }
+ return 0;
+}
+
+/* Callback to prnt the recipient status */
+static void
+print_recipient_status (smtp_recipient_t recipient,
@ -215,9 +243,11 @@
+ smtp_destroy_session (session);
+ return 0;
+}
--- mcelog-1.0pre3.6e4e2a000124/email.h
Index: mcelog-1.0pre3.6e4e2a000124/email.h
===================================================================
--- /dev/null
+++ mcelog-1.0pre3.6e4e2a000124/email.h
@@ -0,0 +1,32 @@
@@ -0,0 +1,34 @@
+#ifndef _MCELOG_EMAIL_H_
+#define _MCELOG_EMAIL_H_
+
@ -229,6 +259,7 @@
+extern void setup_mail_header(FILE *email_fd, struct mce *m);
+extern void email_usage(void);
+extern int email_cmd(int opt, int ac, char **av);
+extern int email_env(void);
+
+#define EMAIL_OPTIONS \
+ { "email", 1, NULL, O_EMAIL_ADDRESS }, \
@ -246,11 +277,14 @@
+*/
+static void email_usage(void) { return; }
+static int email_cmd(int opt, int ac, char **av) { return 0; }
+static int email_env(void) { return 0; }
+#define EMAIL_OPTIONS
+#endif
+
+#endif
--- mcelog-1.0pre3.6e4e2a000124/mcelog.c
Index: mcelog-1.0pre3.6e4e2a000124/mcelog.c
===================================================================
--- mcelog-1.0pre3.6e4e2a000124.orig/mcelog.c
+++ mcelog-1.0pre3.6e4e2a000124/mcelog.c
@@ -37,6 +37,7 @@
#include <assert.h>
@ -270,7 +304,7 @@
enum cputype cputype = CPU_GENERIC;
char *logfn = LOG_DEV_FILENAME;
@@ -70,7 +74,7 @@
@@ -70,7 +74,7 @@ static double cpumhz;
static int cpumhz_forced;
int ascii_mode;
int dump_raw_ascii;
@ -279,7 +313,7 @@
static char *inputfile;
char *processor_flags;
static int foreground;
@@ -914,6 +918,7 @@
@@ -914,6 +918,7 @@ void usage(void)
"--num-errors N Only process N errors (for testing)\n"
"--pidfile file Write pid of daemon into file\n"
);
@ -287,7 +321,7 @@
diskdb_usage();
print_cputypes();
exit(1);
@@ -979,6 +984,7 @@
@@ -979,6 +984,7 @@ static struct option options[] = {
{ "pidfile", 1, NULL, O_PIDFILE },
{ "debug-numerrors", 0, NULL, O_DEBUG_NUMERRORS }, /* undocumented: for testing */
DISKDB_OPTIONS
@ -295,7 +329,7 @@
{}
};
@@ -1153,11 +1159,86 @@
@@ -1153,11 +1159,86 @@ static void drop_cred(void)
}
}
@ -378,11 +412,11 @@
int i;
int len;
int finish = 0;
+ int mail_setup;
+ int mail_setup = 0;
if (recordlen == 0) {
Wprintf("no data in mce record\n");
@@ -1177,12 +1258,16 @@
@@ -1177,12 +1258,16 @@ static void process(int fd, unsigned rec
finish = 1;
if (!mce_filter(mce, recordlen))
continue;
@ -399,7 +433,7 @@
flushlog();
}
@@ -1293,6 +1378,8 @@
@@ -1293,6 +1378,8 @@ int main(int ac, char **av)
exit(0);
} else if (diskdb_cmd(opt, ac, av)) {
exit(0);
@ -408,18 +442,22 @@
} else if (opt == 0)
break;
}
@@ -1301,6 +1388,8 @@
@@ -1301,6 +1388,10 @@ int main(int ac, char **av)
logfn = av[optind++];
if (av[optind])
usage();
+ if (email_mode == 0)
+ email_mode = email_env();
+ /* email sending only in daemon mode */
+ email_mode &= daemon_mode;
checkdmi();
general_setup();
--- mcelog-1.0pre3.6e4e2a000124/mcelog.h
Index: mcelog-1.0pre3.6e4e2a000124/mcelog.h
===================================================================
--- mcelog-1.0pre3.6e4e2a000124.orig/mcelog.h
+++ mcelog-1.0pre3.6e4e2a000124/mcelog.h
@@ -120,6 +120,7 @@
@@ -120,6 +120,7 @@ enum cputype {
enum option_ranges {
O_COMMON = 500,
O_DISKDB = 1000,
@ -427,7 +465,9 @@
};
enum syslog_opt {
--- mcelog-1.0pre3.6e4e2a000124/msg.c
Index: mcelog-1.0pre3.6e4e2a000124/msg.c
===================================================================
--- mcelog-1.0pre3.6e4e2a000124.orig/msg.c
+++ mcelog-1.0pre3.6e4e2a000124/msg.c
@@ -8,10 +8,13 @@
#include "mcelog.h"
@ -443,7 +483,7 @@
static char *output_fn;
int need_stdout(void)
@@ -135,6 +138,11 @@
@@ -135,6 +138,11 @@ int Wprintf(char *fmt, ...)
n = vfprintf(output_fh ? output_fh : stdout, fmt, ap);
va_end(ap);
}

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Aug 16 14:41:55 UTC 2012 - trenn@suse.de
- bnc#774226 mcelog + systemd: won't start without MCELOG_ADMIN_EMAIL set
- fix uninitialized variable mail_setup
-------------------------------------------------------------------
Wed Jul 18 12:49:43 UTC 2012 - trenn@suse.de

View File

@ -16,6 +16,7 @@
#
Name: mcelog
Summary: Log Machine Check Events
License: GPL-2.0+

View File

@ -7,7 +7,7 @@ ConditionPathExists=/dev/mcelog
[Service]
EnvironmentFile=-/etc/sysconfig/mcelog
#warning: if this fails is due to a known kernel bug, fix that instead !
ExecStart=/usr/sbin/mcelog --ignorenodev --daemon --foreground --email $MCELOG_ADMIN_EMAIL
ExecStart=/usr/sbin/mcelog --ignorenodev --daemon --foreground
StandardOutput=syslog
[Install]