[PATCH] Add name_status_lmhosts
Volker Lendecke
vl at samba.org
Tue Jan 3 09:26:53 UTC 2017
On Fri, Dec 23, 2016 at 12:08:21AM +0100, Volker Lendecke wrote:
> This is a pretty desparate hack to make winbind work in a special
> environment. I'm happy if this is too special, but it did help me big
> time.
Ping? Anyone +1 or -1?
Thanks,
Volker
> From b3b3cf12f846fcd0c539a6eed22e939ccfacb6a5 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Mon, 19 Dec 2016 20:18:41 +0100
> Subject: [PATCH] libsmb: Add name_status_lmhosts
>
> Don't ask... Oh, you did? :-)
>
> Try to figure out a hosts' name from lmhosts. This is for a setup I've
> come across where for several reasons kerberos and ldap were unusable
> (very organically grown but unchangeable Solaris 10 installation with
> tons of ancient libs that ./configure incorrectly finds and where tar xf
> samba-4.5.3.tar takes 5 minutes...), so I had to fall back to compile
> with --without-ads. Unfortunately in that environment NetBIOS was also
> turned off, but the "winbind rpc only" code relies on name_status to
> get a DC's name from its IP address for the netlogon calls. This walks
> the local lmhosts file to scan for the same information.
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> source3/libsmb/namequery.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 43 insertions(+)
>
> diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
> index 945fc64..e39d761 100644
> --- a/source3/libsmb/namequery.c
> +++ b/source3/libsmb/namequery.c
> @@ -916,6 +916,42 @@ NTSTATUS node_status_query(TALLOC_CTX *mem_ctx, struct nmb_name *name,
> return status;
> }
>
> +static bool name_status_lmhosts(const struct sockaddr_storage *paddr,
> + int qname_type, fstring pname)
> +{
> + FILE *f;
> + char *name;
> + int name_type;
> + struct sockaddr_storage addr;
> +
> + if (paddr->ss_family != AF_INET) {
> + return false;
> + }
> +
> + f = startlmhosts(get_dyn_LMHOSTSFILE());
> + if (f == NULL) {
> + return false;
> + }
> +
> + while (getlmhostsent(talloc_tos(), f, &name, &name_type, &addr)) {
> + if (addr.ss_family != AF_INET) {
> + continue;
> + }
> + if (name_type != qname_type) {
> + continue;
> + }
> + if (memcmp(&((const struct sockaddr_in *)paddr)->sin_addr,
> + &((const struct sockaddr_in *)&addr)->sin_addr,
> + sizeof(struct in_addr)) == 0) {
> + fstrcpy(pname, name);
> + endlmhosts(f);
> + return true;
> + }
> + }
> + endlmhosts(f);
> + return false;
> +}
> +
> /****************************************************************************
> Find the first type XX name in a node status reply - used for finding
> a servers name given its IP. Return the matched name in *name.
> @@ -957,6 +993,13 @@ bool name_status_find(const char *q_name,
> return false;
> }
>
> + result = name_status_lmhosts(to_ss, type, name);
> + if (result) {
> + DBG_DEBUG("Found name %s in lmhosts\n", name);
> + namecache_status_store(q_name, q_type, type, to_ss, name);
> + return true;
> + }
> +
> set_socket_addr_v4(&ss);
>
> /* W2K PDC's seem not to respond to '*'#0. JRA */
> --
> 2.1.4
>
More information about the samba-technical
mailing list