summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv/yp_dblookup.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-10-24 18:58:26 +0000
committerwpaul <wpaul@FreeBSD.org>1996-10-24 18:58:26 +0000
commit23c458cf11df43eaa7b95dba34d24f4c492c1556 (patch)
treec9e13718f5c1a63d264eb0f15a2cc75b914c103b /usr.sbin/ypserv/yp_dblookup.c
parent60458c7a5c579d18cfcea70a2ad227276cc23f75 (diff)
downloadFreeBSD-src-23c458cf11df43eaa7b95dba34d24f4c492c1556.zip
FreeBSD-src-23c458cf11df43eaa7b95dba34d24f4c492c1556.tar.gz
Add support for handling the YP_SECURE and YP_INTERDOMAIN keys from
any maps that may have them. If the YP_SECURE key is present, ypserv will only allow access to the map from clients on reserved ports. If the YP_INTERDOMAIN key is present, the server will do DNS lookups for hostnames that it can't find in hosts.byname or hosts.byaddr. This is the same as the -d flag (which is retained for backwards compatibility) but it can be set on a per-map/per-domain basis. Also modified /var/yp/Makefile to add YP_INTERDOMAIN to the hosts.* maps and YP_SECURE to master.passwd.* maps by default.
Diffstat (limited to 'usr.sbin/ypserv/yp_dblookup.c')
-rw-r--r--usr.sbin/ypserv/yp_dblookup.c66
1 files changed, 64 insertions, 2 deletions
diff --git a/usr.sbin/ypserv/yp_dblookup.c b/usr.sbin/ypserv/yp_dblookup.c
index ac19571..a55acb8 100644
--- a/usr.sbin/ypserv/yp_dblookup.c
+++ b/usr.sbin/ypserv/yp_dblookup.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yp_dblookup.c,v 1.4 1996/07/07 19:04:33 wpaul Exp $
+ * $Id: yp_dblookup.c,v 1.4 1996/07/07 19:04:33 wpaul Exp wpaul $
*
*/
#include <stdio.h>
@@ -47,7 +47,7 @@
#include "yp_extern.h"
#ifndef lint
-static const char rcsid[] = "$Id: yp_dblookup.c,v 1.4 1996/07/07 19:04:33 wpaul Exp $";
+static const char rcsid[] = "$Id: yp_dblookup.c,v 1.4 1996/07/07 19:04:33 wpaul Exp wpaul $";
#endif
int ypdb_debug = 0;
@@ -77,6 +77,7 @@ struct dbent {
char *name;
char *key;
int size;
+ int flags;
};
static CIRCLEQ_HEAD(circlehead, circleq_entry) qhead;
@@ -193,6 +194,65 @@ void yp_flush_all()
return;
}
+static char *inter_string = "YP_INTERDOMAIN";
+static char *secure_string = "YP_SECURE";
+static int inter_sz = sizeof("YP_INTERDOMAIN") - 1;
+static int secure_sz = sizeof("YP_SECURE") - 1;
+
+static int yp_setflags(dbp)
+ DB *dbp;
+{
+ DBT key = { NULL, 0 }, data = { NULL, 0 };
+ int flags = 0;
+
+ key.data = inter_string;
+ key.size = inter_sz;
+
+ if (!(dbp->get)(dbp, &key, &data, 0))
+ flags |= YP_INTERDOMAIN;
+
+ key.data = secure_string;
+ key.size = secure_sz;
+
+ if (!(dbp->get)(dbp, &key, &data, 0))
+ flags |= YP_SECURE;
+
+ return(flags);
+}
+
+int yp_testflag(map, domain, flag)
+ char *map;
+ char *domain;
+ int flag;
+{
+ char buf[MAXPATHLEN + 2];
+ register struct circleq_entry *qptr;
+
+ if (map == NULL || domain == NULL)
+ return(0);
+
+ strcpy(buf, domain);
+ strcat(buf, "/");
+ strcat(buf, map);
+
+ for (qptr = qhead.cqh_first; qptr != (void *)&qhead;
+ qptr = qptr->links.cqe_next) {
+ if (!strcmp(qptr->dbptr->name, buf)) {
+ if (qptr->dbptr->flags & flag)
+ return(1);
+ else
+ return(0);
+ }
+ }
+
+ if (yp_open_db_cache(domain, map, NULL, 0) == NULL)
+ return(0);
+
+ if (qhead.cqh_first->dbptr->flags & flag)
+ return(1);
+
+ return(0);
+}
/*
* Add a DB handle and database name to the cache. We only maintain
@@ -227,6 +287,8 @@ static int yp_cache_db(dbp, name, size)
qptr->dbptr->size = size;
qptr->dbptr->key = NULL;
+ qptr->dbptr->flags = yp_setflags(dbp);
+
CIRCLEQ_INSERT_HEAD(&qhead, qptr, links);
numdbs++;
OpenPOWER on IntegriCloud