Blame SOURCES/quota-4.01-define_charset_in_mail.patch

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