auth: standardize on -n/--name [type.]name

This commit is contained in:
Sage Weil 2010-03-26 16:04:26 -07:00
parent c6028ae024
commit 848caaf05f
2 changed files with 19 additions and 12 deletions

View File

@ -44,19 +44,17 @@ int main(int argc, const char **argv)
bool list = false;
bool print_key = false;
bool create_keyring = false;
const char *name = "";
const char *caps_fn = NULL;
const char *import_keyring = NULL;
bool set_auid = false;
__u64 auid = CEPH_AUTH_UID_DEFAULT;
const char *name = g_conf.name;
FOR_EACH_ARG(args) {
if (CONF_ARG_EQ("gen-key", 'g')) {
CONF_SAFE_SET_ARG_VAL(&gen_key, OPT_BOOL);
} else if (CONF_ARG_EQ("add-key", 'a')) {
CONF_SAFE_SET_ARG_VAL(&add_key, OPT_STR);
} else if (CONF_ARG_EQ("name", 'n')) {
CONF_SAFE_SET_ARG_VAL(&name, OPT_STR);
} else if (CONF_ARG_EQ("list", 'l')) {
CONF_SAFE_SET_ARG_VAL(&list, OPT_BOOL);
} else if (CONF_ARG_EQ("caps", '\0')) {

View File

@ -1005,9 +1005,9 @@ void parse_startup_config_options(std::vector<const char*>& args, bool isdaemon,
} else if (isdaemon && CONF_ARG_EQ("foreground", 'f')) {
g_conf.daemonize = false;
g_conf.log_to_stdout = false;
} else if (isdaemon && CONF_ARG_EQ("id", 'i')) {
} else if (isdaemon && (CONF_ARG_EQ("id", 'i') || CONF_ARG_EQ("name", 'n'))) {
CONF_SAFE_SET_ARG_VAL(&g_conf.id, OPT_STR);
} else if (!isdaemon && CONF_ARG_EQ("id", 'I')) {
} else if (!isdaemon && (CONF_ARG_EQ("id", 'I') || CONF_ARG_EQ("name", 'n'))) {
CONF_SAFE_SET_ARG_VAL(&g_conf.id, OPT_STR);
} else {
nargs.push_back(args[i]);
@ -1018,15 +1018,24 @@ void parse_startup_config_options(std::vector<const char*>& args, bool isdaemon,
if (module_type) {
g_conf.type = strdup(module_type);
if (g_conf.id) {
int len = strlen(module_type) + strlen(g_conf.id) + 2;
g_conf.name = (char *)malloc(len);
snprintf(g_conf.name, len, "%s.%s", g_conf.type, g_conf.id);
g_conf.alt_name = (char *)malloc(len - 1);
snprintf(g_conf.alt_name, len - 1, "%s%s", module_type, g_conf.id);
// is it "type.name"?
const char *dot = strchr(g_conf.id, '.');
if (dot) {
int tlen = dot - g_conf.id;
g_conf.type = (char *)malloc(tlen + 1);
memcpy(g_conf.type, g_conf.id, tlen);
g_conf.type[tlen] = 0;
g_conf.id = strdup(dot + 1);
}
int len = strlen(g_conf.type) + strlen(g_conf.id) + 2;
g_conf.name = (char *)malloc(len);
snprintf(g_conf.name, len, "%s.%s", g_conf.type, g_conf.id);
g_conf.alt_name = (char *)malloc(len - 1);
snprintf(g_conf.alt_name, len - 1, "%s%s", module_type, g_conf.id);
} else {
g_conf.name = g_conf.type;
g_conf.name = g_conf.type;
}
}
g_conf.entity_name = new EntityName;