svn commit: samba r8629 - in branches/SAMBA_4_0: source/scripting/ejs source/scripting/libjs swat

tridge at samba.org tridge at samba.org
Wed Jul 20 04:27:09 GMT 2005


Author: tridge
Date: 2005-07-20 04:27:09 +0000 (Wed, 20 Jul 2005)
New Revision: 8629

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8629

Log:
- moved the getDomainList() call out of smbcalls_auth.c and into libjs/auth.js

- tried to make the ejs_userAuth() call work for the sam, not just for
  unix auth. I didn't get this working. Andrew, when you get a chance
  can you see what I'm doing wrong? I suspect its because we aren't
  supplying a challenge, but a challenge doesn't really make sense in a
  'is this username/password' correct call.

Added:
   branches/SAMBA_4_0/source/scripting/libjs/auth.js
Modified:
   branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c
   branches/SAMBA_4_0/swat/login.esp


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c
===================================================================
--- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c	2005-07-20 04:21:10 UTC (rev 8628)
+++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_auth.c	2005-07-20 04:27:09 UTC (rev 8629)
@@ -26,19 +26,21 @@
 #include "auth/auth.h"
 #include "scripting/ejs/smbcalls.h"
 
-static int ejs_systemAuth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, const char *password, const char *domain, const char *remote_host)
+static int ejs_doauth(TALLOC_CTX *tmp_ctx, struct MprVar *auth, const char *username, 
+		      const char *password, const char *domain, const char *remote_host,
+		      const char *authtype)
 {
 	struct auth_usersupplied_info *user_info = NULL;
 	struct auth_serversupplied_info *server_info = NULL;
 	struct auth_context *auth_context;
-	const char *auth_unix[] = { "unix", NULL };
+	const char *auth_types[] = { authtype, NULL };
 	NTSTATUS nt_status;
 	DATA_BLOB pw_blob;
 
 	/*
 	  darn, we need some way to get the right event_context here
 	*/
-	nt_status = auth_context_create(tmp_ctx, auth_unix, &auth_context, NULL);
+	nt_status = auth_context_create(tmp_ctx, auth_types, &auth_context, NULL);
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
 		mprSetPropertyValue(auth, "report", mprString("Auth System Failure"));
@@ -104,12 +106,9 @@
 	auth = mprObject("auth");
 
 	if (domain && strcmp("System User", domain) == 0) {
-
-		ejs_systemAuth(tmp_ctx, &auth, username, password, domain, remote_host);
-	}  else {
-
-		mprSetPropertyValue(&auth, "result", mprCreateBoolVar(False));
-		mprSetPropertyValue(&auth, "report", mprString("Unknown Domain"));
+		ejs_doauth(tmp_ctx, &auth, username, password, domain, remote_host, "unix");
+	} else {
+		ejs_doauth(tmp_ctx, &auth, username, password, domain, remote_host, "sam");
 	}
 
 	mpr_Return(eid, auth);
@@ -117,28 +116,10 @@
 	return 0;
 }
 
-static int ejs_domain_list(MprVarHandle eid, int argc, char **argv)
-{
-	struct MprVar list;
-
-	if (argc != 0) {
-		ejsSetErrorMsg(eid, "domList invalid arguments");
-		return -1;
-	}
-
-	list = mprObject("list");
-	mprSetVar(&list, "0", mprString("System User"));
-
-	mpr_Return(eid, list);
-
-	return 0;
-}
-
 /*
   setup C functions that be called from ejs
 */
 void smb_setup_ejs_auth(void)
 {
-	ejsDefineStringCFunction(-1, "getDomainList", ejs_domain_list, NULL, MPR_VAR_SCRIPT_HANDLE);
 	ejsDefineCFunction(-1, "userAuth", ejs_userAuth, NULL, MPR_VAR_SCRIPT_HANDLE);
 }

Added: branches/SAMBA_4_0/source/scripting/libjs/auth.js
===================================================================
--- branches/SAMBA_4_0/source/scripting/libjs/auth.js	2005-07-20 04:21:10 UTC (rev 8628)
+++ branches/SAMBA_4_0/source/scripting/libjs/auth.js	2005-07-20 04:27:09 UTC (rev 8629)
@@ -0,0 +1,17 @@
+/*
+	auth js library functions
+	Copyright Andrew Tridgell 2005
+	released under the GNU GPL v2 or later
+*/
+
+
+/*
+  get a list of domains for SWAT authentication
+*/
+function getDomainList()
+{
+	var ret = new Array(2);
+	ret[0] = "System User";
+	ret[1] = lpGet("workgroup");
+	return ret;
+}

Modified: branches/SAMBA_4_0/swat/login.esp
===================================================================
--- branches/SAMBA_4_0/swat/login.esp	2005-07-20 04:21:10 UTC (rev 8628)
+++ branches/SAMBA_4_0/swat/login.esp	2005-07-20 04:27:09 UTC (rev 8629)
@@ -1,7 +1,6 @@
-<% page_header("plain", "SWAT Login", ""); %>
+<% page_header("plain", "SWAT Login", "");
+   libinclude("auth.js");
 
-<%
-
 if (request['SESSION_EXPIRED'] == "True") {
    write("<b>Your session has expired - please authenticate again<br /></b>\n");
 }



More information about the samba-cvs mailing list