[MonetDB-users] MCinitClient() and user oid.
Hi. I've been trying to get access to the Client structures on the server side. I've therefore been looking at MCinitClient(). What I do not understand is how do you know which oid for the user you should pick, in order to pass this oid as an argument to MCinitClient.
http://yziquel.homelinux.org/topos/api/ocaml-monetdb5/MonetDB5.MAL.Client.ht...
Client MCinitClient(oid user, bstream *fin, stream *fout)
Moreover, it seems to me that in an embedded setting, it doesn't seem to be a smart idea to use MCinitClient. It would perhaps be better to grab the already existing Client structure for the admin. Probably with MCfindClient.
http://yziquel.homelinux.org/topos/api/ocaml-monetdb5/MonetDB5.MAL.Client.ht...
Client MCfindClient(oid user, str scen, bstream *fin, stream *fout)
fin and fout seem optional arguments (meaning you can pass NULL for sensible defaults). But as before, the oid of the user, and the sceanrio string are arguments whose proposed values are unclear to me. How do you get the admin's Client struct? All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
On 02-02-2010 00:01:31 +0100, Guillaume Yziquel wrote:
fin and fout seem optional arguments (meaning you can pass NULL for sensible defaults). But as before, the oid of the user, and the sceanrio string are arguments whose proposed values are unclear to me.
scenario is like language, e.g. mal or sql, but I doubt if you should really be using this function at all.
Fabian Groffen a écrit :
On 02-02-2010 00:01:31 +0100, Guillaume Yziquel wrote:
fin and fout seem optional arguments (meaning you can pass NULL for sensible defaults). But as before, the oid of the user, and the sceanrio string are arguments whose proposed values are unclear to me.
scenario is like language, e.g. mal or sql, but I doubt if you should really be using this function at all.
Here's my use case: I want to use MALparse in order to compile MAL from OCaml. (I want to do some rather involved stuff using Camlp4 to extend the syntax definition accepted by the OCaml compiler). And I need to pass a Client as argument to MALparse. The Mapi interface doesn't provide a way to grab Client structs. (It is clearly not its purpose). Therefore, I need a way to grab a Client struct, and it seems that this is available in mal_client.mx. Then, I do not know how to grab the Client: -1- Inspected the global array of clients? -2- Use MCfindClient? Or MCinitClient? In this last case, how do I know what are the admissible values for oids? That's the kind of issue I have interacting with MonetDB from OCaml. All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
Fabian Groffen a écrit :
On 02-02-2010 00:01:31 +0100, Guillaume Yziquel wrote:
fin and fout seem optional arguments (meaning you can pass NULL for sensible defaults). But as before, the oid of the user, and the sceanrio string are arguments whose proposed values are unclear to me. scenario is like language, e.g. mal or sql, but I doubt if you should really be using this function at all.
Here's my use case:
I want to use MALparse in order to compile MAL from OCaml. (I want to do some rather involved stuff using Camlp4 to extend the syntax definition accepted by the OCaml compiler).
And I need to pass a Client as argument to MALparse.
The Mapi interface doesn't provide a way to grab Client structs. (It is clearly not its purpose). Therefore, I need a way to grab a Client struct, and it seems that this is available in mal_client.mx.
Then, I do not know how to grab the Client:
-1- Inspected the global array of clients?
-2- Use MCfindClient? Or MCinitClient? Since you have found the code to deal with clients, you should have noticed
Guillaume Yziquel wrote: there is a global table of Client records. The first represents the admin. In an embedded setting, you can access it directly and from there you are on your own. However, as mentioned before, in an embedded system you preferrably access the kernel as a normal mclient -lmal user, which ensures proper client admin and handle all the MAL authorization, parsing, admin, and execution. There is no clear application requirement to look and work under the hood. For front-end languages the MAL layer is the abstract machine. Interaction organized through the mapi-interface of ascii text. regards, Martin
In this last case, how do I know what are the admissible values for oids?
That's the kind of issue I have interacting with MonetDB from OCaml.
All the best,
Martin Kersten a écrit :
Guillaume Yziquel wrote:
Here's my use case:
I want to use MALparse in order to compile MAL from OCaml. (I want to do some rather involved stuff using Camlp4 to extend the syntax definition accepted by the OCaml compiler).
And I need to pass a Client as argument to MALparse.
The Mapi interface doesn't provide a way to grab Client structs. (It is clearly not its purpose). Therefore, I need a way to grab a Client struct, and it seems that this is available in mal_client.mx.
Then, I do not know how to grab the Client:
-1- Inspected the global array of clients?
-2- Use MCfindClient? Or MCinitClient?
Since you have found the code to deal with clients, you should have noticed there is a global table of Client records. The first represents the admin. In an embedded setting, you can access it directly and from there you are on your own.
Yes. That's what I'm currently doing. In fact, there's two clients. 1 for the admin, and 1 for the Mapi connection, I guess...
yziquel@seldon:~/git/ocaml-monetdb5$ utils/malclient.native Number of clients: 2
Client idx: 0 Client oid: 0 Client scenario: mal
Client idx: 1 Client oid: 0 Client scenario: mal
However, when inspecting the structs of the clients, I get the above. What I do not understand is whether or not the oids for both clients are supposed to be the same or not. Double-checked my code, and I didn't see any mistake. That's why I'm asking about what these oids are, in ClientRec structs.
However, as mentioned before, in an embedded system you preferrably access the kernel as a normal mclient -lmal user, which ensures proper client admin and handle all the MAL authorization, parsing, admin, and execution.
I understand your point. I'm trying to see to see to which extent my camlp4 project is realistic or not. So far, it seems realistic, even if that implies tinkering at a lower level than mapi.
There is no clear application requirement to look and work under the hood. For front-end languages the MAL layer is the abstract machine. Interaction organized through the mapi-interface of ascii text.
It's the ascii text part that I do not like (for my purposes). I'd want some sort of algebraic datatypes, rather. That's why I'm doing all this. -- Guillaume Yziquel http://yziquel.homelinux.org/
Hi again. Slowly going forward with MAL parsing. But I'm now quite confused: I've been looking at MALparser(), parseMAL() and the different scenario functions in mal_session.mx. However, I do not understand where the result of the parsing is stored. I mean, you compile MAL ASCII to an internal representation, but where is this internal representation located? Where is it explicitely constructed? All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
Guillaume Yziquel a écrit :
Hi again.
Slowly going forward with MAL parsing. But I'm now quite confused: I've been looking at MALparser(), parseMAL() and the different scenario functions in mal_session.mx. However, I do not understand where the result of the parsing is stored. I mean, you compile MAL ASCII to an internal representation, but where is this internal representation located? Where is it explicitely constructed?
All the best,
For the (mailing list's) record, when c is a Client, the internal representation of parsed MAL is located at c->curprg->def. cf. MALengine() in mal_session.mx. All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
Guillaume Yziquel a écrit :
In this last case, how do I know what are the admissible values for oids?
It seems to me that the oids are obtained in the authentication phase. Essentially in AUTHcheckCredentials() in mal_authorize.mx, and specifically in this piece of code (when setting uid*):
if (b && BATcount(b) > 0) { BATiter bi = bat_iterator(b);
if (*scenario == NULL || strNil(*scenario)) { BBPunfix(b->batCacheid); /* of course we DO NOT tell the exact reason here again */ throw(INVCRED, "checkCredentials", INVCRED_INVALID_USER " '%s'",*username); }
/* ok, there are some tuples that we have to consider */ BATloop(b, p, q) { tmp = (str)BUNtail(bi, p); assert (tmp != NULL); if (strcmp(*scenario, tmp) == 0) { /* YAY! fun! party! We are granted access! */ *uid = *id; BBPunfix(b->batCacheid); return(MAL_SUCCEED); } }
BBPunfix(b->batCacheid); /* uh oh... that we made it till here means it's wrong */ throw(INVCRED, "checkCredentials", INVCRED_INVALID_USER " '%s'", *username); } else { /* no scenario restriction applies, so everything is good */ if (b) BBPunfix(b->batCacheid); *uid = *id; return(MAL_SUCCEED); }
In my situation, this authentication is triggered by a MAL call to mal.mapiclient, which under the hood calls MSscheduleClient(), which itself calls AUTHcheckCredentials(). All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
participants (3)
-
Fabian Groffen
-
Guillaume Yziquel
-
Martin Kersten