Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Aug 2012 16:46:53 +0100
From:      Niclas Zeising <zeising@daemonic.se>
To:        current@freebsd.org
Subject:   [PATCH] make it possible for yp_mkdb to send YPPROC_CLEAR to arbitrary host
Message-ID:  <503F8AED.9050508@daemonic.se>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------090307030006060708090008
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I have a patch that makes it possible to send an YPPROC_CLEAR to any 
host, not just localhost.  YPPROC_CLEAR is basically used to flush NIS 
connections, so that clients pick up changes done in the NIS maps right 
away.  Currently yp_mkdb can send this to localhost, but if the 
NIS-server is in a jail, there is no localhost.  This way YPPROC_CLEAR 
can be sent to the NIS server in jails as well.
The patch is attached and also in bin/169911 [1]
Regards
-- 
Niclas Zeising

[1] http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/169911

--------------090307030006060708090008
Content-Type: text/x-patch;
 name="usr.sbin.yp_mkdb.c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="usr.sbin.yp_mkdb.c.diff"

Index: head/usr.sbin/yp_mkdb/yp_mkdb.c
===================================================================
--- head/usr.sbin/yp_mkdb/yp_mkdb.c	(revision 238532)
+++ head/usr.sbin/yp_mkdb/yp_mkdb.c	(working copy)
@@ -57,11 +57,12 @@
 static void
 usage(void)
 {
-	fprintf(stderr, "%s\n%s\n%s\n%s\n",
-	"usage: yp_mkdb -c",
+	fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n",
+	"usage: yp_mkdb [-c | -C hostname]",
 	"       yp_mkdb -u dbname",
-	"       yp_mkdb [-c] [-b] [-s] [-f] [-i inputfile] [-o outputfile]",
-	"               [-d domainname ] [-m mastername] inputfile dbname");
+	"       yp_mkdb [-c | -C hostname] [-b] [-s] [-f] [-i inputfile]",
+	"               [-o outputfile] [-d domainname ] [-m mastername]",
+	"               inputfile dbname");
 	exit(1);
 }
 
@@ -105,6 +106,7 @@
 	char *infile = NULL;
 	char *map = NULL;
 	char *domain = NULL;
+	char *clearhost = "localhost";
 	char *infilename = NULL;
 	char *outfilename = NULL;
 	char *mastername = NULL;
@@ -117,7 +119,7 @@
 	FILE *ifp;
 	char hname[MAXHOSTNAMELEN + 2];
 
-	while ((ch = getopt(argc, argv, "uhcbsfd:i:o:m:")) != -1) {
+	while ((ch = getopt(argc, argv, "uhcC:bsfd:i:o:m:")) != -1) {
 		switch (ch) {
 		case 'f':
 			filter_plusminus++;
@@ -128,6 +130,10 @@
 		case 'c':
 			clear++;
 			break;
+		case 'C':
+			clear++;
+			clearhost = optarg;
+			break;
 		case 'b':
 			interdom++;
 			break;
@@ -156,6 +162,9 @@
 	argc -= optind;
 	argv += optind;
 
+	if (clear > 1)
+		usage();
+
 	if (un) {
 		map = argv[0];
 		if (map == NULL)
@@ -332,7 +341,7 @@
 		char in = 0;
 		char *out = NULL;
 		int stat;
-		if ((stat = callrpc("localhost", YPPROG,YPVERS, YPPROC_CLEAR,
+		if ((stat = callrpc(clearhost, YPPROG,YPVERS, YPPROC_CLEAR,
 			(xdrproc_t)xdr_void, &in,
 			(xdrproc_t)xdr_void, out)) != RPC_SUCCESS) {
 			warnx("failed to send 'clear' to local ypserv: %s",
Index: head/usr.sbin/yp_mkdb/yp_mkdb.8
===================================================================
--- head/usr.sbin/yp_mkdb/yp_mkdb.8	(revision 238532)
+++ head/usr.sbin/yp_mkdb/yp_mkdb.8	(working copy)
@@ -42,7 +42,7 @@
 .Nm
 .Fl u Ar dbname
 .Nm
-.Op Fl c
+.Op Fl c | Fl C Ar hostname
 .Op Fl b
 .Op Fl s
 .Op Fl f
@@ -111,6 +111,12 @@
 .Nm
 will send the signal only after the new database has been successfully
 created.
+.It Fl C
+As
+.Fl c
+but send the YPPROC_CLEAR to the specified
+.Ar hostname
+instead.
 .It Fl b
 Cause
 .Nm

--------------090307030006060708090008--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?503F8AED.9050508>