diff options
author | Michael Adam <obnox@samba.org> | 2007-09-17 15:11:20 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:30:50 -0500 |
commit | 1130482add933d6a3e0b7f13717e0ae72588c6a2 (patch) | |
tree | f0288bcf212a1bcbfefddee50185875b3ce7a47e /source3/utils/net.c | |
parent | 4f051e735b85a24f37e2b844bcbb348f36600420 (diff) | |
download | samba-1130482add933d6a3e0b7f13717e0ae72588c6a2.tar.gz samba-1130482add933d6a3e0b7f13717e0ae72588c6a2.tar.xz samba-1130482add933d6a3e0b7f13717e0ae72588c6a2.zip |
r25197: Change net_make_ipc_connection() and net_make_ipc_connection_ex() to
return NTSTATUS to allow for better error propagation.
Michael
(This used to be commit 46093004a788dae83a4ddb888ca5d72f555c236c)
Diffstat (limited to 'source3/utils/net.c')
-rw-r--r-- | source3/utils/net.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c index 962da0b39e..9c327f162d 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -465,13 +465,14 @@ BOOL net_find_pdc(struct in_addr *server_ip, fstring server_name, const char *do return False; } -struct cli_state *net_make_ipc_connection( unsigned flags ) +NTSTATUS net_make_ipc_connection(unsigned flags, struct cli_state **pcli) { - return net_make_ipc_connection_ex( NULL, NULL, NULL, flags ); + return net_make_ipc_connection_ex(NULL, NULL, NULL, flags, pcli); } -struct cli_state *net_make_ipc_connection_ex( const char *domain, const char *server, - struct in_addr *ip, unsigned flags) +NTSTATUS net_make_ipc_connection_ex(const char *domain, const char *server, + struct in_addr *ip, unsigned flags, + struct cli_state **pcli) { char *server_name = NULL; struct in_addr server_ip; @@ -481,7 +482,8 @@ struct cli_state *net_make_ipc_connection_ex( const char *domain, const char *se if ( !server || !ip ) { if (!net_find_server(domain, flags, &server_ip, &server_name)) { d_fprintf(stderr, "Unable to find a suitable server\n"); - return NULL; + nt_status = NT_STATUS_UNSUCCESSFUL; + goto done; } } else { server_name = SMB_STRDUP( server ); @@ -500,13 +502,17 @@ struct cli_state *net_make_ipc_connection_ex( const char *domain, const char *se saf_store( cli->server_domain, cli->desthost ); SAFE_FREE(server_name); - if (NT_STATUS_IS_OK(nt_status)) { - return cli; - } else { + if (!NT_STATUS_IS_OK(nt_status)) { d_fprintf(stderr, "Connection failed: %s\n", nt_errstr(nt_status)); - return NULL; + cli = NULL; } + +done: + if (pcli != NULL) { + *pcli = cli; + } + return nt_status; } static int net_user(int argc, const char **argv) |