[Samba] Can't join domain (LDAP error)
Daniel O'Connor
darius at dons.net.au
Mon May 3 08:05:14 UTC 2021
> On 3 May 2021, at 11:24, Timur I. Bakeyev <timur at com.bat.ru> wrote:
> Hi from the future!
Hey :)
> 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;
> }
Shouldn't the #ifdef be based on "if not Linux"?, eg..
--- 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;
}
+#ifndef LINUX
+ 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;
}
Or perhaps "#if _XOPEN_SOURCE < 700" although I don't know much about feature macros.
I will try and build it but I am still having trouble building Samba from source :(
--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
More information about the samba
mailing list