diff options
author | Tim Potter <tpot@samba.org> | 2003-04-14 04:15:24 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2003-04-14 04:15:24 +0000 |
commit | 19cda0035e5e056595ac9a96bfb3b029b76eb4d2 (patch) | |
tree | 52a793f9901f12389369affdda47ee38197121f5 /source3/libsmb | |
parent | ab892c11600f457dfed1f175e388bc90e3ae4c5f (diff) | |
download | samba-19cda0035e5e056595ac9a96bfb3b029b76eb4d2.tar.gz samba-19cda0035e5e056595ac9a96bfb3b029b76eb4d2.tar.bz2 samba-19cda0035e5e056595ac9a96bfb3b029b76eb4d2.zip |
Merge cliconnect.c so smbtree builds.
(This used to be commit 5df53e9d8a8b1861d9997a775cfd6d8fe472bdc4)
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/cliconnect.c | 114 |
1 files changed, 113 insertions, 1 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 763878f9b3..4bfa694e63 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -750,7 +750,6 @@ BOOL cli_ulogoff(struct cli_state *cli) /**************************************************************************** Send a tconX. ****************************************************************************/ - BOOL cli_send_tconX(struct cli_state *cli, const char *share, const char *dev, const char *pass, int passlen) { @@ -1343,3 +1342,116 @@ name *SMBSERVER with error %s\n", desthost, cli_errstr(cli) )); return True; } + + + + + +/**************************************************************************** + Send an old style tcon. +****************************************************************************/ +NTSTATUS cli_raw_tcon(struct cli_state *cli, + const char *service, const char *pass, const char *dev, + uint16 *max_xmit, uint16 *tid) +{ + char *p; + + memset(cli->outbuf,'\0',smb_size); + memset(cli->inbuf,'\0',smb_size); + + set_message(cli->outbuf, 0, 0, True); + SCVAL(cli->outbuf,smb_com,SMBtcon); + cli_setup_packet(cli); + + p = smb_buf(cli->outbuf); + *p++ = 4; p += clistr_push(cli, p, service, -1, STR_TERMINATE | STR_NOALIGN); + *p++ = 4; p += clistr_push(cli, p, pass, -1, STR_TERMINATE | STR_NOALIGN); + *p++ = 4; p += clistr_push(cli, p, dev, -1, STR_TERMINATE | STR_NOALIGN); + + cli_setup_bcc(cli, p); + + cli_send_smb(cli); + if (!cli_receive_smb(cli)) { + return NT_STATUS_UNEXPECTED_NETWORK_ERROR; + } + + if (cli_is_error(cli)) { + return cli_nt_error(cli); + } + + *max_xmit = SVAL(cli->inbuf, smb_vwv0); + *tid = SVAL(cli->inbuf, smb_vwv1); + + return NT_STATUS_OK; +} + +/* Return a cli_state pointing at the IPC$ share for the given server */ + +struct cli_state *get_ipc_connect(char *server, struct in_addr *server_ip, + struct user_auth_info *user_info) +{ + struct cli_state *cli; + pstring myname; + NTSTATUS nt_status; + + get_myname(myname); + + nt_status = cli_full_connection(&cli, myname, server, server_ip, 0, "IPC$", "IPC", + user_info->username, lp_workgroup(), user_info->password, + CLI_FULL_CONNECTION_ANNONYMOUS_FALLBACK, NULL); + + if (NT_STATUS_IS_OK(nt_status)) { + return cli; + } else if (is_ipaddress(server)) { + /* windows 9* needs a correct NMB name for connections */ + fstring remote_name; + + if (name_status_find("*", 0, 0, *server_ip, remote_name)) { + cli = get_ipc_connect(remote_name, server_ip, user_info); + if (cli) + return cli; + } + } + return NULL; +} + +/* Return the IP address and workgroup of a master browser on the + network. */ + +struct cli_state *get_ipc_connect_master_ip_bcast(pstring workgroup, struct user_auth_info *user_info) +{ + struct in_addr *ip_list; + struct cli_state *cli; + int i, count; + struct in_addr server_ip; + + /* Go looking for workgroups by broadcasting on the local network */ + + if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) { + return False; + } + + for (i = 0; i < count; i++) { + static fstring name; + + if (!name_status_find("*", 0, 0x1d, ip_list[i], name)) + continue; + + if (!find_master_ip(name, &server_ip)) + continue; + + pstrcpy(workgroup, name); + + DEBUG(4, ("found master browser %s, %s\n", + name, inet_ntoa(ip_list[i]))); + + cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info); + + if (!cli) + continue; + + return cli; + } + + return NULL; +} |