summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/ypserv/Makefile4
-rw-r--r--usr.sbin/ypserv/common/yplib_host.c7
-rw-r--r--usr.sbin/ypserv/mknetid/Makefile7
-rw-r--r--usr.sbin/ypserv/mknetid/mknetid.899
-rw-r--r--usr.sbin/ypserv/mknetid/mknetid.c613
-rw-r--r--usr.sbin/ypserv/mknetid/netid.581
-rw-r--r--usr.sbin/ypserv/stdethers/Makefile8
-rw-r--r--usr.sbin/ypserv/stdethers/stdethers.855
-rw-r--r--usr.sbin/ypserv/stdethers/stdethers.c194
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile.main5
-rw-r--r--usr.sbin/ypserv/ypinit/Makefile.yp71
-rw-r--r--usr.sbin/ypserv/ypinit/ypinit.sh24
-rw-r--r--usr.sbin/ypserv/yppush/Makefile10
-rw-r--r--usr.sbin/ypserv/yppush/yppush.868
-rw-r--r--usr.sbin/ypserv/yppush/yppush.c355
-rw-r--r--usr.sbin/ypserv/yppush/yppush.h111
-rw-r--r--usr.sbin/ypserv/yppush/yppush_err.c74
-rw-r--r--usr.sbin/ypserv/yppush/yppush_proc.c69
-rw-r--r--usr.sbin/ypserv/yppush/yppush_svc.c130
-rw-r--r--usr.sbin/ypserv/yppush/yppush_xdr.c143
-rw-r--r--usr.sbin/ypserv/ypxfr/ypxfr.c42
21 files changed, 2118 insertions, 52 deletions
diff --git a/usr.sbin/ypserv/Makefile b/usr.sbin/ypserv/Makefile
index 4064026e630..a9de8ab1931 100644
--- a/usr.sbin/ypserv/Makefile
+++ b/usr.sbin/ypserv/Makefile
@@ -1,6 +1,6 @@
# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
-# $Id: Makefile,v 1.2 1995/11/01 16:56:03 deraadt Exp $
+# $Id: Makefile,v 1.3 1996/03/02 03:01:29 dm Exp $
-SUBDIR= makedbm stdhosts ypinit ypserv yptest ypxfr
+SUBDIR= makedbm mknetid stdethers stdhosts ypinit ypserv yptest yppush ypxfr
.include <bsd.subdir.mk>
diff --git a/usr.sbin/ypserv/common/yplib_host.c b/usr.sbin/ypserv/common/yplib_host.c
index 2ef86099e70..56ed23af380 100644
--- a/usr.sbin/ypserv/common/yplib_host.c
+++ b/usr.sbin/ypserv/common/yplib_host.c
@@ -30,7 +30,7 @@
*/
#ifndef LINT
-static char *rcsid = "$Id: yplib_host.c,v 1.1 1995/11/01 16:56:18 deraadt Exp $";
+static char *rcsid = "$Id: yplib_host.c,v 1.2 1996/03/02 03:01:31 dm Exp $";
#endif
#include <sys/param.h>
@@ -102,7 +102,12 @@ u_short port;
tv.tv_sec = 10;
tv.tv_usec = 0;
+#if 0
client = clntudp_create(&rsrv_sin, program, version, tv, &rsrv_sock);
+#else
+ client = clnttcp_create(&rsrv_sin, program, version, &rsrv_sock,
+ 0, 0);
+#endif
if (client == NULL) {
fprintf(stderr, "clntudp_create: no contact with host %s.\n",
server);
diff --git a/usr.sbin/ypserv/mknetid/Makefile b/usr.sbin/ypserv/mknetid/Makefile
new file mode 100644
index 00000000000..3aa1e179cfe
--- /dev/null
+++ b/usr.sbin/ypserv/mknetid/Makefile
@@ -0,0 +1,7 @@
+# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
+# $Id: Makefile,v 1.1 1996/03/02 03:01:32 dm Exp $
+
+PROG= mknetid
+MAN= mknetid.8 netid.5
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/mknetid/mknetid.8 b/usr.sbin/ypserv/mknetid/mknetid.8
new file mode 100644
index 00000000000..27ec18d64c9
--- /dev/null
+++ b/usr.sbin/ypserv/mknetid/mknetid.8
@@ -0,0 +1,99 @@
+.\" Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Mats O Jansson
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: mknetid.8,v 1.1 1996/03/02 03:01:33 dm Exp $
+.\"
+.Dd Januari 13, 1996
+.Dt MKNETID 8
+.Os
+.Sh NAME
+.Nm mknetid
+.Nd a YP filter program
+.Sh SYNOPSIS
+.Nm /usr/sbin/mknetid
+.Op Fl d Ar domain
+.Op Fl q
+.Op Fl p Ar passwdfile
+.Op Fl g Ar groupfile
+.Op Fl h Ar hostfile
+.Op Fl m Ar netidfile
+.Sh DESCRIPTION
+.Nm Mknetid
+is used to create a map named
+.Ar netid.byname .
+The map consists of information from
+.Xr passwd 5 ,
+.Xr group 5
+and
+.Xr hosts 5
+eventually concatenated with a
+.Xr netid 5
+file.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl d Ar domain
+Which yp-domain if not default yp-domain.
+.It Fl q
+Keep quiet about multipy occuraces of a uid. Ignore all but the first.
+.It Fl p Ar passwdfile
+Alternate
+.Xr passwd 5
+file. Default is
+.Nm /etc/passwd .
+.It Fl g Ar groupfile
+Alternate
+.Xr group 5
+file. Default is
+.Nm /etc/group .
+.It Fl h Ar hostfile
+Alternate
+.Xr hosts 5 Default is
+.Nm /etc/hosts .
+file
+.It Fl m Ar netidfile
+Alternate
+.Xr netid 5 Default is
+.Nm /etc/netid .
+file.
+.El
+.Sh FILES
+.Bl -tag -width /etc/passwd -compact
+.It Pa /etc/passwd
+.It Pa /etc/group
+.It Pa /etc/hosts
+.It Pa /etc/netid
+.El
+.Sh SEE ALSO
+.Xr passwd 5 ,
+.Xr group 5 ,
+.Xr hosts 5 ,
+.Xr netid 5
+.Sh AUTHOR
+Mats O Jansson <moj@stacken.kth.se>
diff --git a/usr.sbin/ypserv/mknetid/mknetid.c b/usr.sbin/ypserv/mknetid/mknetid.c
new file mode 100644
index 00000000000..a9542510e1b
--- /dev/null
+++ b/usr.sbin/ypserv/mknetid/mknetid.c
@@ -0,0 +1,613 @@
+/*
+ * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: mknetid.c,v 1.1 1996/03/02 03:01:34 dm Exp $";
+#endif
+
+#include <sys/param.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <pwd.h>
+#include <grp.h>
+#include <netdb.h>
+
+struct user {
+ char *usr_name; /* user name */
+ int usr_uid; /* user uid */
+ int usr_gid; /* user gid */
+ int gid_count; /* number of gids */
+ int gid[NGROUPS]; /* additional gids */
+ struct user *prev,*next; /* links in read order */
+ struct user *hprev,*hnext; /* links in hash order */
+};
+
+#ifdef HOSTS
+char *HostFile = HOSTS;
+#else
+char *HostFile = _PATH_HOSTS;
+#endif
+
+#ifdef PASSWD
+char *PasswdFile = PASSWD;
+#else
+char *PasswdFile = _PATH_PASSWD;
+#endif
+
+#ifdef GROUP
+char *GroupFile = GROUP;
+#else
+char *GroupFile = _PATH_GROUP;
+#endif
+
+#ifdef NETID
+char *NetidFile = NETID;
+#else
+char *NetidFile = "/etc/netid";
+#endif
+
+#define HASHMAX 55
+
+char *ProgramName = "mknetid";
+struct user *root = NULL, *tail = NULL;
+struct user *hroot[HASHMAX], *htail[HASHMAX];
+
+static int read_line(fp, buf, size)
+ FILE *fp;
+ char *buf;
+ int size;
+{
+ int done = 0;
+
+ do {
+ while (fgets(buf, size, fp)) {
+ int len = strlen(buf);
+ done += len;
+ if (len > 1 && buf[len-2] == '\\' &&
+ buf[len-1] == '\n') {
+ int ch;
+ buf += len - 2;
+ size -= len - 2;
+ *buf = '\n'; buf[1] = '\0';
+ /*
+ * Skip leading white space on next line
+ */
+ while ((ch = getc(fp)) != EOF &&
+ isascii(ch) && isspace(ch))
+ ;
+ (void) ungetc(ch, fp);
+ } else {
+ return done;
+ }
+ }
+ } while (size > 0 && !feof(fp));
+
+ return done;
+}
+
+int
+hashidx(key)
+char key;
+{
+ if (key < 'A')
+ return(0);
+ if (key <= 'Z')
+ return(1 + key - 'A');
+ if (key < 'a')
+ return(27);
+ if (key <= 'z')
+ return(28 + key - 'a');
+ return(54);
+}
+
+void add_user(username, uid, gid)
+char *username, *uid, *gid;
+{
+ struct user *u;
+ int idx;
+
+ u = (struct user *) malloc(sizeof(struct user));
+ bzero((void *) u,sizeof(struct user));
+ u->usr_name = (char *) malloc(strlen(username) + 1);
+ strcpy(u->usr_name,username);
+ u->usr_uid=atoi(uid);
+ u->usr_gid=atoi(gid);
+ u->gid_count=-1;
+ if (root == NULL) {
+ root = tail = u;
+ } else {
+ u->prev = tail;
+ tail->next = u;
+ tail = u;
+ }
+ idx = hashidx(username[0]);
+ if (hroot[idx] == NULL) {
+ hroot[idx] = htail[idx] = u;
+ } else {
+ u->hprev = htail[idx];
+ htail[idx]->hnext = u;
+ htail[idx] = u;
+ }
+}
+
+void add_group(username, gid)
+char *username, *gid;
+{
+ struct user *u;
+ int idx, g;
+
+ idx = hashidx(username[0]);
+ u = hroot[idx];
+ g = atoi(gid);
+
+ while (u != NULL) {
+ if (strcmp(username,u->usr_name) == 0) {
+ if (g != u->usr_gid) {
+ u->gid_count++;
+ if (u->gid_count < NGROUPS) {
+ u->gid[u->gid_count]=atoi(gid);
+ }
+ }
+ u = htail[idx];
+ }
+ u = u->hnext;
+ }
+}
+
+void
+read_passwd(pfile, fname)
+FILE *pfile;
+char *fname;
+{
+ char line[1024];
+ int line_no = 0;
+ int len, colon;
+ char *p,*k,*u,*g;
+
+ while (read_line(pfile,line,sizeof(line))) {
+
+ line_no++;
+ len = strlen(line);
+
+ if (len > 0) {
+ if (line[0] == '#')
+ continue;
+ }
+
+ /*
+ * Check if we have the whole line
+ */
+
+ if (line[len-1] != '\n') {
+ fprintf(stderr,
+ "line %d in \"%s\" is too long\n",
+ line_no, fname);
+ } else {
+ line[len-1] = '\0';
+ }
+
+ p = (char *) &line;
+
+ k = p; colon = 0;
+ while (*k != '\0') {
+ if (*k == ':')
+ colon++;
+ k++;
+ }
+
+ if (colon > 0) {
+ k = p; /* save start of key */
+ while (*p != ':') { p++; }; /* find first "colon" */
+ if (*p==':') { *p = '\0'; p++; }; /* terminate key */
+ if (strlen(k) == 1) {
+ if (*k == '+')
+ continue;
+ }
+ }
+
+ if (colon < 4) {
+ fprintf(stderr,
+ "syntax error at line %d in \"%s\"\n",
+ line_no, fname);
+ continue;
+ }
+
+ while (*p != ':') { p++; }; /* find second "colon" */
+ if (*p==':') { *p = '\0'; p++; }; /* terminate passwd */
+ u = p;
+ while (*p != ':') { p++; }; /* find third "colon" */
+ if (*p==':') { *p = '\0'; p++; }; /* terminate uid */
+ g = p;
+ while (*p != ':') { p++; }; /* find forth "colon" */
+ if (*p==':') { *p = '\0'; p++; }; /* terminate gid */
+ while(*p != '\0') { p++; }; /* find end of string */
+
+ add_user(k,u,g);
+ }
+}
+
+int
+isgsep(ch)
+char ch;
+{
+ int ret;
+
+ switch(ch) {
+ case ',':
+ case ' ':
+ case '\t':
+ case '\0':
+ ret = 1;
+ break;
+ default:
+ ret = 0;
+ }
+
+ return ret;
+}
+
+void
+read_group(gfile, fname)
+FILE *gfile;
+char *fname;
+{
+ char line[2048];
+ int line_no = 0;
+ int len, colon;
+ char *p,*k,*u,*g;
+
+ while (read_line(gfile,line,sizeof(line))) {
+
+ line_no++;
+ len = strlen(line);
+
+ if (len > 0) {
+ if (line[0] == '#')
+ continue;
+ }
+
+ /*
+ * Check if we have the whole line
+ */
+
+ if (line[len-1] != '\n') {
+ fprintf(stderr,
+ "line %d in \"%s\" is too long\n",
+ line_no, fname);
+ } else {
+ line[len-1] = '\0';
+ }
+
+ p = (char *) &line;
+
+ k = p; colon = 0;
+ while (*k != '\0') {
+ if (*k == ':')
+ colon++;
+ k++;
+ }
+
+ if (colon > 0) {
+ k = p; /* save start of key */
+ while (*p != ':') { p++; }; /* find first "colon" */
+ if (*p==':') { *p = '\0'; p++; }; /* terminate key */
+ if (strlen(k) == 1) {
+ if (*k == '+')
+ continue;
+ }
+ }
+
+ if (colon < 3) {
+ fprintf(stderr,
+ "syntax error at line %d in \"%s\"\n",
+ line_no, fname);
+ continue;
+ }
+
+ while (*p != ':') { p++; }; /* find second "colon" */
+ if (*p==':') { *p = '\0'; p++; }; /* terminate passwd */
+ g = p;
+ while (*p != ':') { p++; }; /* find third "colon" */
+ if (*p==':') { *p = '\0'; p++; }; /* terminate gid */
+
+ u = p;
+
+ while (*u != '\0') {
+ while (!isgsep(*p)) { p++; }; /* find separator */
+ if (*p != '\0') {
+ *p = '\0';
+ if (u != p) {
+ add_group(u,g);
+ }
+ p++;
+ } else {
+ if (u != p) {
+ add_group(u,g);
+ }
+ }
+ u = p;
+ }
+ }
+}
+
+void
+print_passwd_group(qflag,domain)
+int qflag;
+char *domain;
+{
+ struct user *u,*p;
+ int i;
+
+ u = root;
+
+ while (u != NULL) {
+ p = root;
+ while(p->usr_uid != u->usr_uid) {
+ p = p->next;
+ }
+ if (p != u) {
+ if (!qflag) {
+ fprintf(stderr,
+ "%s: unix.%d@%s %s\n",
+ ProgramName,
+ u->usr_uid,
+ domain,
+ "multiply defined, other definitions ignored");
+ }
+ } else {
+ printf("unix.%d@%s %d:%d",
+ u->usr_uid,
+ domain,
+ u->usr_uid,
+ u->usr_gid);
+ if (u->gid_count >= 0) {
+ i=0;
+ while (i <= u->gid_count) {
+ printf(",%d",u->gid[i]);
+ i++;
+ }
+ }
+ printf("\n");
+ }
+ u = u->next;
+ }
+}
+
+void
+print_hosts(pfile, fname, domain)
+FILE *pfile;
+char *fname, *domain;
+{
+ char line[1024];
+ int line_no = 0;
+ int len, colon;
+ char *p,*k,*u;
+
+ while (read_line(pfile,line,sizeof(line))) {
+
+ line_no++;
+ len = strlen(line);
+
+ if (len > 0) {
+ if (line[0] == '#')
+ continue;
+ }
+
+ /*
+ * Check if we have the whole line
+ */
+
+ if (line[len-1] != '\n') {
+ fprintf(stderr,
+ "line %d in \"%s\" is too long\n",
+ line_no, fname);
+ } else {
+ line[len-1] = '\0';
+ }
+
+ p = (char *) &line;
+
+ k = p; /* save start of key */
+ while (!isspace(*p)) { p++; }; /* find first "space" */
+ while (isspace(*p)) { /* replace space with <NUL> */
+ *p = '\0';
+ p++;
+ }
+
+ u = p;
+ while (p != NULL) {
+ if (*p == '\0') {
+ p = NULL;
+ } else {
+ if (!isspace(*p)) {
+ p++;
+ } else {
+ *p = '\0';
+ p = NULL;
+ }
+ }
+ }
+
+ printf("unix.%s@%s 0:%s\n",
+ u,
+ domain,
+ u);
+ }
+}
+
+void
+print_netid(mfile, fname)
+FILE *mfile;
+char *fname;
+{
+ char line[1024];
+ int line_no = 0;
+ int len, colon;
+ char *p,*k,*u;
+
+ while (read_line(mfile,line,sizeof(line))) {
+
+ line_no++;
+ len = strlen(line);
+
+ if (len > 0) {
+ if (line[0] == '#')
+ continue;
+ }
+
+ /*
+ * Check if we have the whole line
+ */
+
+ if (line[len-1] != '\n') {
+ fprintf(stderr,
+ "line %d in \"%s\" is too long\n",
+ line_no, fname);
+ } else {
+ line[len-1] = '\0';
+ }
+
+ p = (char *) &line;
+
+ k = p; /* save start of key */
+ while (!isspace(*p)) { p++; }; /* find first "space" */
+ while (isspace(*p)) { /* replace space with <NUL> */
+ *p = '\0';
+ p++;
+ }
+
+ u = p;
+ while (p != NULL) {
+ if (*p == '\0') {
+ p = NULL;
+ } else {
+ if (!isspace(*p)) {
+ p++;
+ } else {
+ *p = '\0';
+ p = NULL;
+ }
+ }
+ }
+
+ printf("%s %s\n",k,u);
+ }
+}
+
+int
+main (argc,argv)
+int argc;
+char *argv[];
+{
+ int qflag, ch, usage;
+ char *domain;
+ FILE *pfile, *gfile, *hfile, *mfile;
+
+ qflag = usage = 0;
+ domain = NULL;
+
+ while ((ch = getopt(argc, argv, "d:g:h:m:p:q")) != EOF)
+ switch (ch) {
+ case 'd':
+ domain = optarg;
+ break;
+ case 'g':
+ GroupFile = optarg;
+ break;
+ case 'h':
+ HostFile = optarg;
+ break;
+ case 'm':
+ NetidFile = optarg;
+ break;
+ case 'p':
+ PasswdFile = optarg;
+ break;
+ case 'q':
+ qflag++;
+ break;
+ default:
+ usage++;
+ break;
+ }
+
+ if (argc > optind) {
+ usage++;
+ }
+
+ if (usage) {
+ fprintf(stderr,
+ "usage:\t%s [-d domain] [-q] [-p passwdfile] [-g groupfile]\n\t\t[-h hostfile] [-m netidfile]\n",
+ ProgramName);
+ exit(1);
+ }
+
+ if (domain == NULL) {
+ yp_get_default_domain(&domain);
+ }
+
+ pfile = fopen(PasswdFile, "r");
+ if (pfile == NULL) {
+ fprintf(stderr,"%s: can't open file \"%s\"\n",
+ ProgramName, PasswdFile);
+ exit(1);
+ }
+
+ gfile = fopen(GroupFile, "r");
+ if (gfile == NULL) {
+ fprintf(stderr,"%s: can't open file \"%s\"\n",
+ ProgramName, PasswdFile);
+ exit(1);
+ }
+
+ hfile = fopen(HostFile, "r");
+ if (hfile == NULL) {
+ fprintf(stderr,"%s: can't open file \"%s\"\n",
+ ProgramName, PasswdFile);
+ exit(1);
+ }
+
+ printf("NetidFile: %s\n",NetidFile);
+ mfile = fopen(NetidFile, "r");
+
+ read_passwd(pfile,PasswdFile);
+ read_group(gfile,GroupFile);
+
+ print_passwd_group(qflag,domain);
+ print_hosts(hfile,HostFile,domain);
+ if (mfile != NULL) {
+ print_netid(mfile,NetidFile);
+ }
+
+ return(0);
+
+}
diff --git a/usr.sbin/ypserv/mknetid/netid.5 b/usr.sbin/ypserv/mknetid/netid.5
new file mode 100644
index 00000000000..a4bafdc251d
--- /dev/null
+++ b/usr.sbin/ypserv/mknetid/netid.5
@@ -0,0 +1,81 @@
+.\" Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Mats O Jansson
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: netid.5,v 1.1 1996/03/02 03:01:35 dm Exp $
+.\"
+.Dd January 13, 1996
+.Dt NETID 5
+.Os
+.Sh NAME
+.Nm netid
+.Nd
+.Nm YP
+network credential file
+.Sh DESCRIPTION
+Files in
+.Nm netid
+format is rare. One lives in the
+.Nm YP
+map
+.Nm netid.byname .
+The format is rather simple. Each row consists of two
+items, a key and a value. When created by
+.Xr mknetid 8
+there is three kind of records.
+.Pp
+The first type is information about which gids a uid has:
+.Bd -literal
+unix.<uid>@<yp-domain> <uid>:<gid>,<gid>
+.Ed
+.Pp
+The second type has informations about hosts:
+.Bd -literal
+unix.<hostname>@<yp-domain> 0:<hostname>
+.Ed
+.Pp
+The third type is records from a
+.Xr netid 5
+file other than the two types above.
+.Sh EXAMPLES
+.Pp
+A configuration file might appear as follows:
+.Bd -literal
+unix.10714@kaka 10714:400,10
+unix.jodie@kaka 0:jodie
+.Ed
+.Sh FILES
+.Bl -tag -width /etc/netid -compact
+.It Pa /etc/netid
+A file for lines not generated automatic by
+.Xr mknetid 8 .
+.El
+.Sh SEE ALSO
+.Xr mknetid 8
+.Sh AUTHOR
+Mats O Jansson <moj@stacken.kth.se>
diff --git a/usr.sbin/ypserv/stdethers/Makefile b/usr.sbin/ypserv/stdethers/Makefile
new file mode 100644
index 00000000000..bb999c34956
--- /dev/null
+++ b/usr.sbin/ypserv/stdethers/Makefile
@@ -0,0 +1,8 @@
+# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
+# $Id: Makefile,v 1.1 1996/03/02 03:01:36 dm Exp $
+
+PROG= stdethers
+MAN= stdethers.8
+CFLAGS+= -DNTOA_FIX
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/stdethers/stdethers.8 b/usr.sbin/ypserv/stdethers/stdethers.8
new file mode 100644
index 00000000000..5e2ef023c7d
--- /dev/null
+++ b/usr.sbin/ypserv/stdethers/stdethers.8
@@ -0,0 +1,55 @@
+.\" Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Mats O Jansson
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: stdethers.8,v 1.1 1996/03/02 03:01:37 dm Exp $
+.\"
+.Dd December 2, 1995
+.Dt STDETHERS 8
+.Os
+.Sh NAME
+.Nm stdethers
+.Nd a YP filter program
+.Sh SYNOPSIS
+.Nm /usr/sbin/stdethers
+.Op Ar file
+.Sh DESCRIPTION
+.Nm Stdethers
+is used to get ride of some unwanted information in file or stdin. This
+program is used by YP when creating some YP maps.
+.Pp
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Ar file
+Use this file as input instead of stdin.
+.El
+.Sh SEE ALSO
+.Xr ypserv 8
+.Sh AUTHOR
+Mats O Jansson <moj@stacken.kth.se>
diff --git a/usr.sbin/ypserv/stdethers/stdethers.c b/usr.sbin/ypserv/stdethers/stdethers.c
new file mode 100644
index 00000000000..a1bd2e8812a
--- /dev/null
+++ b/usr.sbin/ypserv/stdethers/stdethers.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: stdethers.c,v 1.1 1996/03/02 03:01:37 dm Exp $";
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <stdio.h>
+#include <ctype.h>
+
+char *ProgramName = "stdethers";
+
+extern int ether_line(char *, struct ether_addr *, char *);
+extern char *ether_ntoa(struct ether_addr *);
+
+#ifndef NTOA_FIX
+#define NTOA(x) (char *)ether_ntoa(x)
+#else
+#define NTOA(x) (char *) working_ntoa((u_char *) x)
+
+/* As of 1995-12-02 NetBSD and OpenBSD has an SunOS 4 incompatible ether_ntoa.
+ The code in usr/lib/libc/net/ethers seems to do the correct thing
+ when asking YP but not when returning string from ether_ntoa.
+ */
+
+char *
+working_ntoa(e)
+ u_char *e;
+{
+ static char a[] = "xx:xx:xx:xx:xx:xx";
+
+ sprintf(a, "%x:%x:%x:%x:%x:%x",
+ e[0], e[1], e[2], e[3], e[4], e[5]);
+ return a;
+}
+#endif
+
+static int read_line(fp, buf, size)
+FILE *fp;
+char *buf;
+int size;
+{
+ int done = 0;
+
+ do {
+ while (fgets(buf, size, fp)) {
+ int len = strlen(buf);
+ done += len;
+ if (len > 1 && buf[len-2] == '\\' &&
+ buf[len-1] == '\n') {
+ int ch;
+ buf += len - 2;
+ size -= len - 2;
+ *buf = '\n'; buf[1] = '\0';
+ /*
+ * Skip leading white space on next line
+ */
+ while ((ch = getc(fp)) != EOF &&
+ isascii(ch) && isspace(ch))
+ ;
+ (void) ungetc(ch, fp);
+ } else {
+ return done;
+ }
+ }
+ } while (size > 0 && !feof(fp));
+
+ return done;
+}
+
+int
+main (argc,argv)
+int argc;
+char *argv[];
+{
+ FILE *data_file;
+ char data_line[1024];
+ int usage = 0;
+ int line_no = 0;
+ int len;
+ char *p,*k,*v;
+ struct ether_addr eth_addr;
+ char hostname[256];
+
+ if (argc > 2) {
+ usage++;
+ }
+
+ if (usage) {
+ fprintf(stderr,
+ "usage: %s [file]\n",
+ ProgramName);
+ exit(1);
+ }
+
+ if (argc == 2) {
+ data_file = fopen(argv[1], "r");
+ if (data_file == NULL) {
+ fprintf(stderr,
+ "%s: can't open %s\n",
+ ProgramName,
+ argv[1]);
+ exit(1);
+ }
+ } else {
+ data_file = stdin;
+ }
+
+ while (read_line(data_file,data_line,sizeof(data_line))) {
+
+ line_no++;
+ len = strlen(data_line);
+
+ if (len > 0) {
+ if (data_line[0] == '#')
+ continue;
+ }
+
+ /*
+ * Check if we have the whole line
+ */
+
+ if (data_line[len-1] != '\n') {
+ if (argc == 2) {
+ fprintf(stderr,
+ "line %d in \"%s\" is too long",
+ line_no, argv[1]);
+ } else {
+ fprintf(stderr,
+ "line %d in \"stdin\" is too long",
+ line_no);
+ }
+ } else {
+ data_line[len-1] = '\0';
+ }
+
+ p = (char *) &data_line;
+
+ k = p; /* save start of key */
+ while (!isspace(*p)) { p++; }; /* find first "space" */
+ while (isspace(*p)) { p++; }; /* move over "space" */
+
+ v = p; /* save start of value */
+ while(*p != '\0') { p++; }; /* find end of string */
+
+ if (ether_line(data_line, &eth_addr, hostname) == 0) {
+ fprintf(stdout, "%s\t%s\n",
+ NTOA(&eth_addr),
+ hostname);
+ } else {
+ fprintf(stderr,
+ "%s: ignoring line %d: \"%s\"\n",
+ ProgramName,
+ line_no,
+ data_line);
+ }
+ }
+
+ return(0);
+
+}
diff --git a/usr.sbin/ypserv/ypinit/Makefile.main b/usr.sbin/ypserv/ypinit/Makefile.main
index 9d08001f40c..2d06332646e 100644
--- a/usr.sbin/ypserv/ypinit/Makefile.main
+++ b/usr.sbin/ypserv/ypinit/Makefile.main
@@ -1,5 +1,8 @@
-# $Id: Makefile.main,v 1.3 1996/01/20 00:36:24 chuck Exp $
+# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
+# $Id: Makefile.main,v 1.4 1996/03/02 03:01:39 dm Exp $
SUBDIR=
+passwd group hosts networks rpc services protocols netid: _SUBDIRUSE
+
.include <bsd.subdir.mk>
diff --git a/usr.sbin/ypserv/ypinit/Makefile.yp b/usr.sbin/ypserv/ypinit/Makefile.yp
index 0e0f521989e..7870a2f69c3 100644
--- a/usr.sbin/ypserv/ypinit/Makefile.yp
+++ b/usr.sbin/ypserv/ypinit/Makefile.yp
@@ -1,5 +1,5 @@
# from: @(#)Makefile 5.6.1.2 (Berkeley) 5/8/91
-# $Id: Makefile.yp,v 1.3 1996/01/06 11:39:40 deraadt Exp $
+# $Id: Makefile.yp,v 1.4 1996/03/02 03:01:40 dm Exp $
YPDBDIR=/var/yp
DIR=/etc
@@ -12,10 +12,13 @@ ECHO=/bin/echo
MAKEDBM=/usr/sbin/makedbm
SED=/usr/bin/sed
STDHOSTS=/usr/sbin/stdhosts
+STDETHERS=/usr/sbin/stdethers
+MKNETID=/usr/sbin/mknetid
TOUCH=/usr/bin/touch
-YPPUSH=$(ECHO) "YPPUSH Not Yet Implemented: "
+DOMAIN="`/usr/bin/basename ${.CURDIR}`"
+YPPUSH=/usr/sbin/yppush
-all: passwd group hosts networks rpc services protocols
+all: passwd group hosts ethers networks rpc services protocols netid
passwd.time: $(DIR)/master.passwd
-@if [ -f $(>) ]; then \
@@ -28,8 +31,8 @@ passwd.time: $(DIR)/master.passwd
$(TOUCH) $(@); \
$(ECHO) "updated passwd"; \
if [ ! $(NOPUSH) ]; then \
- $(YPPUSH) passwd.byname; \
- $(YPPUSH) passwd.byuid; \
+ $(YPPUSH) -d $(DOMAIN) passwd.byname; \
+ $(YPPUSH) -d $(DOMAIN) passwd.byuid; \
$(ECHO) "pushed passwd"; \
else \
: ; \
@@ -50,8 +53,8 @@ group.time: $(DIR)/group
$(TOUCH) $(@); \
$(ECHO) "updated group"; \
if [ ! $(NOPUSH) ]; then \
- $(YPPUSH) group.byname; \
- $(YPPUSH) group.bygid; \
+ $(YPPUSH) -d $(DOMAIN) group.byname; \
+ $(YPPUSH) -d $(DOMAIN) group.bygid; \
$(ECHO) "pushed group"; \
else \
: ; \
@@ -71,8 +74,29 @@ hosts.time: $(DIR)/hosts
$(TOUCH) $(@); \
$(ECHO) "updated hosts"; \
if [ ! $(NOPUSH) ]; then \
- $(YPPUSH) hosts.byname; \
- $(YPPUSH) hosts.byaddr; \
+ $(YPPUSH) -d $(DOMAIN) hosts.byname; \
+ $(YPPUSH) -d $(DOMAIN) hosts.byaddr; \
+ $(ECHO) "pushed hosts"; \
+ else \
+ : ; \
+ fi \
+ else \
+ $(ECHO) "couldn't find $(>)"; \
+ fi
+
+ethers.time: $(DIR)/ethers
+ -@if [ -f $(DIR)/ethers ]; then \
+ $(STDETHERS) $(>) | $(SED) -e s/#.*$$// | \
+ $(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$1, $$0 }' | \
+ $(MAKEDBM) - ethers.byaddr; \
+ $(STDETHERS) $(>) | \
+ $(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$2, $$0 }' | \
+ $(MAKEDBM) - ethers.byname; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated ethers"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) -d $(DOMAIN) ethers.byaddr; \
+ $(YPPUSH) -d $(DOMAIN) ethers.byname; \
$(ECHO) "pushed hosts"; \
else \
: ; \
@@ -91,8 +115,8 @@ networks.time: $(DIR)/networks
$(TOUCH) $(@); \
$(ECHO) "updated networks"; \
if [ ! $(NOPUSH) ]; then \
- $(YPPUSH) networks.byname; \
- $(YPPUSH) networks.byaddr; \
+ $(YPPUSH) -d $(DOMAIN) networks.byname; \
+ $(YPPUSH) -d $(DOMAIN) networks.byaddr; \
$(ECHO) "pushed networks"; \
else \
: ; \
@@ -108,7 +132,7 @@ rpc.time: $(DIR)/rpc
$(TOUCH) $(@); \
$(ECHO) "updated rpc"; \
if [ ! $(NOPUSH) ]; then \
- $(YPPUSH) rpc.bynumber; \
+ $(YPPUSH) -d $(DOMAIN) rpc.bynumber; \
$(ECHO) "pushed rpc"; \
else \
: ; \
@@ -125,7 +149,7 @@ services.time: $(DIR)/services
$(TOUCH) $(@); \
$(ECHO) "updated services"; \
if [ ! $(NOPUSH) ]; then \
- $(YPPUSH) services.byname; \
+ $(YPPUSH) -d $(DOMAIN) services.byname; \
$(ECHO) "pushed services"; \
else \
: ; \
@@ -145,8 +169,8 @@ protocols.time: $(DIR)/protocols
$(TOUCH) $(@); \
$(ECHO) "updated protocols"; \
if [ ! $(NOPUSH) ]; then \
- $(YPPUSH) protocols.bynumber; \
- $(YPPUSH) protocols.byname; \
+ $(YPPUSH) -d $(DOMAIN) protocols.bynumber; \
+ $(YPPUSH) -d $(DOMAIN) protocols.byname; \
$(ECHO) "pushed protocols"; \
else \
: ; \
@@ -156,17 +180,34 @@ protocols.time: $(DIR)/protocols
fi
+netid.time: $(DIR)/passwd $(DIR)/group $(DIR)/hosts $(DIR)/netid
+ -@$(MKNETID) -q -d $(DOMAIN) -p $(DIR)/passwd -g $(DIR)/group -h $(DIR)/hosts -m $(DIR)/netid | \
+ $(MAKEDBM) - netid.byname; \
+ $(TOUCH) $(@); \
+ $(ECHO) "updated netid"; \
+ if [ ! $(NOPUSH) ]; then \
+ $(YPPUSH) -d $(DOMAIN) netid.byname; \
+ $(ECHO) "pushed netid"; \
+ else \
+ : ; \
+ fi
+
+
passwd: passwd.time
group: group.time
hosts: hosts.time
+ethers: ethers.time
networks: networks.time
rpc: rpc.time
services: services.time
protocols: protocols.time
+netid: netid.time
$(DIR)/passwd:
$(DIR)/group:
$(DIR)/hosts:
+$(DIR)/ethers:
$(DIR)/networks:
$(DIR)/rpc:
$(DIR)/services:
$(DIR)/protocols:
+$(DIR)/netid:
diff --git a/usr.sbin/ypserv/ypinit/ypinit.sh b/usr.sbin/ypserv/ypinit/ypinit.sh
index 5e7ec963264..b5d67333bbc 100644
--- a/usr.sbin/ypserv/ypinit/ypinit.sh
+++ b/usr.sbin/ypserv/ypinit/ypinit.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Id: ypinit.sh,v 1.2 1995/11/08 00:01:05 deraadt Exp $
+# $Id: ypinit.sh,v 1.3 1996/03/02 03:01:40 dm Exp $
#
# ypinit.sh - setup an master or slave server.
#
@@ -44,8 +44,8 @@ if [ $# -eq 3 ]
then
if [ $1 = "-s" ] # ypinit -s master_server domainname
then
- DOMAIN=`${3}`
- SERVERTYPE=MASTER
+ DOMAIN=${3}
+ SERVERTYPE=SLAVE
MASTER=${2}
ERROR=
fi
@@ -63,15 +63,6 @@ a slave data base. master_server must be an existing reachable YP server." 1>&2
exit 1
fi
-# Just allow master server for now!
-
-#if [ "${SERVERTYPE}" != "MASTER" ];
-#then
-# echo "Sorry, only master server is implemented. Support for slave server" 1>&2
-# echo "needs support for map transfer which isn't implemented yet." 1>&2
-# exit 1
-#fi
-
# Check if domainname is set, don't accept an empty domainname
if [ -z "${DOMAIN}" ]
@@ -197,9 +188,12 @@ fi
if [ "${SERVERTYPE}" = "SLAVE" ];
then
-
+
+ echo ""
+
for MAP in `${YPWHICH} -d ${DOMAIN} -m | cut -d\ -f1`
do
+ echo "Transfering ${MAP}..."
${YPXFR} -h ${MASTER} -c -d ${DOMAIN} ${MAP}
if [ $? -ne 0 ]
@@ -208,4 +202,8 @@ then
exit 1
fi
done
+
+ echo ""
+ echo "Don't forget to update map ypservers on ${MASTER}."
+ exit 0
fi
diff --git a/usr.sbin/ypserv/yppush/Makefile b/usr.sbin/ypserv/yppush/Makefile
new file mode 100644
index 00000000000..fe55c5065a1
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/Makefile
@@ -0,0 +1,10 @@
+# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
+# $Id: Makefile,v 1.1 1996/03/02 03:01:42 dm Exp $
+
+PROG= yppush
+SRCS= yppush.c yplib_host.c yppush_svc.c yppush_xdr.c yppush_proc.c ypdb.c yppush_err.c
+MAN= yppush.8
+.PATH: ${.CURDIR}/../common ${.CURDIR}/../ypserv
+CFLAGS+=-I${.CURDIR}/../common
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/ypserv/yppush/yppush.8 b/usr.sbin/ypserv/yppush/yppush.8
new file mode 100644
index 00000000000..51509138fd3
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/yppush.8
@@ -0,0 +1,68 @@
+.\" Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by Mats O Jansson
+.\" 4. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $Id: yppush.8,v 1.1 1996/03/02 03:01:42 dm Exp $
+.\"
+.Dd January 29, 1995
+.Dt YPPUSH 8
+.Os
+.Sh NAME
+.Nm yppush
+.Nd force distribution of YP map
+.Sh SYNOPSIS
+.Nm /usr/sbin/yppush
+.Op Fl d Ar domainname
+.Op Fl h Ar hostname
+.\" .Op Fl p Ar paralleljobs
+.\" .Op Fl t Ar timeout
+.Op Fl v
+.Ar mapname
+.Sh DESCRIPTION
+.Nm yppush
+is used to distribute an YP map from a master server to any
+slave server in the domain. All servers of domain is featch from the YP
+map ypservers.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl d Ar domainname
+Don't use default domain, use the specified domain.
+.It Fl h Ar hostname
+Distribute map only to one host and not to the hosts in the ypserver map.
+.\" .It Fl p Ar paralleljobs
+.\"Set the number of parallel transfers.
+.\".It Fl t Ar timeout
+.\"Set the amount of time to elapse before a timeout is registered.
+.It Fl v
+Verbose. Announce what the program is doing.
+.El
+.Sh SEE ALSO
+.Xr ypserv 8
+.Sh AUTHOR
+Mats O Jansson
diff --git a/usr.sbin/ypserv/yppush/yppush.c b/usr.sbin/ypserv/yppush/yppush.c
new file mode 100644
index 00000000000..71e0c96baf5
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/yppush.c
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char rcsid[] = "$Id: yppush.c,v 1.1 1996/03/02 03:01:43 dm Exp $";
+#endif /* not lint */
+
+/*
+#include <sys/param.h>
+#include <sys/socket.h>
+*/
+#include <sys/types.h>
+#include <stdio.h>
+/*
+#include <time.h>
+#include <netdb.h>
+*/
+#include <unistd.h>
+/*
+#include <string.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+*/
+
+#include <rpc/rpc.h>
+#include <rpc/xdr.h>
+#include <rpcsvc/yp.h>
+#include <rpcsvc/ypclnt.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/resource.h>
+#include <sys/signal.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "yplib_host.h"
+#include "ypdef.h"
+#include "ypdb.h"
+
+int Verbose = 0;
+char Domain[255], Map[255], *LocalHost = "meg.celsiustech.se";
+u_long OrderNum;
+
+extern void yppush_xfrrespprog_1(struct svc_req *request, SVCXPRT *xprt);
+extern bool_t xdr_ypreq_xfr(XDR *, struct ypreq_xfr *);
+
+void
+usage()
+{
+ fprintf(stderr, "Usage:\n");
+/*
+ fprintf(stderr, "\typpush [-d domainname] [-t seconds] [-p #paralleljobs] [-h host] [-v] mapname\n");
+*/
+ fprintf(stderr, "\typpush [-d domainname] [-h host] [-v] mapname\n");
+ exit(1);
+}
+
+void
+_svc_run()
+{
+ fd_set readfds;
+ struct timeval timeout;
+
+ timeout.tv_sec=60; timeout.tv_usec=0;
+
+ for(;;) {
+ readfds = svc_fdset;
+ switch (select(_rpc_dtablesize(), &readfds, (void *) 0,
+ (void *) 0, &timeout)) {
+ case -1:
+ if (errno == EINTR) {
+ continue;
+ }
+ perror("yppush: _svc_run: select failed");
+ return;
+ case 0:
+ fprintf(stderr, "yppush: Callback timed out.\n");
+ exit(0);
+ default:
+ svc_getreqset(&readfds);
+ }
+ }
+
+}
+
+void
+req_xfr(pid, prog, transp, host, client)
+pid_t pid;
+u_int prog;
+SVCXPRT *transp;
+char *host;
+CLIENT *client;
+{
+ struct ypreq_xfr request;
+ struct timeval tv;
+
+ tv.tv_sec=0; tv.tv_usec=0;
+
+ request.map_parms.domain=(char *)&Domain;
+ request.map_parms.map=(char *)&Map;
+ request.map_parms.peer=LocalHost;
+ request.map_parms.ordernum=OrderNum;
+ request.transid=(u_int)pid;
+ request.prog=prog;
+ request.port=transp->xp_port;
+
+ if (Verbose)
+ printf("%d: %s(%d@%s) -> %s@%s\n",
+ request.transid,
+ request.map_parms.map,
+ request.map_parms.ordernum,
+ host,
+ request.map_parms.peer,
+ request.map_parms.domain);
+ switch (clnt_call(client, YPPROC_XFR, xdr_ypreq_xfr, &request,
+ xdr_void, NULL, tv)) {
+ case RPC_SUCCESS:
+ case RPC_TIMEDOUT:
+ break;
+ default:
+ clnt_perror(client, "yppush: Cannot call YPPROC_XFR");
+ kill(pid, SIGTERM);
+ }
+}
+
+void
+push(inlen, indata)
+int inlen;
+char *indata;
+{
+ char host[255];
+ CLIENT *client;
+ SVCXPRT *transp;
+ int sock = RPC_ANYSOCK;
+ u_int prog;
+ bool_t sts;
+ pid_t pid;
+ int status;
+ struct rusage res;
+
+ sprintf(host,"%*.*s" ,inlen ,inlen, indata);
+
+ client = clnt_create(host, YPPROG, YPVERS, "tcp");
+ if (client == NULL) {
+ if (Verbose)
+ fprintf(stderr,"Target Host: %s\n",host);
+ clnt_pcreateerror("yppush: Cannot create client");
+ return;
+ }
+
+ transp = svcudp_create(sock);
+ if (transp == NULL) {
+ fprintf(stderr, "yppush: Cannot create callback transport.\n");
+ return;
+ }
+
+ for (prog=0x40000000; prog<0x5fffffff; prog++) {
+ if (sts = svc_register(transp, prog, 1,
+ yppush_xfrrespprog_1, IPPROTO_UDP))
+ break;
+ }
+
+ if (!sts) {
+ fprintf(stderr, "yppush: Cannot register callback.\n");
+ return;
+ }
+
+ switch(pid=fork()) {
+ case -1:
+ fprintf(stderr, "yppush: Cannot fork.\n");
+ exit(1);
+ case 0:
+ _svc_run();
+ exit(0);
+ default:
+ close(transp->xp_sock);
+ req_xfr(pid, prog, transp, host, client);
+ wait4(pid, &status, 0, &res);
+ svc_unregister(prog, 1);
+ if (client != NULL) {
+ clnt_destroy(client);
+ }
+ }
+
+}
+
+int
+pushit(instatus, inkey, inkeylen, inval, invallen, indata)
+int instatus;
+char *inkey;
+int inkeylen;
+char *inval;
+int invallen;
+char *indata;
+{
+ if(instatus != YP_TRUE)
+ return instatus;
+ push(invallen, inval);
+ return 0;
+}
+
+int
+main(argc, argv)
+int argc;
+char **argv;
+{
+ struct ypall_callback ypcb;
+ char *master;
+ extern char *optarg;
+ extern int optind;
+ char *domain,*map,*hostname,*parallel,*timeout;
+ int c, r, i;
+ char *ypmap = "ypservers";
+ CLIENT *client;
+ static char map_path[255];
+ struct stat finfo;
+ DBM *yp_databas;
+ char order_key[YP_LAST_LEN] = YP_LAST_KEY;
+ datum o;
+
+ yp_get_default_domain(&domain);
+ hostname = NULL;
+/*
+ while( (c=getopt(argc, argv, "d:h:p:t:v?")) != -1)
+*/
+ while( (c=getopt(argc, argv, "d:h:v?")) != -1)
+ switch(c) {
+ case 'd':
+ domain = optarg;
+ break;
+ case 'h':
+ hostname = optarg;
+ break;
+ case 'p':
+ parallel = optarg;
+ break;
+ case 't':
+ timeout = optarg;
+ break;
+ case 'v':
+ Verbose = 1;
+ break;
+ case '?':
+ usage();
+ /*NOTREACHED*/
+ }
+
+ if(optind + 1 != argc )
+ usage();
+
+ map = argv[optind];
+
+ strcpy(Domain,domain);
+ strcpy(Map,map);
+
+ /* Check domain */
+ sprintf(map_path,"%s/%s",YP_DB_PATH,domain);
+ if (!((stat(map_path, &finfo) == 0) &&
+ ((finfo.st_mode & S_IFMT) == S_IFDIR))) {
+ fprintf(stderr,"yppush: Map does not exists.\n");
+ exit(1);
+ }
+
+ /* Check map */
+ sprintf(map_path,"%s/%s/%s%s",YP_DB_PATH,domain,Map,YPDB_SUFFIX);
+ if (!(stat(map_path, &finfo) == 0)) {
+ fprintf(stderr,"yppush: Map does not exists.\n");
+ exit(1);
+ }
+
+ sprintf(map_path,"%s/%s/%s",YP_DB_PATH,domain,Map);
+ yp_databas = ypdb_open(map_path,0,O_RDONLY);
+ OrderNum=0xffffffff;
+ if (yp_databas == 0) {
+ fprintf(stderr, "yppush: %s%s: Cannot open database\n",
+ map_path, YPDB_SUFFIX);
+ } else {
+ o.dptr = (char *) &order_key;
+ o.dsize = YP_LAST_LEN;
+ o=ypdb_fetch(yp_databas,o);
+ if (o.dptr == NULL) {
+ fprintf(stderr,
+ "yppush: %s: Cannot determine order number\n",
+ Map);
+ } else {
+ OrderNum=0;
+ for(i=0; i<o.dsize-1; i++) {
+ if (!isdigit(o.dptr[i])) {
+ OrderNum=0xffffffff;
+ }
+ }
+ if (OrderNum != 0) {
+ fprintf(stderr,
+ "yppush: %s: Invalid order number '%s'\n",
+ Map,
+ o.dptr);
+ } else {
+ OrderNum = atoi(o.dptr);
+ }
+ }
+ }
+
+
+ yp_bind(Domain);
+
+ if (hostname != NULL) {
+ push(strlen(hostname), hostname);
+ } else {
+
+ r = yp_master(Domain, ypmap, &master);
+
+ if (Verbose) {
+ printf("Contacting master for ypservers (%s).\n", master);
+ }
+
+ client = yp_bind_host(master, YPPROG, YPVERS, 0);
+
+ ypcb.foreach = pushit;
+ ypcb.data = NULL;
+
+ r = yp_all_host(client,Domain, ypmap, &ypcb);
+ }
+
+ exit(0);
+}
+
diff --git a/usr.sbin/ypserv/yppush/yppush.h b/usr.sbin/ypserv/yppush/yppush.h
new file mode 100644
index 00000000000..0585ec15afd
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/yppush.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: yppush.h,v 1.1 1996/03/02 03:01:44 dm Exp $
+ *
+ */
+
+#ifndef _YPPUSH_H_RPCGEN
+#define _YPPUSH_H_RPCGEN
+
+#include <rpc/rpc.h>
+
+
+enum yppush_status {
+ YPPUSH_SUCC = 1,
+ YPPUSH_AGE = 2,
+ YPPUSH_NOMAP = -1,
+ YPPUSH_NODOM = -2,
+ YPPUSH_RSRC = -3,
+ YPPUSH_RPC = -4,
+ YPPUSH_MADDR = -5,
+ YPPUSH_YPERR = -6,
+ YPPUSH_BADARGS = -7,
+ YPPUSH_DBM = -8,
+ YPPUSH_FILE = -9,
+ YPPUSH_SKEW = -10,
+ YPPUSH_CLEAR = -11,
+ YPPUSH_FORCE = -12,
+ YPPUSH_XFRERR = -13,
+ YPPUSH_REFUSED = -14,
+};
+typedef enum yppush_status yppush_status;
+#ifdef __cplusplus
+extern "C" bool_t xdr_yppush_status(XDR *, yppush_status*);
+#elif __STDC__
+extern bool_t xdr_yppush_status(XDR *, yppush_status*);
+#else /* Old Style C */
+bool_t xdr_yppush_status();
+#endif /* Old Style C */
+
+
+struct yppushresp_xfr {
+ u_int transid;
+ yppush_status status;
+};
+typedef struct yppushresp_xfr yppushresp_xfr;
+#ifdef __cplusplus
+extern "C" bool_t xdr_yppushresp_xfr(XDR *, yppushresp_xfr*);
+#elif __STDC__
+extern bool_t xdr_yppushresp_xfr(XDR *, yppushresp_xfr*);
+#else /* Old Style C */
+bool_t xdr_yppushresp_xfr();
+#endif /* Old Style C */
+
+
+#define YPPUSH_XFRRESPPROG ((u_long)0x40000000)
+#define YPPUSH_XFRRESPVERS ((u_long)1)
+
+#ifdef __cplusplus
+#define YPPUSHPROC_NULL ((u_long)0)
+extern "C" void * yppushproc_null_1(void *, CLIENT *);
+extern "C" void * yppushproc_null_1_svc(void *, struct svc_req *);
+#define YPPUSHPROC_XFRRESP ((u_long)1)
+extern "C" void * yppushproc_xfrresp_1(yppushresp_xfr *, CLIENT *);
+extern "C" void * yppushproc_xfrresp_1_svc(yppushresp_xfr *, struct svc_req *);
+
+#elif __STDC__
+#define YPPUSHPROC_NULL ((u_long)0)
+extern void * yppushproc_null_1(void *, CLIENT *);
+extern void * yppushproc_null_1_svc(void *, struct svc_req *);
+#define YPPUSHPROC_XFRRESP ((u_long)1)
+extern void * yppushproc_xfrresp_1(yppushresp_xfr *, CLIENT *);
+extern void * yppushproc_xfrresp_1_svc(yppushresp_xfr *, struct svc_req *);
+
+#else /* Old Style C */
+#define YPPUSHPROC_NULL ((u_long)0)
+extern void * yppushproc_null_1();
+extern void * yppushproc_null_1_svc();
+#define YPPUSHPROC_XFRRESP ((u_long)1)
+extern void * yppushproc_xfrresp_1();
+extern void * yppushproc_xfrresp_1_svc();
+#endif /* Old Style C */
+
+#endif /* !_YPPUSH_H_RPCGEN */
diff --git a/usr.sbin/ypserv/yppush/yppush_err.c b/usr.sbin/ypserv/yppush/yppush_err.c
new file mode 100644
index 00000000000..d54d0d1e125
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/yppush_err.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char rcsid[] = "$Id: yppush_err.c,v 1.1 1996/03/02 03:01:46 dm Exp $";
+#endif /* not lint */
+
+#include <rpcsvc/yp.h>
+
+char *
+yppush_err_string(enum yppush_status y) {
+ switch(y) {
+ case YPPUSH_SUCC:
+ return "Success";
+ case YPPUSH_AGE:
+ return "Master's version not newer";
+ case YPPUSH_NOMAP:
+ return "Can't find server for map";
+ case YPPUSH_NODOM:
+ return "Domain not supported";
+ case YPPUSH_RSRC:
+ return "Local resource alloc failure";
+ case YPPUSH_RPC:
+ return "RPC failure talking to server";
+ case YPPUSH_MADDR:
+ return "Can't get master address";
+ case YPPUSH_YPERR:
+ return "YP server/map db error";
+ case YPPUSH_BADARGS:
+ return "Request arguments bad";
+ case YPPUSH_DBM:
+ return "Local dbm operation failed";
+ case YPPUSH_FILE:
+ return "Local file I/O operation failed";
+ case YPPUSH_SKEW:
+ return "Map version skew during transfer";
+ case YPPUSH_CLEAR:
+ return "Can't send \"Clear\" req to local ypserv";
+ case YPPUSH_FORCE:
+ return "No local order number in map use -f flag.";
+ case YPPUSH_XFRERR:
+ return "ypxfr error";
+ case YPPUSH_REFUSED:
+ return "Transfer request refused by ypserv";
+ }
+};
diff --git a/usr.sbin/ypserv/yppush/yppush_proc.c b/usr.sbin/ypserv/yppush/yppush_proc.c
new file mode 100644
index 00000000000..15fc0a3b302
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/yppush_proc.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char rcsid[] = "$Id: yppush_proc.c,v 1.1 1996/03/02 03:01:46 dm Exp $";
+#endif /* not lint */
+
+#include <stdio.h>
+#include "yppush.h"
+
+void *
+yppushproc_null_1_svc(argp, rqstp)
+ void *argp;
+ struct svc_req *rqstp;
+{
+
+ static char* result;
+
+ /*
+ * insert server code here
+ */
+ return((void*) &result);
+}
+
+void *
+yppushproc_xfrresp_1_svc(argp, rqstp)
+ yppushresp_xfr *argp;
+ struct svc_req *rqstp;
+{
+
+ static char* result;
+
+ /*
+ * insert server code here
+ */
+ if (argp->status!=YPPUSH_SUCC)
+ fprintf(stderr,"yppush: %s\n",
+ yppush_err_string(argp->status));
+
+ return((void*) &result);
+}
diff --git a/usr.sbin/ypserv/yppush/yppush_svc.c b/usr.sbin/ypserv/yppush/yppush_svc.c
new file mode 100644
index 00000000000..636bbc91f55
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/yppush_svc.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef lint
+static char rcsid[] = "$Id: yppush_svc.c,v 1.1 1996/03/02 03:01:47 dm Exp $";
+#endif /* not lint */
+
+#include "yppush.h"
+#include <stdio.h>
+#include <stdlib.h>/* getenv, exit */
+#include <netdb.h>
+#include <signal.h>
+#include <sys/ttycom.h>/* TIOCNOTTY */
+#include <memory.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#ifdef SYSLOG
+#include <syslog.h>
+#else
+#define LOG_ERR 1
+#define openlog(a, b, c)
+#endif
+
+#ifdef __STDC__
+#define SIG_PF void(*)(int)
+#endif
+
+#ifdef DEBUG
+#define RPC_SVC_FG
+#endif
+
+#define _RPCSVC_CLOSEDOWN 120
+int _rpcpmstart; /* Started by a port monitor ? */
+int _rpcfdtype; /* Whether Stream or Datagram ? */
+int _rpcsvcdirty; /* Still serving ? */
+
+static
+void _msgout(msg)
+ char *msg;
+{
+#ifdef RPC_SVC_FG
+ if (_rpcpmstart)
+ syslog(LOG_ERR, msg);
+ else
+ (void) fprintf(stderr, "%s\n", msg);
+#else
+ syslog(LOG_ERR, msg);
+#endif
+}
+
+void
+yppush_xfrrespprog_1(rqstp, transp)
+ struct svc_req *rqstp;
+ register SVCXPRT *transp;
+{
+ union {
+ int fill;
+ } argument;
+ char *result;
+ bool_t (*xdr_argument)(), (*xdr_result)();
+ char *(*local)();
+
+ _rpcsvcdirty = 1;
+ switch (rqstp->rq_proc) {
+ case YPPUSHPROC_NULL:
+ xdr_argument = xdr_void;
+ xdr_result = xdr_void;
+ local = (char *(*)()) yppushproc_null_1_svc;
+ break;
+
+ case YPPUSHPROC_XFRRESP:
+ xdr_argument = xdr_yppushresp_xfr;
+ xdr_result = xdr_void;
+ local = (char *(*)()) yppushproc_xfrresp_1_svc;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ _rpcsvcdirty = 0;
+ exit(1);
+ return;
+ }
+ (void) memset((char *)&argument, 0, sizeof (argument));
+ if (!svc_getargs(transp, xdr_argument, (caddr_t) &argument)) {
+ svcerr_decode(transp);
+ _rpcsvcdirty = 0;
+ exit(1);
+ return;
+ }
+ result = (*local)(&argument, rqstp);
+ if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
+ svcerr_systemerr(transp);
+ }
+ if (!svc_freeargs(transp, xdr_argument, (caddr_t) &argument)) {
+ _msgout("unable to free arguments");
+ exit(1);
+ }
+ _rpcsvcdirty = 0;
+ if (rqstp->rq_proc!=YPPUSHPROC_NULL)
+ exit(0);
+ return;
+}
diff --git a/usr.sbin/ypserv/yppush/yppush_xdr.c b/usr.sbin/ypserv/yppush/yppush_xdr.c
new file mode 100644
index 00000000000..861c1406b0b
--- /dev/null
+++ b/usr.sbin/ypserv/yppush/yppush_xdr.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 1996 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef LINT
+static char rcsid[] = "$Id: yppush_xdr.c,v 1.1 1996/03/02 03:01:48 dm Exp $";
+#endif
+
+#include <rpc/rpc.h>
+#include <rpcsvc/yp.h>
+
+bool_t
+xdr_domainname(xdrs, objp)
+ XDR *xdrs;
+ domainname *objp;
+{
+ if (!xdr_string(xdrs, objp, YPMAXDOMAIN)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_mapname(xdrs, objp)
+ XDR *xdrs;
+ mapname *objp;
+{
+ if (!xdr_string(xdrs, objp, YPMAXMAP)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_peername(xdrs, objp)
+ XDR *xdrs;
+ peername *objp;
+{
+ if (!xdr_string(xdrs, objp, YPMAXPEER)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ypmap_parms(xdrs, objp)
+ XDR *xdrs;
+ ypmap_parms *objp;
+{
+ if (!xdr_domainname(xdrs, &objp->domain)) {
+ return (FALSE);
+ }
+ if (!xdr_mapname(xdrs, &objp->map)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->ordernum)) {
+ return (FALSE);
+ }
+ if (!xdr_peername(xdrs, &objp->peer)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_ypreq_xfr(xdrs, objp)
+ XDR *xdrs;
+ ypreq_xfr *objp;
+{
+ if (!xdr_ypmap_parms(xdrs, &objp->map_parms)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->transid)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->prog)) {
+ return (FALSE);
+ }
+ if (!xdr_u_int(xdrs, &objp->port)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_yppush_status(xdrs, objp)
+ XDR *xdrs;
+ yppush_status *objp;
+{
+ register long *buf;
+
+ if (!xdr_enum(xdrs, (enum_t *)objp)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+bool_t
+xdr_yppushresp_xfr(xdrs, objp)
+ XDR *xdrs;
+ yppushresp_xfr *objp;
+{
+
+ register long *buf;
+
+ if (!xdr_u_int(xdrs, &objp->transid)) {
+ return (FALSE);
+ }
+ if (!xdr_yppush_status(xdrs, &objp->status)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+
+
diff --git a/usr.sbin/ypserv/ypxfr/ypxfr.c b/usr.sbin/ypserv/ypxfr/ypxfr.c
index ce11e13321e..079627276c5 100644
--- a/usr.sbin/ypserv/ypxfr/ypxfr.c
+++ b/usr.sbin/ypserv/ypxfr/ypxfr.c
@@ -10,9 +10,11 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Mats O Jansson
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -28,7 +30,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: ypxfr.c,v 1.2 1996/01/20 00:38:49 chuck Exp $";
+static char rcsid[] = "$Id: ypxfr.c,v 1.3 1996/03/02 03:01:49 dm Exp $";
#endif
#include <stdio.h>
@@ -75,10 +77,10 @@ char *keystr,*valstr;
valstr[vallen] = '\0';
key.dptr = keystr;
- key.dsize = strlen(keystr) + 1;
+ key.dsize = strlen(keystr);
val.dptr = valstr;
- val.dsize = strlen(valstr) + 1;
+ val.dsize = strlen(valstr);
ypdb_store(db, key, val, YPDB_INSERT);
@@ -92,7 +94,7 @@ char *map;
u_long *lordernum;
{
char map_path[1024];
- char order_key[YP_LAST_LEN] = YP_LAST_KEY;
+ char order_key[] = YP_LAST_KEY;
char order[MAX_LAST_LEN+1];
struct stat finfo;
DBM *db;
@@ -231,16 +233,16 @@ u_long ordernum;
{
char datestr[10];
datum key,val;
- char keystr[YP_LAST_LEN] = YP_LAST_KEY;
+ char keystr[] = YP_LAST_KEY;
int status;
sprintf(datestr, "%010d", ordernum);
key.dptr = keystr;
- key.dsize = strlen(keystr) + 1;
+ key.dsize = strlen(keystr);
val.dptr = datestr;
- val.dsize = strlen(datestr) + 1;
+ val.dsize = strlen(datestr);
status = ypdb_store(db, key, val, YPDB_INSERT);
if(status >= 0) {
@@ -258,7 +260,7 @@ char *domain;
char *map;
DBM *db;
{
- char keystr[YP_MASTER_LEN] = YP_MASTER_KEY;
+ char keystr[] = YP_MASTER_KEY;
char *master;
int status;
datum key,val;
@@ -271,10 +273,10 @@ DBM *db;
if(master != NULL) {
key.dptr = keystr;
- key.dsize = strlen(keystr) + 1;
+ key.dsize = strlen(keystr);
val.dptr = master;
- val.dsize = strlen(master) + 1;
+ val.dsize = strlen(master);
status = ypdb_store(db, key, val, YPDB_INSERT);
if(status >= 0) {
@@ -294,7 +296,7 @@ char *domain;
char *map;
DBM *db;
{
- char keystr[YP_INTERDOMAIN_LEN] = YP_INTERDOMAIN_KEY;
+ char keystr[] = YP_INTERDOMAIN_KEY;
char *value;
int vallen;
int status;
@@ -303,12 +305,12 @@ DBM *db;
/* Get INTERDOMAIN */
k.dptr = keystr;
- k.dsize = strlen(keystr) + 1;
+ k.dsize = strlen(keystr);
- status = yp_match_host(client, domain, map,
+ status = !yp_match_host(client, domain, map,
k.dptr, k.dsize, &value, &vallen);
- if(status > 0) {
+ if(status > 0 && value) {
v.dptr = value;
v.dsize = vallen;
@@ -332,7 +334,7 @@ char *domain;
char *map;
DBM *db;
{
- char keystr[YP_SECURE_LEN] = YP_SECURE_KEY;
+ char keystr[] = YP_SECURE_KEY;
char *value;
int vallen;
int status;
@@ -341,7 +343,7 @@ DBM *db;
/* Get SECURE */
k.dptr = keystr;
- k.dsize = strlen(keystr) + 1;
+ k.dsize = strlen(keystr);
status = yp_match_host(client, domain, map,
k.dptr, k.dsize, &value, &vallen);
@@ -532,7 +534,7 @@ char *argv[];
yplog("Connect host: %s", host);
client = yp_bind_host(host,YPPROG,YPVERS,0);
-
+
status = get_remote_ordernum(client,domain,map,
ordernum,&new_ordernum);