{ "config", required_argument, 0, 'c' },
{ "debug", no_argument, 0, 'd' },
{ "local", no_argument, 0, 'l' },
+ { "no-per-user-config", no_argument, 0, 'N' },
{ "help-commands", no_argument, 0, 'H' },
+ { "user", required_argument, 0, 'u' },
+ { "password", required_argument, 0, 'p' },
{ 0, 0, 0, 0 }
};
/* display version number and terminate */
static void version(void) {
- xprintf("disorder version %s\n", disorder_version_string);
+ xprintf("%s", disorder_version_string);
xfclose(stdout);
exit(0);
}
return s[0] == '/';
}
-static void cf_authorize(disorder_client attribute((unused)) *c,
+static void cf_authorize(disorder_client *c,
char **argv) {
- if(!authorize(argv[0]))
+ if(!authorize(c, argv[0]))
auto_reconfigure = 1;
}
xprintf("address: %s\nport: %s\n", address, port);
}
+static void cf_adduser(disorder_client *c,
+ char **argv) {
+ if(disorder_adduser(c, argv[0], argv[1]))
+ exit(EXIT_FAILURE);
+}
+
static const struct command {
const char *name;
int min, max;
int (*isarg)(const char *);
const char *argstr, *desc;
} commands[] = {
+ { "adduser", 2, 2, cf_adduser, 0, "USER PASSWORD",
+ "Create a new user" },
{ "allfiles", 1, 2, cf_allfiles, isarg_regexp, "DIR [~REGEXP]",
"List all files and directories in DIR" },
{ "authorize", 1, 1, cf_authorize, 0, "USER",
disorder_client *c = 0;
int status = 0;
struct vector args;
+ const char *user = 0, *password = 0;
mem_init();
/* garbage-collect PCRE's memory */
pcre_malloc = xmalloc;
pcre_free = xfree;
if(!setlocale(LC_CTYPE, "")) fatal(errno, "error calling setlocale");
- while((n = getopt_long(argc, argv, "hVc:dHl", options, 0)) >= 0) {
+ while((n = getopt_long(argc, argv, "hVc:dHlNu:p:", options, 0)) >= 0) {
switch(n) {
case 'h': help();
case 'H': help_commands();
case 'c': configfile = optarg; break;
case 'd': debugging = 1; break;
case 'l': local = 1; break;
+ case 'N': config_per_user = 0; break;
+ case 'u': user = optarg; break;
+ case 'p': password = optarg; break;
default: fatal(0, "invalid option");
}
}
if(config_read(0)) fatal(0, "cannot read configuration");
+ if(user) {
+ config->username = user;
+ config->password = 0;
+ }
+ if(password)
+ config->password = password;
if(local)
config->connect.n = 0;
if(!(c = disorder_new(1))) exit(EXIT_FAILURE);