the connections list and authentication structures to worry about.
Jeremy
cli = cli_cm_open(talloc_tos(), NULL,
have_ip ? dest_ss_str : desthost,
service, true, smb_encrypt,
- max_protocol);
+ max_protocol, port, name_type);
if (!cli) {
return 1;
}
cli = cli_cm_open(talloc_tos(), NULL,
have_ip ? dest_ss_str : desthost,
service, true, smb_encrypt,
- max_protocol);
+ max_protocol, port, name_type);
if (!cli) {
return 1;
}
cli = cli_cm_open(talloc_tos(), NULL,
query_host, "IPC$", true, smb_encrypt,
- max_protocol);
+ max_protocol, port, name_type);
if (!cli)
return 1;
else but port 139... */
cli_cm_shutdown();
- cli_cm_set_port( 139 );
cli = cli_cm_open(talloc_tos(), NULL,
query_host, "IPC$", true, smb_encrypt,
- max_protocol);
+ max_protocol, 139, name_type);
}
if (cli == NULL) {
cli = cli_cm_open(talloc_tos(), NULL,
have_ip ? dest_ss_str : desthost,
service, true, smb_encrypt,
- max_protocol);
+ max_protocol, port, name_type);
if (!cli)
return 1;
}
msg_port = port ? port : 139;
- if (!(cli=cli_initialise()) || (cli_set_port(cli, msg_port) != msg_port)) {
+ if (!(cli=cli_initialise())) {
d_printf("Connection to %s failed\n", desthost);
return 1;
}
+ cli_set_port(cli, msg_port);
status = cli_connect(cli, server_name, &ss);
if (!NT_STATUS_IS_OK(status)) {
* to port 139 instead of port 445. srl,crh
*/
name_type = 0x03;
- cli_cm_set_dest_name_type( name_type );
desthost = talloc_strdup(frame,poptGetOptArg(pc));
if (!desthost) {
exit(ENOMEM);
}
if( !port )
- cli_cm_set_port( 139 );
+ port = 139;
message = true;
break;
case 'I':
poptGetArg(pc));
}
- /* check for the -P option */
-
- if ( port != 0 )
- cli_cm_set_port( port );
-
/*
* Don't load debug level from smb.conf. It should be
* set by cmdline arg or remain default (0)
*p = 0;
p++;
sscanf(p, "%x", &name_type);
- cli_cm_set_dest_name_type( name_type );
}
return do_host_query(qhost);
const char *share,
bool show_hdr,
bool force_encrypt,
- int max_protocol);
+ int max_protocol,
+ int port,
+ int name_type);
void cli_cm_shutdown(void);
void cli_cm_display(void);
void cli_cm_set_credentials(struct user_auth_info *auth_info);
int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
-int cli_set_port(struct cli_state *cli, int port);
+void cli_set_port(struct cli_state *cli, int port);
bool cli_receive_smb(struct cli_state *cli);
ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len);
bool cli_receive_smb_readX_header(struct cli_state *cli);
cli_ipc = cli_cm_open(ctx, NULL,
server_name, "IPC$",
false, false,
- PROTOCOL_NT1);
+ PROTOCOL_NT1,
+ 0, 0x20);
if (!cli_ipc) {
libnetapi_set_error_string(ctx,
"Failed to connect to IPC$ share on %s", server_name);
make_nmb_name(&calling, my_name, 0x0);
make_nmb_name(&called , dest_host, 0x20);
- if (cli_set_port(cli, port) != port) {
- cli_shutdown(cli);
- return NT_STATUS_UNSUCCESSFUL;
- }
-
+ cli_set_port(cli, port);
cli_set_timeout(cli, 10000); /* 10 seconds. */
if (dest_ss) {
static void cm_set_password(const char *newpass);
-static int port;
-static int name_type = 0x20;
-
static struct client_connection *connections;
static bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
const char *share,
bool show_sessetup,
bool force_encrypt,
- int max_protocol)
+ int max_protocol,
+ int port,
+ int name_type)
{
struct cli_state *c = NULL;
struct nmb_name called, calling;
zero_sockaddr(&ss);
/* have to open a new connection */
- if (!(c=cli_initialise()) || (cli_set_port(c, port) != port)) {
+ if (!(c=cli_initialise())) {
d_printf("Connection to %s failed\n", server_n);
if (c) {
cli_shutdown(c);
}
return NULL;
}
+ if (port) {
+ cli_set_port(c, port);
+ }
+
status = cli_connect(c, server_n, &ss);
if (!NT_STATUS_IS_OK(status)) {
d_printf("Connection to %s failed (Error %s)\n",
return NULL;
}
+ if (max_protocol == 0) {
+ max_protocol = PROTOCOL_NT1;
+ }
c->protocol = max_protocol;
c->use_kerberos = cm_creds.use_kerberos;
c->fallback_after_kerberos = cm_creds.fallback_after_kerberos;
cli_shutdown(c);
return do_connect(ctx, newserver,
newshare, false,
- force_encrypt, max_protocol);
+ force_encrypt, max_protocol,
+ port, name_type);
}
/* must be a normal share */
const char *share,
bool show_hdr,
bool force_encrypt,
- int max_protocol)
+ int max_protocol,
+ int port,
+ int name_type)
{
struct client_connection *node;
}
node->cli = do_connect(ctx, server, share,
- show_hdr, force_encrypt, max_protocol);
+ show_hdr, force_encrypt, max_protocol,
+ port, name_type);
if ( !node->cli ) {
TALLOC_FREE( node );
const char *share,
bool show_hdr,
bool force_encrypt,
- int max_protocol)
+ int max_protocol,
+ int port,
+ int name_type)
{
struct cli_state *c;
if (!c) {
c = cli_cm_connect(ctx, referring_cli,
server, share, show_hdr, force_encrypt,
- max_protocol);
+ max_protocol, port, name_type);
}
return c;
/****************************************************************************
****************************************************************************/
-void cli_cm_set_port(int port_number)
-{
- port = port_number;
-}
-
-/****************************************************************************
-****************************************************************************/
-
-void cli_cm_set_dest_name_type(int type)
-{
- name_type = type;
-}
-
-/****************************************************************************
-****************************************************************************/
-
void cli_cm_set_signing_state(int state)
{
cm_creds.signing_state = state;
rootcli->desthost,
"IPC$", false,
(rootcli->trans_enc_state != NULL),
- rootcli->protocol))) {
+ rootcli->protocol,
+ 0,
+ 0x20))) {
return false;
}
share,
false,
(rootcli->trans_enc_state != NULL),
- rootcli->protocol)) == NULL) {
+ rootcli->protocol,
+ 0,
+ 0x20)) == NULL) {
d_printf("Unable to follow dfs referral [\\%s\\%s]\n",
server, share );
return false;
Change the port number used to call on.
****************************************************************************/
-int cli_set_port(struct cli_state *cli, int port)
+void cli_set_port(struct cli_state *cli, int port)
{
cli->port = port;
- return port;
}
/****************************************************************************
return;
}
- if (!cli_set_port(cli, 139)) {
- cli_shutdown(cli);
- return;
- }
+ cli_set_port(cli, 139);
in_addr_to_sockaddr_storage(&ss, ip);
status = cli_connect(cli, name, &ss);