cifs-utils: CLDAP-Ping to find the correct site
Subsystems (3)
v3 cover cifs-utils: CLDAP-Ping to find the correct site
Hi All,
changes form v2:
- rebased to next
- ldap response on older AD-Servers is not case-sensitive - parse ldap response instead of memmem hack
- off by one error in seperator extraction
- socketaddr is now consructed in cldap_ping.c and no longer in resolve_host.c
- IPv6 is - limited - tested. Just the cldap_ping path not the full integration, but this is the critical stuff anyway.
Feedback as always welcome :-)
Kind Regards
David
David Voit (1):
Implement CLDAP Ping to find the closest site
Makefile.am | 15 ++- cldap_ping.c | 344 +++++++++++++++++++++++++++++++++++++++++++++++++ cldap_ping.h | 9 ++ mount.cifs.c | 5 +- resolve_host.c | 259 ++++++++++++++++++++++++++++++++----- resolve_host.h | 6 +- 6 files changed, 600 insertions(+), 38 deletions(-) create mode 100644 cldap_ping.c create mode 100644 cldap_ping.h
Signature · 1 line
2.44.0
PATCH v3 1/1 Implement CLDAP Ping to find the closest site
For domain based DFS we always need to contact the domain controllers.
On setups, which are using bigger AD installations you could get random dc on the other side of the world, if you don't have site support. This can lead to network timeouts and other problems.
CLDAP-Ping uses ASN.1 + UDP (CLDAP) and custom-DCE encoding including DName compressions without field separation. Finally after finding the sitename we now need to do a DNS SRV lookups to find the correct IPs to our closest site and fill up the remaining IPs from the global list.
--- Makefile.am | 15 ++- cldap_ping.c | 344 +++++++++++++++++++++++++++++++++++++++++++++++++ cldap_ping.h | 9 ++ mount.cifs.c | 5 +- resolve_host.c | 259 ++++++++++++++++++++++++++++++++----- resolve_host.h | 6 +- 6 files changed, 600 insertions(+), 38 deletions(-) create mode 100644 cldap_ping.c create mode 100644 cldap_ping.h
Makefile.am +9 -6
@@ -3,8 +3,8 @@ ACLOCAL_AMFLAGS = -I aclocal root_exec_sbindir = $(ROOTSBINDIR) root_exec_sbin_PROGRAMS = mount.cifs -mount_cifs_SOURCES = mount.cifs.c mtab.c resolve_host.c util.c -mount_cifs_LDADD = $(LIBCAP) $(CAPNG_LDADD) $(RT_LDADD) +mount_cifs_SOURCES = mount.cifs.c mtab.c $(resolve_hosts_SOURCES) util.c +mount_cifs_LDADD = $(LIBCAP) $(CAPNG_LDADD) $(RT_LDADD) $(resolve_hosts_LDADD) include_HEADERS = cifsidmap.h rst_man_pages = mount.cifs.8
@@ -28,6 +28,9 @@ bin_PROGRAMS = bin_SCRIPTS = sbin_PROGRAMS = +resolve_hosts_SOURCES = data_blob.c asn1.c cldap_ping.c resolve_host.c +resolve_hosts_LDADD = -ltalloc -lresolv + if CONFIG_CIFSUPCALL sbin_PROGRAMS += cifs.upcall cifs_upcall_SOURCES = cifs.upcall.c data_blob.c asn1.c spnego.c
@@ -43,8 +46,8 @@ endif if CONFIG_CIFSCREDS bin_PROGRAMS += cifscreds -cifscreds_SOURCES = cifscreds.c cifskey.c resolve_host.c util.c -cifscreds_LDADD = -lkeyutils +cifscreds_SOURCES = cifscreds.c cifskey.c $(resolve_hosts_SOURCES) util.c +cifscreds_LDADD = -lkeyutils $(resolve_hosts_LDADD) rst_man_pages += cifscreds.1
@@ -105,8 +108,8 @@ endif if CONFIG_PAM pam_PROGRAMS = pam_cifscreds.so rst_man_pages += pam_cifscreds.8 -pam_cifscreds.so: pam_cifscreds.c cifskey.c resolve_host.c util.c - $(CC) $(DEFS) $(CFLAGS) $(AM_CFLAGS) $(LDFLAGS) -shared -fpic -o $@ $+ -lpam -lkeyutils +pam_cifscreds.so: pam_cifscreds.c cifskey.c $(resolve_hosts_SOURCES) util.c + $(CC) $(DEFS) $(CFLAGS) $(AM_CFLAGS) $(LDFLAGS) -shared -fpic -o $@ $+ -lpam -lkeyutils $(resolve_hosts_LDADD) endif
cldap_ping.c new file +344 -0
344 lines not on this page · raw message
cldap_ping.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef _CLDAP_PING_H_ +#define _CLDAP_PING_H_ + +// returns -1 of fatal errors, and -2 on network errors +// if we get one of those retry do the cldap ping again on a another dc +// site_name must be of MAXCDNAME size! +int cldap_ping (char *domain,sa_family_t family,void *addr,char *site_name); + +#endif /* _CLDAP_PING_H_ */
mount.cifs.c +4 -1
@@ -1889,8 +1889,11 @@ assemble_mountinfo(struct parsed_mount_info *parsed_info,if (rc) goto assemble_exit; -if (parsed_info->addrlist[0 ] =='\0' ) +if (parsed_info->addrlist[0 ] =='\0' ) { rc =resolve_host (parsed_info->host, parsed_info->addrlist); +if (rc ==0 && parsed_info->verboseflag) +fprintf (stderr,"Host \"%s\" resolved to the following IP addresses: %s\n" , parsed_info->host, parsed_info->addrlist); + }switch (rc) {case EX_USAGE :
resolve_host.c +230 -29
303 lines not on this page · raw message
resolve_host.h +4 -2
@@ -26,8 +26,10 @@/* currently maximum length of IPv6 address string */ #define MAX_ADDRESS_LEN INET6_ADDRSTRLEN -/* limit list of addresses to 16 max-size addrs */ -#define MAX_ADDR_LIST_LEN ((MAX_ADDRESS_LEN + 1) * 16) +#define MAX_ADDRESSES 16 + +/* limit list of addresses to MAX_ADDRESSES max-size addrs */ +#define MAX_ADDR_LIST_LEN ((MAX_ADDRESS_LEN + 1) * MAX_ADDRESSES)extern int resolve_host (const char *host,char *addrstr);
Signature · 1 line
2.44.0