diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-05-03 17:58:20 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-05-03 17:58:20 +0000 |
commit | 21013a86e57aa529031480e356a3ffc47f1472c3 (patch) | |
tree | 44f82998ccfb60d11807d973139e2f1c90d9ec6c | |
parent | 8c5d10c8517a7e709445041d94b7058fab751a81 (diff) |
Fix behavior when a host is unresolvable. Mark it as type GT_IGNORE
so we don't get an error that inadvertainly causes the entry
to get exported to the world. Also keep a count of unresolved hosts
and error out sanely on lines w/ no resolvable hosts. Work by
myself and provos@
-rw-r--r-- | sbin/mountd/mountd.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c index a3699884fcd..244cddad5c3 100644 --- a/sbin/mountd/mountd.c +++ b/sbin/mountd/mountd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mountd.c,v 1.30 2000/05/01 20:20:12 millert Exp $ */ +/* $OpenBSD: mountd.c,v 1.31 2000/05/03 17:58:19 millert Exp $ */ /* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */ /* @@ -667,7 +667,7 @@ get_exportlist() struct ucred anon; char *cp, *endcp, *dirp = NULL, *hst, *usr, *dom, savedc; int len, has_host, exflags, got_nondir, dirplen = 0, num, i, netgrp; - int lookup_failed; + int lookup_failed, num_hosts; /* * First, get rid of the old list @@ -742,6 +742,7 @@ get_exportlist() * Set defaults. */ has_host = FALSE; + num_hosts = 0; lookup_failed = FALSE; anon = def_anon; exflags = MNT_EXPORTED; @@ -852,11 +853,13 @@ get_exportlist() "NULL hostname in netgroup %s, skipping", cp); grp->gr_type = GT_IGNORE; + lookup_failed = TRUE; + continue; } else if (get_host(hst, grp, tgrp)) { syslog(LOG_ERR, "Unknown host (%s) in netgroup %s", hst, cp); - has_host = FALSE; + grp->gr_type = GT_IGNORE; lookup_failed = TRUE; continue; } @@ -864,11 +867,12 @@ get_exportlist() syslog(LOG_ERR, "Unknown host (%s) in line %s", cp, line); - has_host = FALSE; + grp->gr_type = GT_IGNORE; lookup_failed = TRUE; continue; } has_host = TRUE; + num_hosts++; } while (netgrp && getnetgrent((const char **)&hst, (const char **)&usr, (const char **)&dom)); endnetgrent(); @@ -882,8 +886,8 @@ get_exportlist() * If the exports list is empty due to unresolvable hostnames * we throw away the line. */ - if (lookup_failed == TRUE && has_host == FALSE && - tgrp->gr_type == GT_NULL) { + if (lookup_failed == TRUE && num_hosts == 0 && + tgrp->gr_type == GT_IGNORE) { getexp_err(ep, tgrp); goto nextline; } |