From df42b0a7bcdaae96035ecb1d434a66735358fd95 Mon Sep 17 00:00:00 2001 From: Samba Release Account Date: Sun, 23 Feb 1997 05:18:09 +0000 Subject: Makefile: Added cleandir target. chgpasswd.c: Added patch from Roland Haag to allow password changes to be done more than once. loadparm.c: Added entries for the "directory mode/directory mask parameters". Changed default file mode to 644. proto.h: Added sys_gethostbyname. server.c: Added directory mode changes. system.c: Added sys_gethostbyname. trans2.c: Added NT_FILE_ATTRIBUTE_NORMAL patch from Roger Orr trans2.h: Defined NT_FILE_ATTRIBUTE_NORMAL for above patch. util.c: Changes calls to gethostbyname to sys_gethostbyname. jra@cygnus.com (This used to be commit d8d8a7ee00971fca7a8d079bfb547af107df35a4) --- source3/lib/system.c | 42 ++++++++++++++++++++++++++++++++++++++++++ source3/lib/util.c | 6 +++--- 2 files changed, 45 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/system.c b/source3/lib/system.c index ac97449da2..86c4c28a59 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -146,7 +146,11 @@ The wait() calls vary between systems ********************************************************************/ int sys_waitpid(pid_t pid,int *status,int options) { +#ifdef USE_WAITPID return waitpid(pid,status,options); +#else /* USE_WAITPID */ + return wait4(pid, status, options, NULL); +#endif /* USE_WAITPID */ } /******************************************************************* @@ -235,3 +239,41 @@ int sys_chroot(char *dname) return(chroot(dname)); #endif } + +/************************************************************************** +A wrapper for gethostbyname() that tries avoids looking up hostnames +in the root domain, which can cause dial-on-demand links to come up for no +apparent reason. +****************************************************************************/ +struct hostent *sys_gethostbyname(char *name) +{ + char query[256], hostname[256]; + char *domain; + + /* Does this name have any dots in it? If so, make no change */ + + if (strchr(name, '.')) + return(gethostbyname(name)); + + /* Get my hostname, which should have domain name + attached. If not, just do the gethostname on the + original string. + */ + + gethostname(hostname, sizeof(hostname) - 1); + hostname[sizeof(hostname) - 1] = 0; + if ((domain = strchr(hostname, '.')) == NULL) + return(gethostbyname(name)); + + /* Attach domain name to query and do modified query. + If names too large, just do gethostname on the + original string. + */ + + if((strlen(name) + strlen(domain)) >= sizeof(query)) + return(gethostbyname(name)); + + sprintf(query, "%s%s", name, domain); + return(gethostbyname(query)); +} + diff --git a/source3/lib/util.c b/source3/lib/util.c index a43de46c51..643c2fb7a5 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -3238,7 +3238,7 @@ struct hostent *Get_Hostbyname(char *name) return(NULL); } - ret = gethostbyname(name2); + ret = sys_gethostbyname(name2); if (ret != NULL) { free(name2); @@ -3247,7 +3247,7 @@ struct hostent *Get_Hostbyname(char *name) /* try with all lowercase */ strlower(name2); - ret = gethostbyname(name2); + ret = sys_gethostbyname(name2); if (ret != NULL) { free(name2); @@ -3256,7 +3256,7 @@ struct hostent *Get_Hostbyname(char *name) /* try with all uppercase */ strupper(name2); - ret = gethostbyname(name2); + ret = sys_gethostbyname(name2); if (ret != NULL) { free(name2); -- cgit