[Samba] Can't join domain (LDAP error)

Timur I. Bakeyev timur at com.bat.ru
Mon May 3 01:54:10 UTC 2021


Hi from the future!

On Mon, 9 Nov 2020 at 08:13, O'Connor, Daniel via samba <
samba at lists.samba.org> wrote:

>
> > On 9 Nov 2020, at 14:51, Andrew Bartlett <abartlet at samba.org> wrote:
> > On Mon, 2020-11-09 at 14:43 +1030, O'Connor, Daniel wrote:
> >>
> >> Good idea.
> >> First step is building Samba from source which is not a fun
> >> experience on FreeBSD :(
> >
> > We do honestly want to make this easier.  Now of course that doesn't
> > help for a historical bisect, but we are open to and encourage up-
> > streaming of patches from ports.  (We also ask that patches we reject -
> > this has happened - be removed from the port, but can't force that).
>
> I managed to get the build done with the patches from the FreeBSD port
> (plus a few mods where they did not apply).
>
> However the problem is when I go to bisect all those patches need to be
> manually re-applied (eg stash push/pop) and then hand fixed which is quite
> tedious..
>
> I did a bit more digging and 4.12.7 works, 4.13.0 is broken (and HEAD).
>

The (quite rude, TBH)
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252385 suggests, that the
problem, possibly,
was introduced by introduced by this Volker's commit:
https://gitlab.com/samba-team/devel/samba/-/commit/011a2a82953fa910e1e7dee9862fbb5deaae8651
where sscanf() is invoked with unsupported by FreeBSD `%m` modifier. That,
obviously, would kill all the URL parsing.

I've made a hotfix(just repeated another hotfix from 2018), but possibly
this part can be just rewritten to use strchr/strtok/strcmp or other
old-fashioned functions.

Here is the hotfix, if any:

--- source4/libcli/ldap/ldap_client.c.orig      2020-07-09 13:33:56
+++ source4/libcli/ldap/ldap_client.c
@@ -402,8 +402,20 @@ static int ldap_parse_basic_url(
                *pport = port;
                return 0;
        }
+#ifdef FREEBSD
+       int s0, s1; s0 = s1 = 0;
+       ret = sscanf(url, "%n%*[^:/]%n:%d", &s0, &s1, &port);

+       if(ret >= 0) {
+               host = calloc(sizeof(char), s1 - s0 + 1);
+               if (host == NULL) {
+                       return ENOMEM;
+               }
+               ret = sscanf(url, "%[^:/]:%d", host, &port);
+       }
+#else
        ret = sscanf(url, "%m[^:/]:%d", &host, &port);
+#endif
        if (ret < 1) {
                return EINVAL;
        }

With best regards,
Timur


More information about the samba mailing list