1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

lib: Decouple is_myname() from init_names()

In a new binary I forgot "init_names()" in main and it crashed in
auth3. We should not have to call init_names() everywhere I guess.

The my_netbios_names() array is free of duplicates, but as we don't
expect more than a handful of netbios aliases this does not matter for
just checking existence of a name. And moreover, a properly configured
smb.conf doesn't have tons of dups in "netbios aliases" anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2021-02-03 10:15:00 +01:00 committed by Jeremy Allison
parent cf43f331be
commit 088386bbed

View File

@ -1107,21 +1107,38 @@ int map_process_lock_to_ofd_lock(int op)
Returns true if it is equal, false otherwise.
********************************************************************/
static bool nb_name_equal(const char *s1, const char *s2)
{
int cmp = strncasecmp_m(s1, s2, MAX_NETBIOSNAME_LEN-1);
return (cmp == 0);
}
bool is_myname(const char *s)
{
int n;
bool ret = False;
const char **aliases = NULL;
bool ok = false;
for (n=0; my_netbios_names(n); n++) {
const char *nbt_name = my_netbios_names(n);
if (strncasecmp_m(nbt_name, s, MAX_NETBIOSNAME_LEN-1) == 0) {
ret=True;
break;
}
ok = nb_name_equal(lp_netbios_name(), s);
if (ok) {
goto done;
}
DEBUG(8, ("is_myname(\"%s\") returns %d\n", s, ret));
return(ret);
aliases = lp_netbios_aliases();
if (aliases == NULL) {
goto done;
}
while (*aliases != NULL) {
ok = nb_name_equal(*aliases, s);
if (ok) {
goto done;
}
aliases += 1;
}
done:
DBG_DEBUG("is_myname(\"%s\") returns %d\n", s, (int)ok);
return ok;
}
/*******************************************************************