summaryrefslogtreecommitdiff
path: root/source3/utils/net.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2001-12-05 03:14:21 +0000
committerAndrew Bartlett <abartlet@samba.org>2001-12-05 03:14:21 +0000
commitf98d753b2f5bb6c30cd6fafc4869378a8b8eaf96 (patch)
treeef71f9731df949fc7d07da17744469b7cd730655 /source3/utils/net.c
parent2f87684a1e8d26c2566ba39e1a576b7748af7eb0 (diff)
downloadsamba-f98d753b2f5bb6c30cd6fafc4869378a8b8eaf96.tar.gz
samba-f98d753b2f5bb6c30cd6fafc4869378a8b8eaf96.tar.bz2
samba-f98d753b2f5bb6c30cd6fafc4869378a8b8eaf96.zip
Make it easier to construct anonymous connections with a new flag and helper
function. (This used to be commit 61b0f5f4f9788784b0806a9a15cbc6bf1005aa68)
Diffstat (limited to 'source3/utils/net.c')
-rw-r--r--source3/utils/net.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 55bf09dca7..e20833bc0b 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -129,6 +129,28 @@ static struct cli_state *connect_to_ipc(struct in_addr *server_ip, const char *s
}
}
+/****************************************************************************
+connect to \\server\ipc$ anonymously
+****************************************************************************/
+static struct cli_state *connect_to_ipc_anonymous(struct in_addr *server_ip, const char *server_name)
+{
+ struct cli_state *c;
+ NTSTATUS nt_status;
+
+ nt_status = cli_full_connection(&c, opt_requester_name, server_name,
+ server_ip, opt_port,
+ "IPC$", "IPC",
+ "", "",
+ "", 0);
+
+ if (NT_STATUS_IS_OK(nt_status)) {
+ return c;
+ } else {
+ DEBUG(1,("Cannot connect to server (anonymously). Error was %s\n", get_nt_error_msg(nt_status)));
+ return NULL;
+ }
+}
+
static BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_name)
{
@@ -211,8 +233,12 @@ struct cli_state *net_make_ipc_connection(unsigned flags)
d_printf("\nUnable to find a suitable server\n");
return NULL;
}
-
- cli = connect_to_ipc(&server_ip, server_name);
+
+ if (flags & NET_FLAGS_ANONYMOUS) {
+ cli = connect_to_ipc_anonymous(&server_ip, server_name);
+ } else {
+ cli = connect_to_ipc(&server_ip, server_name);
+ }
SAFE_FREE(server_name);
if(!cli) {
d_printf("\nUnable to connect to target server\n");