diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-04-16 11:47:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:16:23 -0500 |
commit | 76a2ac3ac324466962adbeaf1f2a85572f631c0a (patch) | |
tree | 074ea5a1fd8ab1c489d1564fd9b954cd59723ad2 /source3 | |
parent | d2cf063e6bf081e17ba54bcd24a39396dac33e1a (diff) | |
download | samba-76a2ac3ac324466962adbeaf1f2a85572f631c0a.tar.gz samba-76a2ac3ac324466962adbeaf1f2a85572f631c0a.tar.bz2 samba-76a2ac3ac324466962adbeaf1f2a85572f631c0a.zip |
r15098: Make smbclient -L use RPC to list shares, fall back to RAP. This should list
long share names.
Volker
(This used to be commit d3d388180dacb7b9db5d122bc3f2ce1045434f53)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 4 | ||||
-rw-r--r-- | source3/client/client.c | 57 |
2 files changed, 59 insertions, 2 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 1b2fc92227..27753dd072 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -555,7 +555,9 @@ LIBBIGBALLOFMUD_OBJ = $(PARAM_OBJ) $(LIB_NONSMBD_OBJ) $(SECRETS_OBJ) \ LIBBIGBALLOFMUD_PICOBJS = $(LIBBIGBALLOFMUD_OBJ:.o=.@PICSUFFIX@) -CLIENT_OBJ1 = client/client.o client/clitar.o +CLIENT_OBJ1 = client/client.o client/clitar.o 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 CLIENT_OBJ = $(CLIENT_OBJ1) $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(LIB_NONSMBD_OBJ) $(KRBCLIENT_OBJ) \ diff --git a/source3/client/client.c b/source3/client/client.c index 886af863e4..1fbee70645 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2510,7 +2510,7 @@ static void browse_fn(const char *name, uint32 m, *typestr=0; - switch (m) + switch (m & 7) { case STYPE_DISKTREE: fstrcpy(typestr,"Disk"); break; @@ -2532,6 +2532,57 @@ static void browse_fn(const char *name, uint32 m, } } +static BOOL browse_host_rpc(BOOL sort) +{ + 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); + browse_fn(name, info->info_1.type, comment, NULL); + } + + TALLOC_FREE(mem_ctx); + cli_rpc_pipe_close(pipe_hnd); + return True; +} + /**************************************************************************** Try and browse available connections on a host. ****************************************************************************/ @@ -2544,6 +2595,10 @@ static BOOL browse_host(BOOL sort) d_printf("\t--------- ---- -------\n"); } + if (browse_host_rpc(sort)) { + return True; + } + if((ret = cli_RNetShareEnum(cli, browse_fn, NULL)) == -1) d_printf("Error returning browse list: %s\n", cli_errstr(cli)); |