Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv22716

Modified Files:
        merovingian.mx 
Log Message:
Do not attempt to start a server if the .vaultkey is missing, because it
simply cannot work.  This way it is properly communicated to the user
that the configuration is wrong, instead of just that it "crashed during
startup".


U merovingian.mx
Index: merovingian.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian.mx,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- merovingian.mx      12 Oct 2008 15:43:31 -0000      1.62
+++ merovingian.mx      26 Oct 2008 08:09:26 -0000      1.63
@@ -62,6 +62,7 @@
 #include <stdarg.h>    /* variadic stuff */
 #include <stdio.h> /* fprintf */
 #include <sys/types.h>
+#include <sys/stat.h> /* stat */
 #include <sys/wait.h> /* wait */
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -363,6 +364,8 @@
        int pfdo[2];
        int pfde[2];
        dpair dp = topdp;
+       str vaultkey = NULL;
+       struct stat statbuf;
 
        er = SABAOTHgetStatus(stats, database);
        if (er != MAL_SUCCEED) {
@@ -463,6 +466,18 @@
        if ((*stats)->locked == 1 && force == 1)
                merlog("startup of database under maintenance '%s' forced", 
database);
 
+       /* check if the vaultkey is there, otherwise abort early (value
+        * lateron reused when server is started) */
+       vaultkey = alloca(sizeof(char) * 512);
+       snprintf(vaultkey, 511, "%s/.vaultkey", (*stats)->path);
+       if (stat(vaultkey, &statbuf) == -1) {
+               SABAOTHfreeStatus(stats);
+               *stats = NULL;
+               return(newErr("cannot start database '%s': no .vaultkey found "
+                                       "(did you create the database with 
`monetdb create %s`?)",
+                                       database, database));
+       }
+
        /* create the pipes (filedescriptors) now, such that we and the
         * child have the same descriptor set */
        if (pipe(pfdo) == -1) {
@@ -482,7 +497,6 @@
        if (pid == 0) {
                str conffile = alloca(sizeof(char) * 512);
                str dbname = alloca(sizeof(char) * 512);
-               str vaultkey = alloca(sizeof(char) * 512);
                str argv[13];   /* for the exec arguments */
                int c = 0;
 


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to