summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2005-06-26 05:18:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:18:50 -0500
commit864de2a4ab9ed2cf2f8850516a021973941af87a (patch)
treea81001fdcb4bcd4cee0b6f1de13b9e1008d48cf1 /source4
parent122bb5642cfda604d90acfcb05e43e1c1f68bcea (diff)
downloadsamba-864de2a4ab9ed2cf2f8850516a021973941af87a.tar.gz
samba-864de2a4ab9ed2cf2f8850516a021973941af87a.tar.bz2
samba-864de2a4ab9ed2cf2f8850516a021973941af87a.zip
r7922: Comment out complicated connect/session/tree API for the moment. Replace
with tree_connect() and tree_disconnect() functions. (This used to be commit 9ed763f7fa9e6138d8c1da29c1e0adf2e18cb5e1)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/ejs/smbcalls_cli.c85
1 files changed, 83 insertions, 2 deletions
diff --git a/source4/scripting/ejs/smbcalls_cli.c b/source4/scripting/ejs/smbcalls_cli.c
index f144fd61e5..7a693fc180 100644
--- a/source4/scripting/ejs/smbcalls_cli.c
+++ b/source4/scripting/ejs/smbcalls_cli.c
@@ -22,10 +22,13 @@
#include "includes.h"
#include "lib/ejs/ejs.h"
-#include "librpc/gen_ndr/ndr_nbt.h"
#include "libcli/raw/libcliraw.h"
#include "libcli/composite/composite.h"
+#if 0
+
+#include "librpc/gen_ndr/ndr_nbt.h"
+
/* Connect to a server */
static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv)
@@ -398,15 +401,93 @@ static int ejs_cli_disconnect(MprVarHandle eid, int argc, MprVar **argv)
return 0;
}
+#endif
+
+/* Perform a tree connect:
+
+ tree_handle = tree_connect("\\\\frogurt\\homes", "user%pass");
+ */
+
+static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
+{
+ struct cli_credentials *creds;
+ struct smbcli_tree *tree;
+ const char *hostname, *sharename;
+ NTSTATUS result;
+ TALLOC_CTX *mem_ctx;
+
+ if (argc != 2) {
+ ejsSetErrorMsg(eid, "tree_connect(): invalid number of args");
+ return -1;
+ }
+
+ /* Set up host, share destination */
+
+ mem_ctx = talloc_init(NULL);
+ smbcli_parse_unc(argv[0], mem_ctx, &hostname, &sharename);
+
+ /* Set up credentials */
+
+ creds = cli_credentials_init(NULL);
+ cli_credentials_set_conf(creds);
+ cli_credentials_parse_string(creds, argv[1], CRED_SPECIFIED);
+
+ /* Do connect */
+
+ result = smbcli_tree_full_connection(NULL, &tree, hostname, 0,
+ sharename, "?????", creds, NULL);
+
+ talloc_free(mem_ctx);
+
+ if (!NT_STATUS_IS_OK(result)) {
+ ejsSetReturnValue(eid, mprNTSTATUS(result));
+ return 0;
+ }
+
+ ejsSetReturnValue(eid, mprCreatePtrVar(tree, talloc_get_name(tree)));
+
+ return 0;
+}
+
+/* Perform a tree disconnect:
+
+ tree_disconnect(tree_handle);
+ */
+
+static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv)
+{
+ struct smbcli_tree *tree;
+ NTSTATUS result;
+
+ if (!mprVarIsPtr(argv[0]->type) ||
+ !talloc_check_name(argv[0]->ptr, "struct smbcli_tree")) {
+ ejsSetErrorMsg(eid, "first arg is not a tree handle");
+ return -1;
+ }
+
+ tree = talloc_check_name(argv[0]->ptr, "struct smbcli_tree");
+
+ result = smb_tree_disconnect(tree);
+
+ ejsSetReturnValue(eid, mprNTSTATUS(result));
+
+ return 0;
+}
+
/*
setup C functions that be called from ejs
*/
void smb_setup_ejs_cli(void)
{
+ ejsDefineStringCFunction(-1, "tree_connect", ejs_tree_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
+ ejsDefineCFunction(-1, "tree_disconnect", ejs_tree_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE);
+
+#if 0
ejsDefineStringCFunction(-1, "connect", ejs_cli_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "session_setup", ejs_cli_ssetup, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "tree_connect", ejs_cli_tree_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "tree_disconnect", ejs_cli_tree_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE);
ejsDefineCFunction(-1, "session_logoff", ejs_cli_session_logoff, NULL, MPR_VAR_SCRIPT_HANDLE);
- ejsDefineCFunction(-1, "disconnect", ejs_cli_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE);
+ ejsDefineCFunction(-1, "disconnect", ejs_cli_disconnect, NULL, MPR_VAR_SCRIPT_HANDLE);
+#endif
}