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