summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-01-10 09:21:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:50:01 -0500
commit8f86ddcd930e5f9214777e5b761e6eb1748b8e74 (patch)
tree611d8238a67ac0ba73dad2ecd63bf058cdb74c48 /source4/scripting/ejs
parent4f06be612369862d0005c68c3658c3ed18b7883d (diff)
downloadsamba-8f86ddcd930e5f9214777e5b761e6eb1748b8e74.tar.gz
samba-8f86ddcd930e5f9214777e5b761e6eb1748b8e74.tar.bz2
samba-8f86ddcd930e5f9214777e5b761e6eb1748b8e74.zip
r12819: Fix swat authentication again. We need to pass the socket_address
structure around, so the auth code knows where the request came from. Andrew Bartlett (This used to be commit 7a7b2668c00d4d22bcf8aa3ba256af88f70c38c4)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/smbcalls_auth.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/source4/scripting/ejs/smbcalls_auth.c b/source4/scripting/ejs/smbcalls_auth.c
index c79f2af0ac..a1310ded9c 100644
--- a/source4/scripting/ejs/smbcalls_auth.c
+++ b/source4/scripting/ejs/smbcalls_auth.c
@@ -29,7 +29,7 @@
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,
- const char *authtype)
+ struct socket_address *remote_host, const char *authtype)
{
struct auth_usersupplied_info *user_info = NULL;
struct auth_serversupplied_info *server_info = NULL;
@@ -63,7 +63,7 @@ static int ejs_doauth(MprVarHandle eid,
user_info->workstation_name = workstation;
- user_info->remote_host = NULL;
+ user_info->remote_host = remote_host;
user_info->password_state = AUTH_PASSWORD_PLAIN;
user_info->password.plaintext = talloc_strdup(user_info, password);
@@ -75,7 +75,9 @@ static int ejs_doauth(MprVarHandle eid,
nt_status = auth_check_password(auth_context, tmp_ctx, user_info, &server_info);
if (!NT_STATUS_IS_OK(nt_status)) {
- mprSetPropertyValue(auth, "report", mprString("Login Failed"));
+ mprSetPropertyValue(auth, "report",
+ mprString(talloc_asprintf(mprMemCtx(), "Login Failed: %s",
+ get_friendly_nt_error_msg(nt_status))));
mprSetPropertyValue(auth, "result", mprCreateBoolVar(False));
goto done;
}
@@ -111,8 +113,9 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
const char *workstation;
struct MprVar auth;
struct cli_credentials *creds;
+ struct socket_address *remote_host;
- if (argc != 1 || argv[0]->type != MPR_TYPE_OBJECT) {
+ 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.");
return -1;
}
@@ -120,7 +123,13 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
/* get credential values from credentials object */
creds = mprGetPtr(argv[0], "creds");
if (creds == NULL) {
- ejsSetErrorMsg(eid, "userAuth requires a 'creds' element");
+ ejsSetErrorMsg(eid, "userAuth requires a 'creds' first parameter");
+ return -1;
+ }
+
+ remote_host = mprGetPtr(argv[1], "socket_address");
+ if (remote_host == NULL) {
+ ejsSetErrorMsg(eid, "userAuth requires a socket address second parameter");
return -1;
}
@@ -139,10 +148,10 @@ static int ejs_userAuth(MprVarHandle eid, int argc, struct MprVar **argv)
auth = mprObject("auth");
- if (domain && (strcmp("System User", domain) == 0)) {
- ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, "unix");
+ if (domain && (strcmp("SYSTEM USER", domain) == 0)) {
+ ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, "unix");
} else {
- ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, "sam");
+ ejs_doauth(eid, tmp_ctx, &auth, username, password, domain, workstation, remote_host, "sam");
}
mpr_Return(eid, auth);