Skip to content

Commit 0653904

Browse files
committed
flux-keygen: add --name option
Problem: flux-keygen always uses the hostname for the certificate 'name' metadata, but this name is logged when a peer tries to authenticate. In a system instance, these log messages can be confusing since the peer is likely not the host that generated the certificate. Add -n,--name option which allows the certificate name to be set on the command line.
1 parent acd7eb2 commit 0653904

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cmd/flux-keygen.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include "src/common/libutil/log.h"
2020

2121
static struct optparse_option opts[] = {
22+
{ .name = "name", .key = 'n', .has_arg = 1, .arginfo = "NAME",
23+
.usage = "Set certificate name (default: hostname)", },
2224
OPTPARSE_TABLE_END,
2325
};
2426

@@ -67,7 +69,8 @@ int main (int argc, char *argv[])
6769
if (gethostname (buf, sizeof (buf)) < 0)
6870
log_err_exit ("gethostname");
6971
zcert_set_meta (cert, "hostname", "%s", buf);
70-
zcert_set_meta (cert, "name", "%s", buf); // used in overlay logging
72+
// name is used in overlay logging
73+
zcert_set_meta (cert, "name", "%s", optparse_get_str (p, "name", buf));
7174
zcert_set_meta (cert, "time", "%s", ctime_iso8601_now (buf, sizeof (buf)));
7275
zcert_set_meta (cert, "userid", "%d", getuid ());
7376

0 commit comments

Comments
 (0)