mirror of
https://github.com/samba-team/samba.git
synced 2025-11-14 12:23:52 +03:00
r7505: Add more argument forms for session_setup().
Throw an exception if tree connect fails.
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
93eb9afb4d
commit
5b67f2c3d9
@@ -89,7 +89,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv)
|
||||
|
||||
/* Perform a session setup:
|
||||
|
||||
session_setup(conn, "DOMAIN\USERNAME%PASSWORD");
|
||||
session_setup(conn, "DOMAIN\\USERNAME%PASSWORD");
|
||||
session_setup(conn, USERNAME, PASSWORD);
|
||||
session_setup(conn, DOMAIN, USERNAME, PASSWORD);
|
||||
session_setup(conn); // anonymous
|
||||
@@ -149,6 +149,34 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv)
|
||||
cli_credentials_set_password(creds, argv[3]->string,
|
||||
CRED_SPECIFIED);
|
||||
|
||||
} else if (argc == 3) {
|
||||
|
||||
/* USERNAME, PASSWORD form */
|
||||
|
||||
if (!mprVarIsString(argv[1]->type)) {
|
||||
ejsSetErrorMsg(eid, "arg1 must be a string");
|
||||
goto done;
|
||||
}
|
||||
|
||||
cli_credentials_set_username(creds, argv[1]->string,
|
||||
CRED_SPECIFIED);
|
||||
|
||||
if (!mprVarIsString(argv[2]->type)) {
|
||||
|
||||
ejsSetErrorMsg(eid, "arg2 must be a string");
|
||||
goto done;
|
||||
}
|
||||
|
||||
cli_credentials_set_password(creds, argv[2]->string,
|
||||
CRED_SPECIFIED);
|
||||
|
||||
} else if (argc == 2) {
|
||||
|
||||
/* DOMAIN/USERNAME%PASSWORD form */
|
||||
|
||||
cli_credentials_parse_string(creds, argv[1]->string,
|
||||
CRED_SPECIFIED);
|
||||
|
||||
} else {
|
||||
|
||||
/* Anonymous connection */
|
||||
@@ -255,6 +283,11 @@ static int ejs_cli_tcon(MprVarHandle eid, int argc, MprVar **argv)
|
||||
|
||||
status = smb_tree_connect(tree, mem_ctx, &tcon);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
ejsSetErrorMsg(eid, "session setup: %s", nt_errstr(status));
|
||||
return -1;
|
||||
}
|
||||
|
||||
tree->tid = tcon.tconx.out.tid;
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
|
||||
Reference in New Issue
Block a user