[quota/f18] Define charset in e-mails sent by warnquota

Petr Pisar ppisar at fedoraproject.org
Tue Feb 5 08:40:32 UTC 2013


commit 9df3fafd172d84cc906a68fe9b5e598436c28fa5
Author: Petr Písař <ppisar at redhat.com>
Date:   Mon Dec 3 13:49:06 2012 +0100

    Define charset in e-mails sent by warnquota

 quota-4.01-define_charset_in_mail.patch |   79 +++++++++++++++++++++++++++++++
 quota.spec                              |    4 ++
 2 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/quota-4.01-define_charset_in_mail.patch b/quota-4.01-define_charset_in_mail.patch
new file mode 100644
index 0000000..699f519
--- /dev/null
+++ b/quota-4.01-define_charset_in_mail.patch
@@ -0,0 +1,79 @@
+From aebb8189069f24e6f4e59cf79f179bcbafe7a098 Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack at suse.cz>
+Date: Tue, 6 Nov 2012 11:04:44 +0100
+Subject: [PATCH 1/2] warnquota: Add MIME-Version header
+
+Warnquota forgot to add MIME-Version header to sent email when Content-type
+etc. fields were set.
+
+Signed-off-by: Jan Kara <jack at suse.cz>
+---
+ warnquota.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/warnquota.c b/warnquota.c
+index 08827f2..80f528c 100644
+--- a/warnquota.c
++++ b/warnquota.c
+@@ -503,6 +503,7 @@ static int mail_user(struct offenderlist *offender, struct configparams *config)
+ 	if (should_cc(offender, config))
+ 		fprintf(fp, "Cc: %s\n", config->cc_to);
+ 	if ((config->charset)[0] != '\0') { /* are we supposed to set the encoding */
++		fprintf(fp, "MIME-Version: 1.0\n");
+ 		fprintf(fp, "Content-Type: text/plain; charset=%s\n", config->charset);
+ 		fprintf(fp, "Content-Disposition: inline\n");
+ 		fprintf(fp, "Content-Transfer-Encoding: 8bit\n");
+-- 
+1.7.11.7
+
+From d8bb9ec3cef26cd3fb62534d896bf9c8feea67f9 Mon Sep 17 00:00:00 2001
+From: Jan Kara <jack at suse.cz>
+Date: Tue, 6 Nov 2012 12:12:19 +0100
+Subject: [PATCH 2/2] warnquota: Use current locale as default charset
+
+If charset in warnquota.conf is not specified, use charset from current
+locale as the charset of the warning email. This is to accomodate possible
+translations of messages via gettext.
+
+Signed-off-by: Jan Kara <jack at suse.cz>
+---
+ warnquota.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/warnquota.c b/warnquota.c
+index 80f528c..5c5a1b9 100644
+--- a/warnquota.c
++++ b/warnquota.c
+@@ -29,6 +29,8 @@
+ #include <grp.h>
+ #include <time.h>
+ #include <getopt.h>
++#include <locale.h>
++#include <langinfo.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+ #include <sys/utsname.h>
+@@ -707,6 +709,7 @@ static int readconfigfile(const char *filename, struct configparams *config)
+ 	char *value;
+ 	char *pos;
+ 	int line, len, bufpos;
++	char *locale;
+ 
+ 	/* set default values */
+ 	sstrncpy(config->mail_cmd, MAIL_CMD, CNF_BUFFER);
+@@ -716,6 +719,12 @@ static int readconfigfile(const char *filename, struct configparams *config)
+ 	sstrncpy(config->support, SUPPORT, CNF_BUFFER);
+ 	sstrncpy(config->phone, PHONE, CNF_BUFFER);
+ 	(config->charset)[0] = '\0';
++	setlocale(LC_ALL, NULL);
++	locale = setlocale(LC_MESSAGES, NULL);
++	if (locale && strcasecmp(locale, "posix") && strcasecmp(locale, "c")) {
++		locale = nl_langinfo(CODESET);
++		sstrncpy(config->charset, locale, CNF_BUFFER);
++	}
+ 	maildev[0] = 0;
+ 	config->user_signature = config->user_message = config->group_signature = config->group_message = NULL;
+ 	config->use_ldap_mail = 0;
+-- 
+1.7.11.7
+
diff --git a/quota.spec b/quota.spec
index e6200af..b0335c6 100644
--- a/quota.spec
+++ b/quota.spec
@@ -40,6 +40,8 @@ Patch9: quota-4.00-repquota-Fix-reporting-for-XFS.patch
 Patch10: quota-4.01-quota-Fix-reporting-of-NFS-mountpoints.patch
 # Submitted to upstream, SF#3571486
 Patch11: quota-4.01-Make-group-warning-message-more-official.patch
+# In upstream after 4.01, SF#3571589
+Patch12: quota-4.01-define_charset_in_mail.patch
 
 
 %description
@@ -123,6 +125,7 @@ Linux/UNIX environment.
 %patch9 -p1 -b .repqouta_xfs
 %patch10 -p1 -b .nfs3_pathname
 %patch11 -p1 -b .group_warning
+%patch12 -p1 -b .charset_in_mail
 
 #fix typos/mistakes in localized documentation
 for pofile in $(find ./po/*.p*)
@@ -250,6 +253,7 @@ echo '  systemd-sysv-convert --apply quota_nld'
 %changelog
 * Tue Feb 05 2013 Petr Pisar <ppisar at redhat.com> - 1:4.00-7
 - Make group warning message more official
+- Define charset in e-mails sent by warnquota (SF#3571589)
 
 * Fri Sep 07 2012 Petr Pisar <ppisar at redhat.com> - 1:4.00-6
 - Fix reporting for NFSv3 mount points


More information about the scm-commits mailing list