krb5 commit: Add -p, -F, -K options to kadmind

Greg Hudson ghudson at MIT.EDU
Fri Oct 5 14:37:14 EDT 2012


https://github.com/krb5/krb5/commit/91175a8ba034fa95accb39a5341fd296217e6fed
commit 91175a8ba034fa95accb39a5341fd296217e6fed
Author: Nicolas Williams <nico at cryptonector.com>
Date:   Mon Sep 24 13:38:20 2012 -0500

    Add -p, -F, -K options to kadmind
    
    New options:
    
        -p path-to-kdb5_util
        -K path-to-kprop
        -F dump-file
    
    These are needed for testing without first having to install.
    
    ticket: 7372

 .../krb_admins/admin_commands/kadmind.rst          |   15 +++++++++++
 src/kadmin/server/ipropd_svc.c                     |   27 ++++++++++---------
 src/kadmin/server/ovsec_kadmd.c                    |   21 ++++++++++++++-
 3 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/doc/rst_source/krb_admins/admin_commands/kadmind.rst b/doc/rst_source/krb_admins/admin_commands/kadmind.rst
index 573e7a1..10fc672 100644
--- a/doc/rst_source/krb_admins/admin_commands/kadmind.rst
+++ b/doc/rst_source/krb_admins/admin_commands/kadmind.rst
@@ -13,6 +13,9 @@ SYNOPSIS
 [**-nofork**]
 [**-port** *port-number*]
 [**-P** *pid_file*]
+[**-p** *kdb5_util_path*]
+[**-K** *kprop_path*]
+[**-F** *dump_file*]
 
 DESCRIPTION
 -----------
@@ -82,6 +85,18 @@ OPTIONS
     whether kadmind is still running and to allow init scripts to stop
     the correct process.
 
+**-p** *kdb5_util_path*
+    specifies the path to the kdb5_util command to use when dumping the
+    KDB in response to full resync requests when iprop is enabled.
+
+**-K** *kprop_path*
+    specifies the path to the kprop command to use to send full dumps
+    to slaves in response to full resync requests.
+
+**-F** *dump_file*
+    specifies the file path to be used for dumping the KDB in response
+    to full resync requests when iprop is enabled.
+
 **-x** *db_args*
     specifies database-specific arguments.
 
diff --git a/src/kadmin/server/ipropd_svc.c b/src/kadmin/server/ipropd_svc.c
index ffbd02a..6509474 100644
--- a/src/kadmin/server/ipropd_svc.c
+++ b/src/kadmin/server/ipropd_svc.c
@@ -35,6 +35,9 @@ extern gss_name_t rqst2name(struct svc_req *rqstp);
 extern void *global_server_handle;
 extern int nofork;
 extern short l_port;
+extern char *kdb5_util;
+extern char *kprop;
+extern char *dump_file;
 static char abuf[33];
 
 /* Result is stored in a static buffer and is invalidated by the next call. */
@@ -57,12 +60,12 @@ static char *reply_unknown_str	= "<UNKNOWN_CODE>";
 #ifdef	DPRINT
 #undef	DPRINT
 #endif
-#define	DPRINT(i, ...)		    \
-    do {				  \
-	if (nofork) {		     \
-	    fprintf(stderr, __VA_ARGS__); \
-	    fflush(stderr);	       \
-	}				 \
+#define	DPRINT(i, ...)				\
+    do {					\
+	if (nofork) {				\
+	    fprintf(stderr, __VA_ARGS__);	\
+	    fflush(stderr);			\
+	}					\
     } while (0)
 
 
@@ -351,7 +354,7 @@ ipropx_resync(uint32_t vers, struct svc_req *rqstp)
      * subsequent updates very iprop).
      */
     if (asprintf(&ubuf, "%s dump -i%d -c %s",
-		 KPROPD_DEFAULT_KDB5_UTIL, vers, KPROP_DEFAULT_FILE) < 0) {
+		 kdb5_util, vers, dump_file) < 0) {
 	krb5_klog_syslog(LOG_ERR,
 			 _("%s: cannot construct kdb5 util dump string too long; out of memory"),
 			 whoami);
@@ -406,15 +409,13 @@ ipropx_resync(uint32_t vers, struct svc_req *rqstp)
 	}
 
 	DPRINT("%s: exec `kprop -f %s %s' ...\n",
-		whoami, KPROP_DEFAULT_FILE, clhost);
+		whoami, dump_file, clhost);
 	/* XXX Yuck!  */
 	if (getenv("KPROP_PORT")) {
-	    pret = execl(KPROP_DEFAULT_FILE, "kprop", "-f",
-			 KPROP_DEFAULT_FILE, "-P", getenv("KPROP_PORT"),
-			 clhost, NULL);
+	    pret = execl(kprop, "kprop", "-f", dump_file, "-P",
+			 getenv("KPROP_PORT"), clhost, NULL);
 	} else {
-	    pret = execl(KPROP_DEFAULT_FILE, "kprop", "-f",
-			 KPROP_DEFAULT_FILE, clhost, NULL);
+	    pret = execl(kprop, "kprop", "-f", dump_file, clhost, NULL);
 	}
 	perror(whoami);
 	krb5_klog_syslog(LOG_ERR,
diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c
index b77e765..60a2afb 100644
--- a/src/kadmin/server/ovsec_kadmd.c
+++ b/src/kadmin/server/ovsec_kadmd.c
@@ -108,7 +108,8 @@ static void usage()
 {
     fprintf(stderr, _("Usage: kadmind [-x db_args]* [-r realm] [-m] [-nofork] "
                       "[-port port-number]\n"
-                      "\t\t[-P pid_file]\n"
+                      "\t\t[-p path-to-kdb5_util] [-F dump-file]\n"
+                      "\t\t[-K path-to-kprop] [-P pid_file]\n"
                       "\nwhere,\n\t[-x db_args]* - any number of database "
                       "specific arguments.\n"
                       "\t\t\tLook at each database documentation for "
@@ -203,6 +204,9 @@ static krb5_context context;
 static krb5_context hctx;
 
 int nofork = 0;
+char *kdb5_util = KPROPD_DEFAULT_KDB5_UTIL;
+char *kprop = KPROPD_DEFAULT_KPROP;
+char *dump_file = KPROP_DEFAULT_FILE;
 
 int main(int argc, char *argv[])
 {
@@ -299,6 +303,21 @@ int main(int argc, char *argv[])
             pid_file = *argv;
         } else if (strcmp(*argv, "-W") == 0) {
             strong_random = 0;
+        } else if (strcmp(*argv, "-p") == 0) {
+            argc--; argv++;
+            if (!argc)
+                usage();
+            kdb5_util = *argv;
+        } else if (strcmp(*argv, "-F") == 0) {
+            argc--; argv++;
+            if (!argc)
+                usage();
+            dump_file = *argv;
+        } else if (strcmp(*argv, "-K") == 0) {
+            argc--; argv++;
+            if (!argc)
+                usage();
+            kprop = *argv;
         } else
             break;
         argc--; argv++;


More information about the cvs-krb5 mailing list