Skip to content

Commit

Permalink
Add -p, -F, -K options to kadmind
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicowilliams authored and greghudson committed Oct 5, 2012
1 parent cea0b28 commit 91175a8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 14 deletions.
15 changes: 15 additions & 0 deletions doc/rst_source/krb_admins/admin_commands/kadmind.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ SYNOPSIS
[**-nofork**]
[**-port** *port-number*]
[**-P** *pid_file*]
[**-p** *kdb5_util_path*]
[**-K** *kprop_path*]
[**-F** *dump_file*]

DESCRIPTION
-----------
Expand Down Expand Up @@ -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.

Expand Down
27 changes: 14 additions & 13 deletions src/kadmin/server/ipropd_svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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)


Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 20 additions & 1 deletion src/kadmin/server/ovsec_kadmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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[])
{
Expand Down Expand Up @@ -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++;
Expand Down

0 comments on commit 91175a8

Please sign in to comment.