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

Modified Files:
        control.c control.h monetdb.c 
Log Message:
prepare for TCP connections

U control.h
Index: control.h
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/control.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- control.h   23 Sep 2009 11:41:51 -0000      1.3
+++ control.h   23 Sep 2009 12:41:02 -0000      1.4
@@ -26,7 +26,8 @@
                int port,
                char* database,
                char* command,
-               char wait);
+               char wait,
+               char* pass);
 char* control_hash(char *pass, char *salt);
 
 #endif

U control.c
Index: control.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/control.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- control.c   23 Sep 2009 12:16:38 -0000      1.5
+++ control.c   23 Sep 2009 12:41:02 -0000      1.6
@@ -18,6 +18,7 @@
  */
 
 #include "sql_config.h"
+#include "control.h"
 #include <stdio.h>
 #include <stdlib.h> /* malloc, realloc */
 #include <unistd.h> /* close */
@@ -47,7 +48,8 @@
                int port,
                char* database,
                char* command,
-               char wait)
+               char wait,
+               char* pass)
 {
        char sbuf[8096];
        char *buf;
@@ -93,6 +95,32 @@
                        snprintf(sbuf, sizeof(sbuf), "cannot connect: %s", 
strerror(errno));
                        return(strdup(sbuf));
                }
+               
+               /* perform login ritual */
+               if ((len = recv(sock, sbuf, sizeof(sbuf), 0)) <= 0) {
+                       snprintf(sbuf, sizeof(sbuf), "no response from 
merovingian");
+                       return(strdup(sbuf));
+               }
+               /* we only understand merovingian:1 */
+               if (strncmp(sbuf, "merovingian:1:", strlen("merovingian:1:")) 
!= 0) {
+                       snprintf(sbuf, sizeof(sbuf), "unsupported merovingian 
server");
+                       return(strdup(sbuf));
+               }
+               buf = strchr(sbuf + strlen("merovingian:1:"), ':');
+               if (buf != NULL)
+                       *buf = '\0';
+               buf = sbuf + strlen("merovingian:1:");
+
+               buf = control_hash(pass, buf);
+
+               len = snprintf(sbuf, sizeof(sbuf), "%s\n", buf);
+               send(sock, sbuf, len, 0);
+
+               if ((len = recv(sock, sbuf, sizeof(sbuf), 0)) <= 0)
+                       return(strdup("no response from merovingian"));
+               sbuf[len - 1] = '\0';
+               if (strcmp(sbuf, "OK") != 0)
+                       return(strdup(sbuf));
        }
 
        len = snprintf(sbuf, sizeof(sbuf), "%s %s\n", database, command);

U monetdb.c
Index: monetdb.c
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/merovingian/monetdb.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- monetdb.c   22 Sep 2009 18:03:31 -0000      1.60
+++ monetdb.c   23 Sep 2009 12:41:02 -0000      1.61
@@ -206,7 +206,7 @@
                        fflush(stdout);
                }
 
-               ret = control_send(&out, mero_control, -1, argv[i], merocmd, 0);
+               ret = control_send(&out, mero_control, -1, argv[i], merocmd, 0, 
NULL);
 
                if (ret != NULL) {
                        if (premsg != NULL)
@@ -290,9 +290,9 @@
        if (database == NULL) {
                /* I ran out of creative ideas on this one, so I just injected
                 * the last(?) sight we might see from van der Decken */
-               e = control_send(&buf, mero_control, -1, "flyghende", 
"hollander", 1);
+               e = control_send(&buf, mero_control, -1, "flyghende", 
"hollander", 1, NULL);
        } else {
-               e = control_send(&buf, mero_control, -1, database, "status", 0);
+               e = control_send(&buf, mero_control, -1, database, "status", 0, 
NULL);
        }
        if (e != NULL)
                return(e);
@@ -722,7 +722,7 @@
         * merovingian.  Anelosimus eximius is a social species of spiders,
         * which help each other, just like merovingians do among each
         * other. */
-       p = control_send(&buf, mero_control, -1, "anelosimus", "eximius", 1);
+       p = control_send(&buf, mero_control, -1, "anelosimus", "eximius", 1, 
NULL);
        if (p != NULL) {
                printf("%s: %s\n", argv[0], p);
                free(p);
@@ -967,7 +967,7 @@
                        exit(1);
                }
 
-               out = control_send(&res, mero_control, -1, argv[2], p, 0);
+               out = control_send(&res, mero_control, -1, argv[2], p, 0, NULL);
                if (out != NULL || strcmp(res, "OK") != 0) {
                        res = out == NULL ? res : out;
                        fprintf(stderr, "%s: %s\n", argv[0], res);
@@ -987,7 +987,7 @@
                        strncat(property, "=", sizeof(property));
                        p = property;
                }
-               out = control_send(&res, mero_control, 0, argv[i], p, 0);
+               out = control_send(&res, mero_control, 0, argv[i], p, 0, NULL);
                if (out != NULL || strcmp(res, "OK") != 0) {
                        res = out == NULL ? res : out;
                        fprintf(stderr, "%s: %s\n", argv[0], res);
@@ -1114,7 +1114,7 @@
                                value = stats->dbname;
                        } else {
                                char *buf;
-                               e = control_send(&buf, mero_control, -1, 
stats->dbname, "get", 1);
+                               e = control_send(&buf, mero_control, -1, 
stats->dbname, "get", 1, NULL);
                                if (e != NULL) {
                                        fprintf(stderr, "get: internal error: 
%s\n", e);
                                        free(e);


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to