bin/169911: [PATCH] make it possible for yp_mkdb to send YPPROC_CLEAR to specified host

Niclas Zeising zeising at daemonic.se
Mon Jul 16 14:50:11 UTC 2012


>Number:         169911
>Category:       bin
>Synopsis:       [PATCH] make it possible for yp_mkdb to send YPPROC_CLEAR to specified host
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 16 14:50:10 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Niclas Zeising
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
System: FreeBSD tifa.daemonic.se 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r231776M: Wed Feb 15 22:30:06 CET 2012 root at tifa.daemonic.se:/usr/obj/usr/src/sys/TIFA amd64


	
>Description:
	yp_mkdb is used to generate maps for NIS to hand out.  It is possible to have yp_mkdb send a YPPROC_CLEAR to localhost to have the local NIS server to close open connections and flush it's cache.
	When running a NIS server in a jail, localhost does not exists, which means there is no way to accomplish this 'clearing'.
>How-To-Repeat:
	
>Fix:

	Attached patch adds a new option -C hostname to yp_mkdb that makes it send the YPPROC_CLEAR to the specified hostname instead of localhost.
	This makes it possible to 'clear' a NIS server running in a jail.  This option is mutually exclusive with -c.

--- usr.sbin.yp_mkdb.c.diff begins here ---
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
--- usr.sbin.yp_mkdb.c.diff ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list