printf(" -c,--config .... dmlite config file [" DMLITE_CONFIG_DEFAULT "]\n");
printf(" -u,--user ...... user name []\n\n");
printf("COMMANDS are:\n");
- printf(" listusers,lu\n");
- printf(" listgroups,lg\n");
+ printf(" listusers,lu ........... list users\n");
+ printf(" listgroups,lg .......... list groups\n");
+ printf(" deleteuser,du USER ..... delete user\n");
+ printf(" deletegroup,dg GROUP ... delete group\n");
}
}
while (optind < argc) {
- std::string operation;
+ std::string operation, arg;
+ if (optind + 1 < argc) arg = argv[optind + 1];
+ else arg = "";
try {
authn = stack->getAuthn();
uids = authn->getUsers();
for (size_t i = 0; i < uids.size(); i++)
dumpInfo(uids[i].name, uids[i]);
+ printf("\n");
} else if (
strcasecmp(argv[optind], "listgroups") == 0 ||
strcasecmp(argv[optind], "lg") == 0
gids = authn->getGroups();
for (size_t i = 0; i < gids.size(); i++)
dumpInfo(gids[i].name, gids[i]);
+ printf("\n");
+ } else if (
+ strcasecmp(argv[optind], "deleteuser") == 0 ||
+ strcasecmp(argv[optind], "du") == 0
+ ) {
+ operation = "delete user";
+ if (arg.empty()) {
+ printf("Missing argument.\n");
+ usage(argv[0]);
+ return 1;
+ }
+ optind++;
+
+ authn->deleteUser(arg);
+ printf("User '%s' deleted.\n\n", arg.c_str());
+ } else if (
+ strcasecmp(argv[optind], "deletegroup") == 0 ||
+ strcasecmp(argv[optind], "dg") == 0
+ ) {
+ operation = "delete group";
+ if (arg.empty()) {
+ printf("Missing argument.\n");
+ usage(argv[0]);
+ return 1;
+ }
+ optind++;
+
+ authn->deleteGroup(arg);
+ printf("Group '%s' deleted.\n\n", arg.c_str());
} else {
printf("Unknown command.\n");
usage(argv[0]);