diff options
author | Martin Pool <mbp@samba.org> | 2002-02-15 21:55:42 +0000 |
---|---|---|
committer | Martin Pool <mbp@samba.org> | 2002-02-15 21:55:42 +0000 |
commit | d8a66f20e0fd2335afcdf5ee3848be757738c7b7 (patch) | |
tree | 5ac68478a7f3ede60c86b0a68bd62ce6af32e431 | |
parent | b06d5e6f341e7a9f3dc95155ad2b8d7109b21559 (diff) | |
download | samba-d8a66f20e0fd2335afcdf5ee3848be757738c7b7.tar.gz samba-d8a66f20e0fd2335afcdf5ee3848be757738c7b7.tar.xz samba-d8a66f20e0fd2335afcdf5ee3848be757738c7b7.zip |
Merge revision 1.48.2.15
> parse_resolvconf should return the number of nameservers found, and
> resolve_hosts should examine this value to make sure we don't print
> out garbage if we fail to parse /etc/resolv.conf.
>
> (HP CR #311)
-rw-r--r-- | source/include/proto.h | 1 | ||||
-rw-r--r-- | source/libsmb/namequery.c | 27 |
2 files changed, 19 insertions, 9 deletions
diff --git a/source/include/proto.h b/source/include/proto.h index f94fde3545f..20ac0cc1e2f 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -911,7 +911,6 @@ BOOL name_status_find(const char *q_name, int q_type, int type, struct in_addr *name_query(int fd,const char *name,int name_type, BOOL bcast,BOOL recurse, struct in_addr to_ip, int *count); -BOOL parse_resolvconf(char name_server_arr[][16]); FILE *startlmhosts(char *fname); BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr); void endlmhosts(FILE *fp); diff --git a/source/libsmb/namequery.c b/source/libsmb/namequery.c index 781f1bad28d..2f50493e025 100644 --- a/source/libsmb/namequery.c +++ b/source/libsmb/namequery.c @@ -514,13 +514,15 @@ struct in_addr *name_query(int fd,const char *name,int name_type, } /******************************************************** -This routine parses /etc/resolv.conf and finds the -first three nameservers specified in the file. -This routine is used by the Admin Log -messages when a DNS lookup fails. + This routine parses /etc/resolv.conf and finds the + first three nameservers specified in the file. + This routine is used by the Admin Log + messages when a DNS lookup fails. + + Returns the number of nameservers found. *********************************************************/ -BOOL parse_resolvconf(char name_server_arr[][16]) +static int parse_resolvconf(char name_server_arr[][16]) { char *fname = NAME_SERVER_FILE; FILE *fp = sys_fopen(fname,"r"); @@ -530,7 +532,7 @@ BOOL parse_resolvconf(char name_server_arr[][16]) if (!fp) { DEBUG(4,("parse_resolvconf: Can't open resolv.conf file %s. Error was %s\n", fname, strerror(errno))); - return FALSE; + return 0; } while(!feof(fp) && !ferror(fp)) { @@ -582,6 +584,8 @@ BOOL parse_resolvconf(char name_server_arr[][16]) } } } + + return i; } /******************************************************** @@ -866,8 +870,15 @@ static BOOL resolve_hosts(const char *name, return True; } /* BEGIN_ADMIN_LOG */ - parse_resolvconf(name_server_arr); - sys_adminlog(LOG_CRIT,(char *)gettext("Failed DNS name resolution. Unresolved name: %s. DNS server address: %s."),name,name_server_arr[0]); + { + BOOL parse_ok; + + parse_ok = parse_resolvconf(name_server_arr); + sys_adminlog(LOG_CRIT, + (char *)gettext("Failed DNS name resolution. Unresolved name: %s. DNS server address: %s."), + name, + parse_ok ? name_server_arr[0] : "UNKNOWN"); + } /* END_ADMIN_LOG */ return False; } |