p = pserver;
while(next_token( &p, desthost, LIST_SEP, sizeof(desthost))) {
+ NTSTATUS status;
+
standard_sub_basic(current_user_info.smb_name, current_user_info.domain,
desthost, sizeof(desthost));
strupper_m(desthost);
return NULL;
}
- if (cli_connect(cli, desthost, &dest_ip)) {
+ status = cli_connect(cli, desthost, &dest_ip);
+ if (NT_STATUS_IS_OK(status)) {
DEBUG(3,("connected to password server %s\n",desthost));
connected_ok = True;
break;
}
+ DEBUG(10,("server_cryptkey: failed to connect to server %s. Error %s\n",
+ desthost, nt_errstr(status) ));
}
if (!connected_ok) {
fstring server_name;
char name_type_hex[10];
int msg_port;
+ NTSTATUS status;
make_nmb_name(&calling, calling_name, 0x0);
make_nmb_name(&called , desthost, name_type);
msg_port = port ? port : 139;
- if (!(cli=cli_initialise()) || (cli_set_port(cli, msg_port) != msg_port) ||
- !cli_connect(cli, server_name, &ip)) {
+ if (!(cli=cli_initialise()) || (cli_set_port(cli, msg_port) != msg_port)) {
d_printf("Connection to %s failed\n", desthost);
return 1;
}
+ status = cli_connect(cli, server_name, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Connection to %s failed. Error %s\n", desthost, nt_errstr(status));
+ return 1;
+ }
+
if (!cli_session_request(cli, &calling, &called)) {
d_printf("session request failed\n");
cli_cm_shutdown();
Open the client sockets.
****************************************************************************/
-BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
+NTSTATUS cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip)
{
int name_type = 0x20;
char *p;
if (!ip || is_zero_ip(*ip)) {
if (!resolve_name(cli->desthost, &cli->dest_ip, name_type)) {
- return False;
+ return NT_STATUS_BAD_NETWORK_NAME;
}
if (ip) *ip = cli->dest_ip;
} else {
if (cli->fd == -1) {
DEBUG(1,("Error connecting to %s (%s)\n",
ip?inet_ntoa(*ip):host,strerror(errno)));
- return False;
+ return map_nt_error_from_unix(errno);
}
set_socket_options(cli->fd,user_socket_options);
- return True;
+ return NT_STATUS_OK;
}
/**
DEBUG(3,("Connecting to host=%s\n", dest_host));
- if (!cli_connect(cli, dest_host, &ip)) {
- DEBUG(1,("cli_start_connection: failed to connect to %s (%s)\n",
- nmb_namestr(&called), inet_ntoa(ip)));
+ nt_status = cli_connect(cli, dest_host, &ip);
+ if (!NT_STATUS_IS_OK(nt_status)) {
+ DEBUG(1,("cli_start_connection: failed to connect to %s (%s). Error %s\n",
+ nmb_namestr(&called), inet_ntoa(ip), nt_errstr(nt_status) ));
cli_shutdown(cli);
- if (is_zero_ip(ip)) {
- return NT_STATUS_BAD_NETWORK_NAME;
- } else {
- return NT_STATUS_CONNECTION_REFUSED;
- }
+ return nt_status;
}
if (retry)
}
if (!cli_session_request(*ppcli, &calling, &called)) {
+ NTSTATUS status;
struct nmb_name smbservername;
make_nmb_name(&smbservername , "*SMBSERVER", 0x20);
return False;
}
- if (!cli_connect(*ppcli, desthost, pdest_ip) ||
+ status = cli_connect(*ppcli, desthost, pdest_ip);
+ if (!NT_STATUS_IS_OK(status) ||
!cli_session_request(*ppcli, &calling, &smbservername)) {
DEBUG(0,("attempt_netbios_session_request: %s rejected the session for \
name *SMBSERVER with error %s\n", desthost, cli_errstr(*ppcli) ));
pstring servicename;
char *sharename;
fstring newserver, newshare;
+ NTSTATUS status;
/* make a copy so we don't modify the global string 'service' */
pstrcpy(servicename, share);
ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_initialise()) || (cli_set_port(c, port) != port) ||
- !cli_connect(c, server_n, &ip)) {
+ if (!(c=cli_initialise()) || (cli_set_port(c, port) != port)) {
d_printf("Connection to %s failed\n", server_n);
return NULL;
}
+ status = cli_connect(c, server_n, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Connection to %s failed (Error %s)\n", server_n, nt_errstr(status));
+ return NULL;
+ }
c->protocol = max_protocol;
c->use_kerberos = use_kerberos;
int port_try_first;
int port_try_next;
const char *username_used;
-
+ NTSTATUS status;
+
zero_ip(&ip);
ZERO_STRUCT(c);
c->port = port_try_first;
- if (!cli_connect(c, server_n, &ip)) {
+ status = cli_connect(c, server_n, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
/* First connection attempt failed. Try alternate port. */
c->port = port_try_next;
- if (!cli_connect(c, server_n, &ip)) {
- cli_shutdown(c);
- errno = ETIMEDOUT;
- return NULL;
- }
- }
+ status = cli_connect(c, server_n, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli_shutdown(c);
+ errno = ETIMEDOUT;
+ return NULL;
+ }
+ }
if (!cli_session_request(c, &calling, &called)) {
cli_shutdown(c);
*err_str = '\0';
if(!resolve_name( remote_machine, &ip, 0x20)) {
- slprintf(err_str, err_str_len-1, "unable to find an IP address for machine %s.\n",
+ slprintf(err_str, err_str_len-1, "Unable to find an IP address for machine %s.\n",
remote_machine );
return NT_STATUS_UNSUCCESSFUL;
}
return NT_STATUS_NO_MEMORY;
}
- if (!cli_connect(cli, remote_machine, &ip)) {
- slprintf(err_str, err_str_len-1, "unable to connect to SMB server on machine %s. Error was : %s.\n",
- remote_machine, cli_errstr(cli) );
- result = cli_nt_error(cli);
+ result = cli_connect(cli, remote_machine, &ip);
+ if (!NT_STATUS_IS_OK(result)) {
+ slprintf(err_str, err_str_len-1, "Unable to connect to SMB server on machine %s. Error was : %s.\n",
+ remote_machine, nt_errstr(result) );
cli_shutdown(cli);
return result;
}
struct cli_state *cli;
uint32 local_type = local ? SV_TYPE_LOCAL_LIST_ONLY : 0;
struct nmb_name called, calling;
+ NTSTATUS status;
/* W2K DMB's return empty browse lists on port 445. Use 139.
* Patch from Andy Levine andyl@epicrealm.com.
return;
}
- if (!cli_set_port(cli, 139) || !cli_connect(cli, name, &ip)) {
+ if (!cli_set_port(cli, 139)) {
+ return;
+ }
+
+ status = cli_connect(cli, name, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
return;
}
struct in_addr ip;
fstring myname;
static int count;
+ NTSTATUS status;
fstrcpy(server,share+2);
share = strchr_m(server,'\\');
zero_ip(&ip);
/* have to open a new connection */
- if (!(c=cli_initialise()) || !cli_connect(c, server_n, &ip)) {
+ if (!(c=cli_initialise())) {
DEBUG(0,("Connection to %s failed\n", server_n));
return NULL;
}
+ status = cli_connect(c, server_n, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Connection to %s failed. Error %s\n", server_n, nt_errstr(status) ));
+ return NULL;
+ }
+
c->use_kerberos = use_kerberos;
if (!cli_session_request(c, &calling, &called)) {
char *server_n;
char *server;
struct in_addr ip;
+ NTSTATUS status;
server = share+2;
share = strchr_m(server,'\\');
zero_ip(&ip);
/* have to open a new connection */
- if (!(c=cli_initialise()) || !cli_connect(c, server_n, &ip)) {
+ if (!(c=cli_initialise())) {
DEBUG(0,("Connection to %s failed\n", server_n));
return NULL;
}
+ status = cli_connect(c, server_n, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Connection to %s failed. Error %s\n", server_n, nt_errstr(status) ));
+ return NULL;
+ }
+
c->protocol = max_protocol;
if (!cli_session_request(c, &calling, &called)) {
struct nmb_name called, calling;
struct in_addr ip;
struct cli_state *c;
+ NTSTATUS status;
make_nmb_name(&calling, myname, 0x0);
make_nmb_name(&called , host, 0x20);
c->port = port_to_use;
- if (!cli_connect(c, host, &ip)) {
- printf("Failed to connect with %s\n", host);
+ status = cli_connect(c, host, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
return NULL;
}
* Well, that failed, try *SMBSERVER ...
* However, we must reconnect as well ...
*/
- if (!cli_connect(c, host, &ip)) {
- printf("Failed to connect with %s\n", host);
+ status = cli_connect(c, host, &ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
return NULL;
}
BOOL ret = False;
struct in_addr server_ip;
char *server_name = NULL;
+ NTSTATUS status;
/* flags (i.e. server type) may depend on command */
if (!net_find_server(NULL, flags, &server_ip, &server_name))
return False;
}
- if (!cli_connect(cli, server_name, &server_ip))
+ status = cli_connect(cli, server_name, &server_ip);
+ if (!NT_STATUS_IS_OK(status))
goto done;
if (!attempt_netbios_session_request(&cli, global_myname(),
server_name, &server_ip))
struct nmb_name calling, called;
time_t ret = 0;
struct cli_state *cli = NULL;
+ NTSTATUS status;
cli = cli_initialise();
if (!cli) {
goto done;
}
- if (!cli_connect(cli, host, ip)) {
- fprintf(stderr,"Can't contact server\n");
+ status = cli_connect(cli, host, ip);
+ if (!NT_STATUS_IS_OK(status)) {
+ fprintf(stderr,"Can't contact server %s. Error %s\n", host, nt_errstr(status));
goto done;
}
then closing it */
BOOL smbd_running(void)
{
+ NTSTATUS status;
struct cli_state *cli;
if ((cli = cli_initialise()) == NULL)
return False;
- if (!cli_connect(cli, global_myname(), &loopback_ip)) {
+ status = cli_connect(cli, global_myname(), &loopback_ip);
+ if (!NT_STATUS_IS_OK(status)) {
cli_shutdown(cli);
return False;
}