[Samba] RPC: Problem Deleting LDAP-Entries in pdb_ldap.c
Andrew Bartlett
abartlet at samba.org
Wed Feb 25 05:43:10 GMT 2004
On Tue, 2004-02-24 at 22:30, Yohann Fourteau wrote:
> I'm sorry, I haven't seen the answer .
> I give some explaination here.
>
>
> Selon Andrew Bartlett <abartlet at samba.org>:
> > Can we have a few more comments than this? I know Samba doesn't do
> > comments well, but I need to understand what's going on here...
>
>
> Ok I will be my best in the future :)
>
>
>
> > Given the warning in the Linux strtok manpage, this worries me...
>
> It's the first time I code in C... But I know very well LDAP :)
> I've learnt C long time ago at school. I haven't seen the warning in the man
> page, I was looking for a "split" function easy to use.
See if LDAP provides you a function, otherwise, strchr() and strndup()
might be the best way forward.
> > > + DEBUG(5,("smbldap_modify: dn => [%s]\n", dn ));
> > > +
> > > + for (i = 0; attrs[i] != NULL; i++) {
> > > + if ( ( attrs[i]->mod_op == LDAP_MOD_DELETE )
> > > + && strequal(attrs[i]->mod_type,rdn_attribut) ) {
> > > + for (j=0;attrs[i]->mod_values[j] != NULL; j++) {
> > > + if (strequal(attrs[i]->mod_values[j],rdn_value))
>
> > We have to watch what character set this is in. We probably need a
> > strequal_utf8() (or if this must be the same case, a normal strcmp()
> > call... )
>
> Yes, normaly, the dn is in utf8.
Actually, always the dn is utf8 - so we can't use functions that operate
on 'unix strings', as they might not be utf8. Instead, we must
write/find a function that 'knows' both strings are UTF8. (This would
be worth having anyway).
> > I realise this is 'alright', but it scares me... We really should
> > always safe_strcat() with a constant length, into fixed-size buffers
> > only. Things like asprintf() would be better, even if we waste a
> > (small) amount of ram building the string.
>
> You've right to be scared. I know what I'v done, the idea is correct (I've
> tested it in another language) but I'm not a C expert.
> I was waiting for that kind of help.
> Memory management, strings manipulation, it's not so easy in C :) (than perl,
> php, etc).
> I learn.
Indeed. :-)
> > Apart from that, this patch looks good - you certainly seem to know what
> > you are doing. We just need have this patch cleaned up so that others
> > can also understand it :-) (And I'm sure somebody will call me on my
> > code at some point here...)
>
>
> Well, I write more comments and I repost the patch with some modification (I
> have to learn about talloc...).
Thanks! I'm really looking forward to finally supporting renames!
Andrew Bartlett
--
Andrew Bartlett abartlet at pcug.org.au
Manager, Authentication Subsystems, Samba Team abartlet at samba.org
Student Network Administrator, Hawker College abartlet at hawkerc.net
http://samba.org http://build.samba.org http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20040225/1703c28b/attachment.bin
More information about the samba-technical
mailing list