1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

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 d3d388180d)
This commit is contained in:
Volker Lendecke 2006-04-16 11:47:26 +00:00 committed by Gerald (Jerry) Carter
parent d2cf063e6b
commit 76a2ac3ac3
2 changed files with 59 additions and 2 deletions

View File

@ -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) \

View File

@ -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));