From f98d753b2f5bb6c30cd6fafc4869378a8b8eaf96 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 5 Dec 2001 03:14:21 +0000 Subject: Make it easier to construct anonymous connections with a new flag and helper function. (This used to be commit 61b0f5f4f9788784b0806a9a15cbc6bf1005aa68) --- source3/utils/net.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'source3') 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"); -- cgit