Initialize all members of a configparams structure in warnquota

This commit is contained in:
Petr Písař 2019-11-05 14:52:14 +01:00
parent 0c47f5f1ee
commit 5865da5790
3 changed files with 74 additions and 7 deletions

View File

@ -1,4 +1,4 @@
From 769f46743d11a4723ef59b018cef0aa6b6c062a6 Mon Sep 17 00:00:00 2001
From 662e9e93babc9be39bb2d6267ffe428703ca137e Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Thu, 12 Sep 2019 10:18:01 +0200
Subject: [PATCH] warnquota: Clarify that CC_TO gets resolved through LDAP
@ -10,22 +10,23 @@ Clarify that CC_TO field from warnquota.conf gets resolved through LDAP
lookup similarly to normal message recifient.
Signed-off-by: Jan Kara <jack@suse.cz>
Petr Písař: Ported to Fedora 32.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
warnquota.conf | 2 ++
1 file changed, 2 insertions(+)
diff --git a/warnquota.conf b/warnquota.conf
index 60b0672..5bbd0ab 100644
index 7e00947..34bfe53 100644
--- a/warnquota.conf
+++ b/warnquota.conf
@@ -25,6 +25,8 @@ MAIL_CMD = "/usr/lib/sendmail -t"
# Standard mail fields
FROM = "root@localhost"
SUBJECT = "Your account quota has exceeded!"
@@ -8,6 +8,8 @@ MAIL_CMD = "/usr/sbin/sendmail -t"
FROM = "root@example.com"
# but they don't have to be:
SUBJECT = NOTE: You are exceeding your allocated disk space limits
+# Note that if LDAP is configured, the name in CC_TO gets looked up in LDAP
+# to obtain email address similarly to email recipient address.
CC_TO = "root@localhost"
CC_TO = "root@example.com"
# If you set this variable CC will be used only when user has less than
# specified grace time left (examples of possible times: 5 seconds, 1 minute,
--

View File

@ -0,0 +1,61 @@
From 50c3f30d610ed9979a1291422e8641e05f881212 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 5 Nov 2019 14:20:46 +0100
Subject: [PATCH] warnquota: Initialize all members of a configparams structure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Running warnquota under valgrind reported many "Conditional jump or
move depends on uninitialised value" mistakes because readconfigfile()
did not initizalize ldap_bindpw member if some of the configuration
options were missing from the configuration file.
This patch simply initializes all bytes of the configparams structure
to 0 instead of settting each of the members explicitly.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
warnquota.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/warnquota.c b/warnquota.c
index f6b42d5..2882fee 100644
--- a/warnquota.c
+++ b/warnquota.c
@@ -759,13 +759,13 @@ static int readconfigfile(const char *filename, struct configparams *config)
char *locale;
/* set default values */
+ memset(config, 0, sizeof(*config));
sstrncpy(config->mail_cmd, MAIL_CMD, CNF_BUFFER);
sstrncpy(config->from, FROM, CNF_BUFFER);
sstrncpy(config->subject, SUBJECT, CNF_BUFFER);
sstrncpy(config->cc_to, CC_TO, CNF_BUFFER);
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);
#ifdef HAVE_NL_LANGINFO
@@ -775,17 +775,11 @@ static int readconfigfile(const char *filename, struct configparams *config)
}
#endif
maildev[0] = 0;
- config->user_signature = config->user_message = config->group_signature = config->group_message = NULL;
config->cc_before = -1;
#ifdef USE_LDAP_MAIL_LOOKUP
- config->use_ldap_mail = 0;
- config->ldap_starttls = 0;
config->ldap_tls = LDAP_OPT_X_TLS_NEVER;
config->ldap_vers = LDAP_VERSION3;
- config->ldap_port = config->ldap_is_setup = 0;
- config->ldap_host[0] = 0;
- config->ldap_uri[0] = 0;
#endif
if (!(fp = fopen(filename, "r"))) {
--
2.21.0

View File

@ -96,6 +96,9 @@ Patch15: quota-4.05-warnquota-Free-LDAP-error-message.patch
# Document CC_TO in warquota.conf is looked up with LDAP,
# in upstream after 4.05
Patch16: quota-4.05-warnquota-Clarify-that-CC_TO-gets-resolved-through-L.patch
# Initialize all members of a configparams structure in warnquota,
# proposed to upstream, <https://sourceforge.net/p/linuxquota/patches/51/>
Patch17: quota-4.05-warnquota-Initialize-all-members-of-a-configparams-s.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bash
@ -232,6 +235,7 @@ Linux/UNIX environment.
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
# Regenerate build scripts
autoreconf -f -i
@ -387,6 +391,7 @@ make check
- Fix checking for the LDAP failures in the warnquota tool
- Report detailed LDAP failures
- Document CC_TO in warquota.conf is looked up with LDAP
- Initialize all members of a configparams structure in warnquota
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1:4.05-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild