Author: abartlet Date: 2006-01-18 11:25:30 +0000 (Wed, 18 Jan 2006) New Revision: 12997
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=12997 Log: Feed the right event context to libnet in ejsnet and the auth code. This should give better behaviour in SWAT. Fix authentication as Samba, rather than System, users in SWAT. Andrew Bartlett Modified: branches/SAMBA_4_0/source/scripting/ejs/ejsnet.c branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c Changeset: Modified: branches/SAMBA_4_0/source/scripting/ejs/ejsnet.c =================================================================== --- branches/SAMBA_4_0/source/scripting/ejs/ejsnet.c 2006-01-18 11:22:30 UTC (rev 12996) +++ branches/SAMBA_4_0/source/scripting/ejs/ejsnet.c 2006-01-18 11:25:30 UTC (rev 12997) @@ -25,8 +25,8 @@ #include "scripting/ejs/smbcalls.h" #include "scripting/ejs/ejsnet.h" #include "libnet/libnet.h" +#include "events/events.h" - static int ejs_net_userman(MprVarHandle, int, struct MprVar**); static int ejs_net_createuser(MprVarHandle, int, char**); static int ejs_net_deleteuser(MprVarHandle eid, int argc, char **argv); @@ -39,12 +39,22 @@ static int ejs_net_context(MprVarHandle eid, int argc, struct MprVar **argv) { + TALLOC_CTX *event_mem_ctx = talloc_new(mprMemCtx()); struct cli_credentials *creds; struct libnet_context *ctx; struct MprVar obj; + struct event_context *ev; - /* TODO: Need to get the right event context in here */ - ctx = libnet_context_init(NULL); + if (!event_mem_ctx) { + ejsSetErrorMsg(eid, "talloc_new() failed"); + return -1; + } + ev = event_context_find(event_mem_ctx); + ctx = libnet_context_init(ev); + /* IF we generated a new event context, it will be under here, + * and we need it to last as long as the libnet context, so + * make it a child */ + talloc_steal(ctx, event_mem_ctx); if (argc == 0 || (argc == 1 && argv[0]->type == MPR_TYPE_NULL)) { creds = cli_credentials_init(ctx); Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c =================================================================== --- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c 2006-01-18 11:22:30 UTC (rev 12996) +++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c 2006-01-18 11:25:30 UTC (rev 12997) @@ -25,24 +25,24 @@ #include "lib/appweb/ejs/ejs.h" #include "auth/auth.h" #include "scripting/ejs/smbcalls.h" +#include "lib/events/events.h" static int ejs_doauth(MprVarHandle eid, TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, const char *password, const char *domain, const char *workstation, - struct socket_address *remote_host, const char *authtype) + struct socket_address *remote_host, const char **auth_types) { struct auth_usersupplied_info *user_info = NULL; struct auth_serversupplied_info *server_info = NULL; struct auth_session_info *session_info = NULL; struct auth_context *auth_context; struct MprVar *session_info_obj; - const char *auth_types[] = { authtype, NULL }; NTSTATUS nt_status; - /* - darn, we need some way to get the right event_context here - */ - nt_status = auth_context_create(tmp_ctx, auth_types, &auth_context, NULL); + /* Hope we can find the event context somewhere up there... */ + struct event_context *ev = event_context_find(tmp_ctx); + + nt_status = auth_context_create(tmp_ctx, auth_types, &auth_context, ev); if (!NT_STATUS_IS_OK(nt_status)) { mprSetPropertyValue(auth, "result", mprCreateBoolVar(False)); mprSetPropertyValue(auth, "report", mprString("Auth System Failure")); @@ -122,6 +122,7 @@ struct MprVar auth; struct cli_credentials *creds; struct socket_address *remote_host; + const char *auth_types_unix[] = { "unix", NULL }; if (argc != 2 || argv[0]->type != MPR_TYPE_OBJECT || argv[1]->type != MPR_TYPE_OBJECT) { ejsSetErrorMsg(eid, "userAuth invalid arguments, this function requires an object."); @@ -157,9 +158,9 @@ auth = mprObject("auth"); if (domain && (strcmp("SYSTEM USER", domain) == 0)) { - ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, "unix"); + ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, auth_types_unix); } else { - ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, "sam"); + ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, lp_auth_methods()); } mpr_Return(eid, auth);