testprogs: print SDDL string of printer security descriptors
[abartlet/samba.git/.git] / nsswitch / pam_winbind.c
index 2e6520c1ce076e21995775908c889b1ac29d270f..82c8c4d0e251a8da81678ff3f83bc0cb5405fc04 100644 (file)
@@ -807,8 +807,7 @@ static int wbc_auth_error_to_pam_error(struct pwb_context *ctx,
        return pam_winbind_request_log(ctx, ret, username, fn);
 }
 
-/* PAM_RADIO_TYPE is linux-only. */
-#ifdef LINUX
+#if defined(HAVE_PAM_RADIO_TYPE)
 static bool _pam_winbind_change_pwd(struct pwb_context *ctx)
 {
        struct pam_message msg, *pmsg;
@@ -846,7 +845,6 @@ static bool _pam_winbind_change_pwd(struct pwb_context *ctx)
 }
 #endif
 
-
 /**
  * send a password expiry message if required
  *
@@ -1139,13 +1137,14 @@ 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;
        }
 
        search_location = name_list;
-       while ((comma = strstr(search_location, ",")) != NULL) {
+       while ((comma = strchr(search_location, ',')) != NULL) {
                current_name = strndup(search_location,
                                       comma - search_location);
                if (NULL == current_name) {
@@ -1194,6 +1193,15 @@ 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 != 0) && (sid_list_buffer[len - 1] == ',')) {
+                       sid_list_buffer[len - 1] = '\0';
+               }
        }
 
        result = true;