svn commit: samba r15098 - branches/SAMBA_3_0/source
branches/SAMBA_3_0/source/client trunk/source trunk/source/client
vlendec at samba.org
vlendec at samba.org
Sun Apr 16 11:47:28 GMT 2006
Author: vlendec
Date: 2006-04-16 11:47:26 +0000 (Sun, 16 Apr 2006)
New Revision: 15098
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=15098
Log:
Make smbclient -L use RPC to list shares, fall back to RAP. This should list
long share names.
Volker
Modified:
branches/SAMBA_3_0/source/Makefile.in
branches/SAMBA_3_0/source/client/client.c
trunk/source/Makefile.in
trunk/source/client/client.c
Changeset:
Modified: branches/SAMBA_3_0/source/Makefile.in
===================================================================
--- branches/SAMBA_3_0/source/Makefile.in 2006-04-16 06:05:33 UTC (rev 15097)
+++ branches/SAMBA_3_0/source/Makefile.in 2006-04-16 11:47:26 UTC (rev 15098)
@@ -555,7 +555,9 @@
LIBBIGBALLOFMUD_PICOBJS = $(LIBBIGBALLOFMUD_OBJ:.o=. at 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) \
Modified: branches/SAMBA_3_0/source/client/client.c
===================================================================
--- branches/SAMBA_3_0/source/client/client.c 2006-04-16 06:05:33 UTC (rev 15097)
+++ branches/SAMBA_3_0/source/client/client.c 2006-04-16 11:47:26 UTC (rev 15098)
@@ -2510,7 +2510,7 @@
*typestr=0;
- switch (m)
+ switch (m & 7)
{
case STYPE_DISKTREE:
fstrcpy(typestr,"Disk"); break;
@@ -2532,6 +2532,57 @@
}
}
+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 @@
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));
Modified: trunk/source/Makefile.in
===================================================================
--- trunk/source/Makefile.in 2006-04-16 06:05:33 UTC (rev 15097)
+++ trunk/source/Makefile.in 2006-04-16 11:47:26 UTC (rev 15098)
@@ -564,7 +564,9 @@
LIBBIGBALLOFMUD_PICOBJS = $(LIBBIGBALLOFMUD_OBJ:.o=. at 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) \
Modified: trunk/source/client/client.c
===================================================================
--- trunk/source/client/client.c 2006-04-16 06:05:33 UTC (rev 15097)
+++ trunk/source/client/client.c 2006-04-16 11:47:26 UTC (rev 15098)
@@ -2510,7 +2510,7 @@
*typestr=0;
- switch (m)
+ switch (m & 7)
{
case STYPE_DISKTREE:
fstrcpy(typestr,"Disk"); break;
@@ -2532,6 +2532,57 @@
}
}
+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 @@
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));
More information about the samba-cvs
mailing list