From: Volker Lendecke Date: Sun, 7 Mar 2004 08:16:10 +0000 (+0000) Subject: This might not be used a lot and might not survive for long, but at least it X-Git-Tag: samba-4.0.0alpha6~801^2~11857 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=6659353bd9d374271b7639eb148e32a8b2905bc9 This might not be used a lot and might not survive for long, but at least it should work as expected :-) Fix wb_delgrpmember. Volker (This used to be commit 9fc0025d12d17b0c68956af481a836eebc32e675) --- diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 4f6cc4225a7..772332ee592 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -1179,7 +1179,7 @@ int main(int argc, char **argv) break; case 'O': if ( !wbinfo_remove_user_from_group(string_arg) ) { - d_printf("Could not remove user kfrom group\n"); + d_printf("Could not remove user from group\n"); goto done; } break; diff --git a/source3/nsswitch/winbindd_acct.c b/source3/nsswitch/winbindd_acct.c index 34c7238b846..e6496695cb6 100644 --- a/source3/nsswitch/winbindd_acct.c +++ b/source3/nsswitch/winbindd_acct.c @@ -219,7 +219,7 @@ static WINBINDD_GR* string2group( char *string ) if ( num_gr_members ) { fstring buffer; - gr_members = (char**)smb_xmalloc(sizeof(char*)*num_gr_members+1); + gr_members = (char**)smb_xmalloc(sizeof(char*)*(num_gr_members+1)); i = 0; while ( next_token(&str, buffer, ",", sizeof(buffer)) && inum_gr_mem && !found; i++ ) { - if ( StrCaseCmp( grp->gr_mem[i], user ) == 0 ) + for ( i=0; inum_gr_mem; i++ ) { + if ( StrCaseCmp( grp->gr_mem[i], user ) == 0 ) { found = True; + break; + } } if ( !found ) @@ -672,8 +674,10 @@ static BOOL wb_delgrpmember( WINBINDD_GR *grp, const char *user ) /* still some remaining members */ if ( grp->num_gr_mem > 1 ) { - memmove( grp->gr_mem[i], grp->gr_mem[i+1], sizeof(char*)*(grp->num_gr_mem-(i+1)) ); + SAFE_FREE(grp->gr_mem[i]); grp->num_gr_mem--; + grp->gr_mem[i] = grp->gr_mem[grp->num_gr_mem]; + grp->gr_mem[grp->num_gr_mem] = NULL; } else { /* last one */ free_winbindd_gr( grp ); @@ -1083,7 +1087,7 @@ enum winbindd_result winbindd_remove_user_from_group(struct winbindd_cli_state * group = state->request.data.acct_mgt.groupname; user = state->request.data.acct_mgt.username; - DEBUG(3, ("[%5lu]: remove_user_to_group: delete %s from %s\n", (unsigned long)state->pid, + DEBUG(3, ("[%5lu]: remove_user_from_group: delete %s from %s\n", (unsigned long)state->pid, user, group)); /* don't worry about checking the username since we're removing it anyways */ @@ -1091,7 +1095,7 @@ enum winbindd_result winbindd_remove_user_from_group(struct winbindd_cli_state * /* make sure it is a valid group */ if ( !(grp = wb_getgrnam( group )) ) { - DEBUG(4,("winbindd_remove_user_to_group: Cannot remove a user to a non-extistent group\n")); + DEBUG(4,("winbindd_remove_user_from_group: Cannot remove a user from a non-extistent group\n")); return WINBINDD_ERROR; }