summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJim McDonough <jmcd@samba.org>2006-05-16 01:21:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:17:03 -0500
commit62f61caff4cb36070a0987bfccc679ade091f73b (patch)
treeab8ed98eb20d10676562b7f8c9302a832875ac60 /source3
parent039113fe15eca1c69d6ccf40792d562bcca48ca4 (diff)
downloadsamba-62f61caff4cb36070a0987bfccc679ade091f73b.tar.gz
samba-62f61caff4cb36070a0987bfccc679ade091f73b.tar.bz2
samba-62f61caff4cb36070a0987bfccc679ade091f73b.zip
r15630: adapt smbclient fix to smbtree to enable long share names
(This used to be commit ae56154fc7694042496a55d4dade8ef1a7ba361c)
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in5
-rw-r--r--source3/utils/smbtree.c57
2 files changed, 61 insertions, 1 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 32243b4759..fc6daa381b 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -477,7 +477,10 @@ SMBCONTROL_OBJ = utils/smbcontrol.o $(LOCKING_OBJ) $(PARAM_OBJ) \
SMBTREE_OBJ = utils/smbtree.o $(PARAM_OBJ) \
$(PROFILE_OBJ) $(LIB_NONSMBD_OBJ) $(LIBSMB_OBJ) \
- $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ)
+ $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) $(SECRETS_OBJ) \
+ rpc_client/cli_srvsvc.o rpc_parse/parse_srv.o \
+ rpc_client/cli_pipe.o rpc_parse/parse_rpc.o \
+ rpc_client/cli_netlogon.o rpc_parse/parse_net.o
TESTPARM_OBJ = utils/testparm.o \
$(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c
index 853a46f379..d9cd446f6c 100644
--- a/source3/utils/smbtree.c
+++ b/source3/utils/smbtree.c
@@ -127,6 +127,60 @@ static BOOL get_servers(char *workgroup, struct user_auth_info *user_info)
return True;
}
+static BOOL get_rpc_shares(struct cli_state *cli,
+ void (*fn)(const char *, uint32, const char *, void *),
+ void *state)
+{
+ NTSTATUS status;
+ struct rpc_pipe_client *pipe_hnd;
+ TALLOC_CTX *mem_ctx;
+ ENUM_HND enum_hnd;
+ WERROR werr;
+ SRV_SHARE_INFO_CTR ctr;
+ int i;
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ DEBUG(0, ("talloc_new failed\n"));
+ return False;
+ }
+
+ init_enum_hnd(&enum_hnd, 0);
+
+ pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &status);
+
+ if (pipe_hnd == NULL) {
+ DEBUG(10, ("Could not connect to srvsvc pipe: %s\n",
+ nt_errstr(status)));
+ TALLOC_FREE(mem_ctx);
+ return False;
+ }
+
+ werr = rpccli_srvsvc_net_share_enum(pipe_hnd, mem_ctx, 1, &ctr,
+ 0xffffffff, &enum_hnd);
+
+ if (!W_ERROR_IS_OK(werr)) {
+ TALLOC_FREE(mem_ctx);
+ cli_rpc_pipe_close(pipe_hnd);
+ return False;
+ }
+
+ for (i=0; i<ctr.num_entries; i++) {
+ SRV_SHARE_INFO_1 *info = &ctr.share.info1[i];
+ char *name, *comment;
+ name = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_netname);
+ comment = rpcstr_pull_unistr2_talloc(
+ mem_ctx, &info->info_1_str.uni_remark);
+ fn(name, info->info_1.type, comment, state);
+ }
+
+ TALLOC_FREE(mem_ctx);
+ cli_rpc_pipe_close(pipe_hnd);
+ return True;
+}
+
+
static BOOL get_shares(char *server_name, struct user_auth_info *user_info)
{
struct cli_state *cli;
@@ -134,6 +188,9 @@ static BOOL get_shares(char *server_name, struct user_auth_info *user_info)
if (!(cli = get_ipc_connect(server_name, NULL, user_info)))
return False;
+ if (get_rpc_shares(cli, add_name, &shares))
+ return True;
+
if (!cli_RNetShareEnum(cli, add_name, &shares))
return False;