diff options
author | Volker Lendecke <vlendec@samba.org> | 2004-03-07 08:16:10 +0000 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2004-03-07 08:16:10 +0000 |
commit | 6659353bd9d374271b7639eb148e32a8b2905bc9 (patch) | |
tree | 1d439d891bfb7f6cf8d2b9e9059ee86b397951f3 /source3 | |
parent | 83d4d424628389f40d637229f0627f500d892355 (diff) | |
download | samba-6659353bd9d374271b7639eb148e32a8b2905bc9.tar.gz samba-6659353bd9d374271b7639eb148e32a8b2905bc9.tar.bz2 samba-6659353bd9d374271b7639eb148e32a8b2905bc9.zip |
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)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/nsswitch/wbinfo.c | 2 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_acct.c | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 4f6cc4225a..772332ee59 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 34c7238b84..e6496695cb 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)) && i<num_gr_members ) { @@ -661,9 +661,11 @@ static BOOL wb_delgrpmember( WINBINDD_GR *grp, const char *user ) if ( !grp || !user ) return False; - for ( i=0; i<grp->num_gr_mem && !found; i++ ) { - if ( StrCaseCmp( grp->gr_mem[i], user ) == 0 ) + for ( i=0; i<grp->num_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; } |