/* establish the connection if not already */
if (!cli) {
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
- service, auth_info,
- true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli) {
+ NTSTATUS status;
+
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : desthost,
+ service, auth_info,
+ true, smb_encrypt,
+ max_protocol, port, name_type,
+ &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
}
}
static int process(const char *base_directory)
{
int rc = 0;
+ NTSTATUS status;
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
- service, auth_info, true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli) {
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : desthost,
+ service, auth_info, true, smb_encrypt,
+ max_protocol, port, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
}
static int do_host_query(const char *query_host)
{
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : query_host, "IPC$", auth_info, true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli)
+ NTSTATUS status;
+
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : query_host,
+ "IPC$", auth_info, true, smb_encrypt,
+ max_protocol, port, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
+ }
browse_host(true);
else but port 139... */
cli_shutdown(cli);
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : query_host, "IPC$",
- auth_info, true, smb_encrypt,
- max_protocol, 139, name_type);
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : query_host,
+ "IPC$", auth_info, true, smb_encrypt,
+ max_protocol, 139, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
+ cli = NULL;
+ }
}
if (cli == NULL) {
/* do we already have a connection? */
if (!cli) {
- cli = cli_cm_open(talloc_tos(), NULL,
- have_ip ? dest_ss_str : desthost,
- service, auth_info, true, smb_encrypt,
- max_protocol, port, name_type);
- if (!cli)
+ NTSTATUS status;
+
+ status = cli_cm_open(talloc_tos(), NULL,
+ have_ip ? dest_ss_str : desthost,
+ service, auth_info, true, smb_encrypt,
+ max_protocol, port, name_type, &cli);
+ if (!NT_STATUS_IS_OK(status)) {
return 1;
+ }
}
recurse=true;
Open a client connection to a \\server\share.
****************************************************************************/
-struct cli_state *cli_cm_open(TALLOC_CTX *ctx,
+NTSTATUS cli_cm_open(TALLOC_CTX *ctx,
struct cli_state *referring_cli,
const char *server,
const char *share,
bool force_encrypt,
int max_protocol,
int port,
- int name_type)
+ int name_type,
+ struct cli_state **pcli)
{
/* Try to reuse an existing connection in this list. */
struct cli_state *c = cli_cm_find(referring_cli, server, share);
NTSTATUS status;
if (c) {
- return c;
+ *pcli = c;
+ return NT_STATUS_OK;
}
if (auth_info == NULL) {
d_printf("cli_cm_open() Unable to open connection [\\%s\\%s] "
"without auth info\n",
server, share );
- return NULL;
+ return NT_STATUS_INVALID_PARAMETER;
}
status = cli_cm_connect(ctx,
name_type,
&c);
if (!NT_STATUS_IS_OK(status)) {
- return NULL;
+ return status;
}
- return c;
+ *pcli = c;
+ return NT_STATUS_OK;
}
/****************************************************************************
/* Check for the referral. */
- if (!(cli_ipc = cli_cm_open(ctx,
- rootcli,
- rootcli->desthost,
- "IPC$",
- dfs_auth_info,
- false,
- (rootcli->trans_enc_state != NULL),
- rootcli->protocol,
- 0,
- 0x20))) {
+ status = cli_cm_open(ctx,
+ rootcli,
+ rootcli->desthost,
+ "IPC$",
+ dfs_auth_info,
+ false,
+ (rootcli->trans_enc_state != NULL),
+ rootcli->protocol,
+ 0,
+ 0x20,
+ &cli_ipc);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
*/
/* Open the connection to the target server & share */
- if ((*targetcli = cli_cm_open(ctx, rootcli,
- server,
- share,
- dfs_auth_info,
- false,
- (rootcli->trans_enc_state != NULL),
- rootcli->protocol,
- 0,
- 0x20)) == NULL) {
+ status = cli_cm_open(ctx, rootcli,
+ server,
+ share,
+ dfs_auth_info,
+ false,
+ (rootcli->trans_enc_state != NULL),
+ rootcli->protocol,
+ 0,
+ 0x20,
+ targetcli);
+ if (!NT_STATUS_IS_OK(status)) {
d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
server, share );
return false;