Changeset: a302d016b72c for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a302d016b72c Modified Files: tools/merovingian/ChangeLog tools/merovingian/daemon/argvcmds.c tools/merovingian/daemon/merovingian.c tools/merovingian/daemon/monetdbd.1.in Branch: default Log Message:
merovingian: make providing dbfarm mandatory for all commands The dbfarm now has to be provided to each invocation of monetdbd explicitly. This avoids confusion. diffs (254 lines): diff --git a/tools/merovingian/ChangeLog b/tools/merovingian/ChangeLog --- a/tools/merovingian/ChangeLog +++ b/tools/merovingian/ChangeLog @@ -2,6 +2,8 @@ # This file is updated with mchangelog * Wed Aug 31 2011 Fabian Groffen <[email protected]> +- Starting monetdbd without any arguments or without dbfarm is no longer + supported. A dbfarm now must be provided for each command. - The control passphrase has been turned into a hash of the password, for a more stronger authorisation model as used by mclients. On upgrade, any existing passphrase is converted to the hashed version of the diff --git a/tools/merovingian/daemon/argvcmds.c b/tools/merovingian/daemon/argvcmds.c --- a/tools/merovingian/daemon/argvcmds.c +++ b/tools/merovingian/daemon/argvcmds.c @@ -53,23 +53,20 @@ command_help(int argc, char *argv[]) printf(" must be a path in the filesystem where a directory can be\n"); printf(" created, or a directory that is writable that already exists.\n"); } else if (strcmp(argv[1], "start") == 0) { - printf("usage: monetdbd start [-n] [dbfarm]\n"); - printf(" Starts the monetdbd deamon. When no dbfarm given, it starts\n"); - printf(" in the default dbfarm (%s).\n", LOCALSTATEDIR "/monetdb5/dbfarm"); + printf("usage: monetdbd start [-n] <dbfarm>\n"); + printf(" Starts the monetdbd deamon for the given dbfarm.\n"); printf(" When -n is given, monetdbd will not fork into the background."); } else if (strcmp(argv[1], "stop") == 0) { - printf("usage: monetdbd stop [dbfarm]\n"); - printf(" Stops a running monetdbd deamon for the given dbfarm, or\n"); - printf(" when none given, the default one (%s).\n", LOCALSTATEDIR "/monetdb5/dbfarm"); + printf("usage: monetdbd stop <dbfarm>\n"); + printf(" Stops a running monetdbd deamon for the given dbfarm.\n"); } else if (strcmp(argv[1], "set") == 0) { - printf("usage: monetdbd set property=value [dbfarm]\n"); - printf(" Sets property to value for the given dbfarm, or when\n"); - printf(" absent, the default (%s).\n", LOCALSTATEDIR "/monetdb5/dbfarm"); + printf("usage: monetdbd set property=value <dbfarm>\n"); + printf(" Sets property to value for the given dbfarm.\n"); printf(" For a list of properties, use `monetdbd get all`\n"); } else if (strcmp(argv[1], "get") == 0) { - printf("usage: monetdbd get <\"all\" | property,...> [dbfarm]\n"); + printf("usage: monetdbd get <\"all\" | property,...> <dbfarm>\n"); printf(" Gets value for property for the given dbfarm, or\n"); - printf(" retrieves all properties for the given dbfarm\n"); + printf(" retrieves all properties.\n"); } else { printf("help: unknown command: %s\n", argv[1]); exitcode = 1; @@ -130,8 +127,8 @@ command_create(int argc, char *argv[]) return(1); } - phrase[0].key = "passphrase"; - phrase[0].val = NULL; + phrase[0].key = "control"; + phrase[0].val = "false"; phrase[1].key = NULL; if (writeProps(phrase, dbfarm) != 0) { fprintf(stderr, "unable to create file in directory '%s': %s\n", @@ -146,7 +143,7 @@ int command_get(confkeyval *ckv, int argc, char *argv[]) { char *p; - char *dbfarm = LOCALSTATEDIR "/monetdb5/dbfarm"; + char *dbfarm; char *property = NULL; char *value; char buf[512]; @@ -154,13 +151,12 @@ command_get(confkeyval *ckv, int argc, c confkeyval *kv; int meropid = -1; - if (argc < 2 || argc > 3) { + if (argc != 3) { command_help(2, &argv[-1]); return(1); } - if (argc == 3) - dbfarm = argv[2]; + dbfarm = argv[2]; /* read the merovingian properties from the dbfarm */ if (readProps(ckv, dbfarm) != 0) { @@ -279,19 +275,18 @@ command_set(confkeyval *ckv, int argc, c char *p = NULL; char h[256]; char *property; - char *dbfarm = LOCALSTATEDIR "/monetdb5/dbfarm"; + char *dbfarm; confkeyval *kv; FILE *pfile = NULL; char buf[8]; pid_t meropid; - if (argc < 2 || argc > 3) { + if (argc != 3) { command_help(2, &argv[-1]); return(1); } - if (argc == 3) - dbfarm = argv[2]; + dbfarm = argv[2]; /* read the merovingian properties from the dbfarm */ if (readProps(ckv, dbfarm) != 0) { @@ -394,19 +389,18 @@ command_set(confkeyval *ckv, int argc, c int command_stop(confkeyval *ckv, int argc, char *argv[]) { - char *dbfarm = LOCALSTATEDIR "/monetdb5/dbfarm"; + char *dbfarm; char *pidfilename = NULL; FILE *pfile = NULL; char buf[8]; pid_t daemon; - if (argc > 2) { + if (argc != 2) { command_help(2, &argv[-1]); return(1); } - if (argc == 2) - dbfarm = argv[1]; + dbfarm = argv[1]; /* read the merovingian properties from the dbfarm */ if (readProps(ckv, dbfarm) != 0) { diff --git a/tools/merovingian/daemon/merovingian.c b/tools/merovingian/daemon/merovingian.c --- a/tools/merovingian/daemon/merovingian.c +++ b/tools/merovingian/daemon/merovingian.c @@ -615,15 +615,7 @@ main(int argc, char *argv[]) kv = findConfKey(_mero_db_props, "readonly"); kv->val = strdup("no"); - /* in case of no arguments, we act backwards compatible: start - * merovingian in the hardwired dbfarm location */ - if (sizeof(LOCALSTATEDIR "/monetdb5/dbfarm") >= sizeof(dbfarm)) { - Mfprintf(stderr, "fatal: compiled in dbfarm location exceeds " \ - "allocated path length, please file a bug at " \ - "http://bugs.monetdb.org/\n"); - exit(1); - } - snprintf(dbfarm, sizeof(dbfarm), "%s", LOCALSTATEDIR "/monetdb5/dbfarm"); + *dbfarm = '\0'; if (argc > 1) { if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 || @@ -642,10 +634,9 @@ main(int argc, char *argv[]) } else if (strcmp(argv[1], "set") == 0) { exit(command_set(ckv, argc - 1, &argv[1])); } else if (strcmp(argv[1], "start") == 0) { - /* start without path argument just means start hardwired dbfarm */ - if (argc > 2 && strcmp(argv[2], "-n") == 0) + if (argc > 3 && strcmp(argv[2], "-n") == 0) merodontfork = 1; - if (argc > 2 + merodontfork) { + if (argc == 3 + merodontfork) { int len; len = snprintf(dbfarm, sizeof(dbfarm), "%s", argv[2 + merodontfork]); @@ -656,6 +647,9 @@ main(int argc, char *argv[]) "http://bugs.monetdb.org/\n"); exit(1); } + } else { + command_help(argc, argv); + exit(1); } } else if (strcmp(argv[1], "stop") == 0) { exit(command_stop(ckv, argc - 1, &argv[1])); @@ -664,8 +658,13 @@ main(int argc, char *argv[]) command_help(0, NULL); exit(1); } + } else { + command_help(0, NULL); + exit(1); } + assert(*dbfarm != '\0'); + /* fork into background before doing anything more */ if (!merodontfork) { char buf[4]; diff --git a/tools/merovingian/daemon/monetdbd.1.in b/tools/merovingian/daemon/monetdbd.1.in --- a/tools/merovingian/daemon/monetdbd.1.in +++ b/tools/merovingian/daemon/monetdbd.1.in @@ -6,7 +6,7 @@ monetdbd \- the MonetDB Database Server daemon .SH SYNOPSIS .B monetdbd -[command [command_args] [dbfarm]] +command [command_args] dbfarm .SH DESCRIPTION .B monetdbd is the MonetDB Database Server daemon. The program is mainly meant to @@ -39,11 +39,9 @@ A instance manages one local cluster based, which is a directory in the system, referred to as the .IR dbfarm . -Nowadays, it is preferred to always give the dbfarm location as argument +Nowadays, the dbfarm location always has to be given as argument to .BR monetdbd . -For system-wide installs, the default dbfarm location is set to -@Elocalstatedir@/monetdb5/dbfarm. .P Within its local cluster .B monetdbd @@ -90,33 +88,32 @@ be created, and an initial properties fi itself. .I dbfarm must be a location addressable in the local filesystem hierarchy. -.IP "start [-n] [dbfarm]" +.IP "start [-n] <dbfarm>" Starts .BR monetdbd , -the MonetDB Database Server, on the given dbfarm, or its default, the -system-wide location @Elocalstatedir@/monetdb5/dbfarm. When the +the MonetDB Database Server, on the given dbfarm. When the .I -n flag is given, .B monetdbd will not fork into the background, but instead remain attached to the calling environment, until given a stop signal. -.IP "stop [dbfarm]" +.IP "stop <dbfarm>" Sends a stop signal to the .B monetdbd -process responsible for the given dbfarm, or the default system-wide -location @Elocalstatedir@/monetdb5/dbfarm. -.IP "get <all | property[,property[,..]]> [dbfarm]" +process responsible for the given dbfarm. +.IP "get <all | property[,property[,..]]> <dbfarm>" Prints the requested properties, or all known properties, for the given -database. For each property and its value are printed. Some properties +dbfarm. For each property, its value is printed. Some properties are virtual, and given for information purposes only, they cannot be modified using the .I set command. -.IP "set property=value [dbfarm]" +.IP "set property=value <dbfarm>" Sets property to value for the given database. For a list of properties, run .BR "monetdbd get all" . -Most properties require a restart of the MonetDB Database Server. The +Some properties require a restart of the MonetDB Database Server in +order to take effect. The .I set command, will however always write the property, and tell the running .B monetdbd _______________________________________________ Checkin-list mailing list [email protected] http://mail.monetdb.org/mailman/listinfo/checkin-list
