summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-04-16 11:47:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:16:23 -0500
commit76a2ac3ac324466962adbeaf1f2a85572f631c0a (patch)
tree074ea5a1fd8ab1c489d1564fd9b954cd59723ad2 /source3/client
parentd2cf063e6bf081e17ba54bcd24a39396dac33e1a (diff)
downloadsamba-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/client')
-rw-r--r--source3/client/client.c57
1 files changed, 56 insertions, 1 deletions
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));