Fix pam_winbind build against newer iniparser library.
[samba.git] / nsswitch / pam_winbind.c
index 3e13517f771af74c55d36a208d9d772685fd01fd..a344186f067c1617e635ef0e8ddd859682294100 100644 (file)
@@ -437,13 +437,13 @@ static int _pam_parse(const pam_handle_t *pamh,
                ctrl |= WINBIND_SILENT;
        }
 
-       if (iniparser_getstr(d, CONST_DISCARD(char *, "global:krb5_ccache_type")) != NULL) {
+       if (iniparser_getstring(d, CONST_DISCARD(char *, "global:krb5_ccache_type")) != NULL) {
                ctrl |= WINBIND_KRB5_CCACHE_TYPE;
        }
 
-       if ((iniparser_getstr(d, CONST_DISCARD(char *, "global:require-membership-of"))
+       if ((iniparser_getstring(d, CONST_DISCARD(char *, "global:require-membership-of"))
             != NULL) ||
-           (iniparser_getstr(d, CONST_DISCARD(char *, "global:require_membership_of"))
+           (iniparser_getstring(d, CONST_DISCARD(char *, "global:require_membership_of"))
             != NULL)) {
                ctrl |= WINBIND_REQUIRED_MEMBERSHIP;
        }
@@ -1137,6 +1137,7 @@ static bool winbind_name_list_to_sid_string_list(struct pwb_context *ctx,
        char *current_name = NULL;
        const char *search_location;
        const char *comma;
+       int len;
 
        if (sid_list_buffer_size > 0) {
                sid_list_buffer[0] = 0;
@@ -1192,6 +1193,17 @@ static bool winbind_name_list_to_sid_string_list(struct pwb_context *ctx,
                _make_remark_format(ctx, PAM_TEXT_INFO, _("Cannot convert group %s "
                                "to sid, please contact your administrator to see "
                                "if group %s is valid."), search_location, search_location);
+               /*
+                * The lookup of the last name failed..
+                * It results in require_member_of_sid ends with ','
+                * It is malformated parameter here, overwrite the last ','.
+                */
+               len = strlen(sid_list_buffer);
+               if (len) {
+                       if (sid_list_buffer[len - 1] == ',') {
+                               sid_list_buffer[len - 1] = '\0';
+                       }
+               }
        }
 
        result = true;
@@ -2278,7 +2290,7 @@ static const char *get_conf_item_string(struct pwb_context *ctx,
                        goto out;
                }
 
-               parm_opt = iniparser_getstr(ctx->dict, key);
+               parm_opt = iniparser_getstring,(ctx->dict, key, NULL);
                TALLOC_FREE(key);
 
                _pam_log_debug(ctx, LOG_INFO, "CONFIG file: %s '%s'\n",