On Mon, Sep 01, 2014 at 04:31:30PM +0200, Jakub Hrozek wrote:
Hi,
attached is a simple patch that fixes a Coverity warning.
This is the pattern we use elsewhere as well and the patch applies well,
ACK.
bye,
Sumit
P.S. Maybe it is a good time to open a ticket to check the umask() usage
in the SSSD code, with a simple grep I can find the following variants:
umask(0000)
umask(0022)
umask(0077)
umask(0111)
umask(0133)
umask(0177)
umask(022)
umask(077)
From 557d59d0b8d5db9fc7f80ab037418625450efad3 Mon Sep 17 00:00:00
2001
From: Jakub Hrozek <jhrozek(a)redhat.com>
Date: Mon, 1 Sep 2014 13:27:33 +0200
Subject: [PATCH] LDAP: Set umask before calling mkstemp
Even though we only call mkstemp to generate a random filename, it's a
good practice to set and re-set umask before and after calling mkstemp.
Silences a warning from Coverity static analyzer.
---
src/providers/ldap/ldap_child.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/providers/ldap/ldap_child.c b/src/providers/ldap/ldap_child.c
index 6ef7bd204bb028b0dc1f0ccb8b6e52cdacf044f2..e5779b70906d90ab855677f04a154e179f2163c6
100644
--- a/src/providers/ldap/ldap_child.c
+++ b/src/providers/ldap/ldap_child.c
@@ -189,6 +189,7 @@ static krb5_error_code ldap_child_get_tgt_sync(TALLOC_CTX *memctx,
TALLOC_CTX *tmp_ctx;
char *ccname_file_dummy;
char *ccname_file;
+ mode_t old_umask;
krberr = krb5_init_context(&context);
if (krberr) {
@@ -303,7 +304,9 @@ static krb5_error_code ldap_child_get_tgt_sync(TALLOC_CTX *memctx,
goto done;
}
+ old_umask = umask(077);
fd = mkstemp(ccname_file_dummy);
+ umask(old_umask);
if (fd == -1) {
ret = errno;
goto done;
--
1.9.3
_______________________________________________
sssd-devel mailing list
sssd-devel(a)lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/sssd-devel