diff options
author | Noel Power <noel.power@suse.com> | 2013-11-05 17:24:46 +0000 |
---|---|---|
committer | David Disseldorp <ddiss@samba.org> | 2013-11-20 16:12:13 +0100 |
commit | 01cae099e0aab96fc3d3f21cd19b8925180f0351 (patch) | |
tree | 21c37c01819b9e6a8577b65c95c8b1d6014cec65 /nsswitch/pam_winbind.c | |
parent | 3f77bf2ce318b51547c36f315b34a062ba7afccf (diff) | |
download | samba-01cae099e0aab96fc3d3f21cd19b8925180f0351.tar.gz |
handle later iniparser version assigning a zero length string value for 'key='
older iniparser versions ( like that used in upstream samba ) ignore 'key='
entries, the key is not entered into the dictionary at all. Later
versions of iniparse specifically handle the following special cases
* key=
* key=;
* key=#
by assigning a value of "" ( a zero length string ) to the key
in the dictionary.
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Wed Nov 20 16:12:13 CET 2013 on sn-devel-104
Diffstat (limited to 'nsswitch/pam_winbind.c')
-rw-r--r-- | nsswitch/pam_winbind.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c index 9f855564bcc..2e37662959c 100644 --- a/nsswitch/pam_winbind.c +++ b/nsswitch/pam_winbind.c @@ -330,6 +330,21 @@ static void _pam_log_state_datum(struct pwb_context *ctx, #define _PAM_LOG_STATE_ITEM_PASSWORD(ctx, item_type) \ _pam_log_state_datum(ctx, item_type, #item_type, \ _LOG_PASSWORD_AS_STRING) +/* + * wrapper to preserve old behaviour of iniparser which ignored + * key values that had no value assigned like + * key = + * for a key like above newer iniparser will return a zero-length + * string, previously iniparser would return NULL + */ +static char *iniparser_getstring_nonempty(dictionary *d, char *key, char *def) +{ + char *ret = iniparser_getstring(d, key, def); + if (ret && strlen(ret) == 0) { + ret = NULL; + } + return ret; +} static void _pam_log_state(struct pwb_context *ctx) { @@ -418,13 +433,13 @@ static int _pam_parse(const pam_handle_t *pamh, ctrl |= WINBIND_SILENT; } - if (iniparser_getstring(d, discard_const_p(char, "global:krb5_ccache_type"), NULL) != NULL) { + if (iniparser_getstring_nonempty(d, discard_const_p(char, "global:krb5_ccache_type"), NULL) != NULL) { ctrl |= WINBIND_KRB5_CCACHE_TYPE; } - if ((iniparser_getstring(d, discard_const_p(char, "global:require-membership-of"), NULL) + if ((iniparser_getstring_nonempty(d, discard_const_p(char, "global:require-membership-of"), NULL) != NULL) || - (iniparser_getstring(d, discard_const_p(char, "global:require_membership_of"), NULL) + (iniparser_getstring_nonempty(d, discard_const_p(char, "global:require_membership_of"), NULL) != NULL)) { ctrl |= WINBIND_REQUIRED_MEMBERSHIP; } @@ -2262,7 +2277,7 @@ static const char *get_conf_item_string(struct pwb_context *ctx, goto out; } - parm_opt = iniparser_getstring(ctx->dict, key, NULL); + parm_opt = iniparser_getstring_nonempty(ctx->dict, key, NULL); TALLOC_FREE(key); _pam_log_debug(ctx, LOG_INFO, "CONFIG file: %s '%s'\n", |