From: Justin Mitchell <jumitche@redhat.com>
To: Steve Dickson <steved@redhat.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH 7/7] libnfsidmap: use conf_get_bool()
Date: Wed, 30 Aug 2017 12:59:18 +0100 [thread overview]
Message-ID: <1504094358.10850.11.camel@redhat.com> (raw)
In-Reply-To: <1504093866.10850.1.camel@redhat.com>
We can improve code readability by using conf_get_bool() from
libnfsconf instead of comparing the string values ourselves
Signed-off-by: Justin Mitchell <jumitche@redhat.com>
---
libnfsidmap.c | 6 +-----
umich_ldap.c | 21 ++++++---------------
2 files changed, 7 insertions(+), 20 deletions(-)
diff --git a/libnfsidmap.c b/libnfsidmap.c
index afe84ef..bacb0e3 100644
--- a/libnfsidmap.c
+++ b/libnfsidmap.c
@@ -339,7 +339,6 @@ int nfs4_init_name_mapping(char *conffile)
struct conf_list *nfs4_methods, *gss_methods;
char *nobody_user, *nobody_group;
char *nostrip;
- char *reformatgroup;
char *conf_path;
/* XXX: need to be able to reload configurations... */
@@ -424,10 +423,7 @@ int nfs4_init_name_mapping(char *conffile)
no_strip = 0;
if (no_strip & IDTYPE_GROUP) {
- reformatgroup = conf_get_str_with_def("General", "Reformat-Group", "false");
- if ((strcasecmp(reformatgroup, "true") == 0) ||
- (strcasecmp(reformatgroup, "on") == 0) ||
- (strcasecmp(reformatgroup, "yes") == 0))
+ if (conf_get_bool("General", "Reformat-Group", false))
reformat_group = 1;
else
reformat_group = 0;
diff --git a/umich_ldap.c b/umich_ldap.c
index 6e01cc3..6ddce32 100644
--- a/umich_ldap.c
+++ b/umich_ldap.c
@@ -1095,9 +1095,9 @@ out_err:
static int
umichldap_init(void)
{
- char *tssl, *canonicalize, *memberof;
char missing_msg[128] = "";
char *server_in, *canon_name;
+ bool canonicalize = false;
server_in = conf_get_str(LDAP_SECTION, "LDAP_server");
ldap_info.base = conf_get_str(LDAP_SECTION, "LDAP_base");
@@ -1105,10 +1105,7 @@ umichldap_init(void)
ldap_info.group_tree = conf_get_str(LDAP_SECTION, "LDAP_group_base");
ldap_info.user_dn = conf_get_str(LDAP_SECTION, "LDAP_user_dn");
ldap_info.passwd = conf_get_str(LDAP_SECTION, "LDAP_passwd");
- tssl = conf_get_str_with_def(LDAP_SECTION, "LDAP_use_ssl", "false");
- if ((strcasecmp(tssl, "true") == 0) ||
- (strcasecmp(tssl, "on") == 0) ||
- (strcasecmp(tssl, "yes") == 0))
+ if (conf_get_bool(LDAP_SECTION, "LDAP_use_ssl", false))
ldap_info.use_ssl = 1;
else
ldap_info.use_ssl = 0;
@@ -1130,10 +1127,8 @@ umichldap_init(void)
}
ldap_info.server = server_in;
- canonicalize = conf_get_str_with_def(LDAP_SECTION, "LDAP_canonicalize_name", "yes");
- if ((strcasecmp(canonicalize, "true") == 0) ||
- (strcasecmp(canonicalize, "on") == 0) ||
- (strcasecmp(canonicalize, "yes") == 0)) {
+ if (conf_get_bool(LDAP_SECTION, "LDAP_canonicalize_name", true)) {
+ canonicalize = true;
canon_name = get_canonical_hostname(server_in);
if (canon_name == NULL)
IDMAP_LOG(0, ("umichldap_init: Warning! Unable to "
@@ -1202,11 +1197,7 @@ umichldap_init(void)
* will use the memberof lists of the account and search through
* only those groups to obtain gids.
*/
- memberof = conf_get_str_with_def(LDAP_SECTION,
- "LDAP_use_memberof_for_groups", "false");
- if ((strcasecmp(memberof, "true") == 0) ||
- (strcasecmp(memberof, "on") == 0) ||
- (strcasecmp(memberof, "yes") == 0))
+ if (conf_get_bool(LDAP_SECTION, "LDAP_use_memberof_for_groups", false))
ldap_info.memberof_for_groups = 1;
else
ldap_info.memberof_for_groups = 0;
@@ -1233,7 +1224,7 @@ umichldap_init(void)
/* print out some good debugging info */
IDMAP_LOG(1, ("umichldap_init: canonicalize_name: %s",
- canonicalize));
+ canonicalize ? "yes" : "no"));
IDMAP_LOG(1, ("umichldap_init: server : %s (from config value '%s')",
ldap_info.server, server_in));
IDMAP_LOG(1, ("umichldap_init: port : %d", ldap_info.port));
--
1.8.3.1
next prev parent reply other threads:[~2017-08-30 11:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 11:51 [PATCH 0/7] Move nfs.conf to a shared library Justin Mitchell
2017-08-30 11:53 ` [PATCH 1/7] nfs-utils: const-ify all the config handling functions Justin Mitchell
2017-08-30 11:54 ` [PATCH 2/7] nfs-utils: Merge conf_get_str and conf_get_section Justin Mitchell
2017-08-30 11:55 ` [PATCH 3/7] nfs-utils: Move nfs.conf handling into a shared lib Justin Mitchell
2017-08-30 11:56 ` [PATCH 4/7] nfs-utils: Add get_str with default value Justin Mitchell
2017-08-30 11:57 ` [PATCH 5/7] nfs-utils: Add pkgconf data for libnfsconf Justin Mitchell
2017-08-30 11:58 ` [PATCH 6/7] libnfsidmap: Use libnfsconf instead of builtin cfg Justin Mitchell
2017-08-30 11:59 ` Justin Mitchell [this message]
2017-08-30 12:15 ` [PATCH 0/7] Move nfs.conf to a shared library Christoph Hellwig
2017-08-30 14:20 ` Chuck Lever
2017-08-30 20:33 ` Steve Dickson
2017-09-01 13:28 ` Justin Mitchell
2017-09-05 21:34 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1504094358.10850.11.camel@redhat.com \
--to=jumitche@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.