715fde4
From aebb8189069f24e6f4e59cf79f179bcbafe7a098 Mon Sep 17 00:00:00 2001
715fde4
From: Jan Kara <jack@suse.cz>
715fde4
Date: Tue, 6 Nov 2012 11:04:44 +0100
715fde4
Subject: [PATCH 1/2] warnquota: Add MIME-Version header
715fde4
715fde4
Warnquota forgot to add MIME-Version header to sent email when Content-type
715fde4
etc. fields were set.
715fde4
715fde4
Signed-off-by: Jan Kara <jack@suse.cz>
715fde4
---
715fde4
 warnquota.c | 1 +
715fde4
 1 file changed, 1 insertion(+)
715fde4
715fde4
diff --git a/warnquota.c b/warnquota.c
715fde4
index 08827f2..80f528c 100644
715fde4
--- a/warnquota.c
715fde4
+++ b/warnquota.c
715fde4
@@ -503,6 +503,7 @@ static int mail_user(struct offenderlist *offender, struct configparams *config)
715fde4
 	if (should_cc(offender, config))
715fde4
 		fprintf(fp, "Cc: %s\n", config->cc_to);
715fde4
 	if ((config->charset)[0] != '\0') { /* are we supposed to set the encoding */
715fde4
+		fprintf(fp, "MIME-Version: 1.0\n");
715fde4
 		fprintf(fp, "Content-Type: text/plain; charset=%s\n", config->charset);
715fde4
 		fprintf(fp, "Content-Disposition: inline\n");
715fde4
 		fprintf(fp, "Content-Transfer-Encoding: 8bit\n");
715fde4
-- 
715fde4
1.7.11.7
715fde4
715fde4
From d8bb9ec3cef26cd3fb62534d896bf9c8feea67f9 Mon Sep 17 00:00:00 2001
715fde4
From: Jan Kara <jack@suse.cz>
715fde4
Date: Tue, 6 Nov 2012 12:12:19 +0100
715fde4
Subject: [PATCH 2/2] warnquota: Use current locale as default charset
715fde4
715fde4
If charset in warnquota.conf is not specified, use charset from current
715fde4
locale as the charset of the warning email. This is to accomodate possible
715fde4
translations of messages via gettext.
715fde4
715fde4
Signed-off-by: Jan Kara <jack@suse.cz>
715fde4
---
715fde4
 warnquota.c | 9 +++++++++
715fde4
 1 file changed, 9 insertions(+)
715fde4
715fde4
diff --git a/warnquota.c b/warnquota.c
715fde4
index 80f528c..5c5a1b9 100644
715fde4
--- a/warnquota.c
715fde4
+++ b/warnquota.c
715fde4
@@ -29,6 +29,8 @@
715fde4
 #include <grp.h>
715fde4
 #include <time.h>
715fde4
 #include <getopt.h>
715fde4
+#include <locale.h>
715fde4
+#include <langinfo.h>
715fde4
 #include <sys/types.h>
715fde4
 #include <sys/wait.h>
715fde4
 #include <sys/utsname.h>
715fde4
@@ -707,6 +709,7 @@ static int readconfigfile(const char *filename, struct configparams *config)
715fde4
 	char *value;
715fde4
 	char *pos;
715fde4
 	int line, len, bufpos;
715fde4
+	char *locale;
715fde4
 
715fde4
 	/* set default values */
715fde4
 	sstrncpy(config->mail_cmd, MAIL_CMD, CNF_BUFFER);
715fde4
@@ -716,6 +719,12 @@ static int readconfigfile(const char *filename, struct configparams *config)
715fde4
 	sstrncpy(config->support, SUPPORT, CNF_BUFFER);
715fde4
 	sstrncpy(config->phone, PHONE, CNF_BUFFER);
715fde4
 	(config->charset)[0] = '\0';
715fde4
+	setlocale(LC_ALL, NULL);
715fde4
+	locale = setlocale(LC_MESSAGES, NULL);
715fde4
+	if (locale && strcasecmp(locale, "posix") && strcasecmp(locale, "c")) {
715fde4
+		locale = nl_langinfo(CODESET);
715fde4
+		sstrncpy(config->charset, locale, CNF_BUFFER);
715fde4
+	}
715fde4
 	maildev[0] = 0;
715fde4
 	config->user_signature = config->user_message = config->group_signature = config->group_message = NULL;
715fde4
 	config->use_ldap_mail = 0;
715fde4
-- 
715fde4
1.7.11.7
715fde4