diff -Naur -X samba_excludes --recursive samba-3.0.23/source/auth/auth_domain.c samba-3.0.23.ben/source/auth/auth_domain.c --- samba-3.0.23/source/auth/auth_domain.c 2006-06-09 12:30:30.000000000 -0700 +++ samba-3.0.23.ben/source/auth/auth_domain.c 2006-07-13 13:28:24.000000000 -0700 @@ -45,7 +45,7 @@ const char *dc_name, struct in_addr dc_ip, struct rpc_pipe_client **pipe_ret, - BOOL *retry) + BOOL *retry, struct local_bind_info* local_binding) { NTSTATUS result; struct rpc_pipe_client *netlogon_pipe = NULL; @@ -73,7 +73,7 @@ /* Attempt connection */ *retry = True; result = cli_full_connection(cli, global_myname(), dc_name, &dc_ip, 0, - "IPC$", "IPC", "", "", "", 0, Undefined, retry); + "IPC$", "IPC", "", "", "", 0, Undefined, retry, local_binding); if (!NT_STATUS_IS_OK(result)) { /* map to something more useful */ @@ -173,7 +173,7 @@ uchar chal[8], auth_serversupplied_info **server_info, const char *dc_name, - struct in_addr dc_ip) + struct in_addr dc_ip, struct local_bind_info* local_binding) { NET_USER_INFO_3 info3; @@ -199,7 +199,7 @@ dc_name, dc_ip, &netlogon_pipe, - &retry); + &retry, local_binding); } if ( !NT_STATUS_IS_OK(nt_status) ) { @@ -322,7 +322,8 @@ (uchar *)auth_context->challenge.data, server_info, dc_name, - dc_ip); + dc_ip, + NULL /* local_binding info, not supported */); return nt_status; } @@ -424,7 +425,8 @@ (uchar *)auth_context->challenge.data, server_info, dc_name, - dc_ip); + dc_ip, + NULL /* local_binding info, not supported */); return nt_status; } diff -Naur -X samba_excludes --recursive samba-3.0.23/source/auth/auth_server.c samba-3.0.23.ben/source/auth/auth_server.c --- samba-3.0.23/source/auth/auth_server.c 2006-04-19 19:29:20.000000000 -0700 +++ samba-3.0.23.ben/source/auth/auth_server.c 2006-07-13 13:24:53.000000000 -0700 @@ -71,7 +71,7 @@ return NULL; } - if (cli_connect(cli, desthost, &dest_ip)) { + if (cli_connect(cli, desthost, &dest_ip, NULL /* local_binding_info, not supported */)) { DEBUG(3,("connected to password server %s\n",desthost)); connected_ok = True; break; @@ -86,7 +86,7 @@ } if (!attempt_netbios_session_request(cli, global_myname(), - desthost, &dest_ip)) { + desthost, &dest_ip, NULL /* local_binding info, not supported */)) { release_server_mutex(); DEBUG(1,("password server fails session request\n")); cli_shutdown(cli); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/client/client.c samba-3.0.23.ben/source/client/client.c --- samba-3.0.23/source/client/client.c 2006-07-10 09:27:54.000000000 -0700 +++ samba-3.0.23.ben/source/client/client.c 2006-07-13 13:42:46.000000000 -0700 @@ -61,6 +61,7 @@ static BOOL translation = False; static BOOL have_ip; +static struct local_bind_info local_binding; /* clitar bits insert */ extern int blocksize; @@ -3353,12 +3354,12 @@ msg_port = port ? port : 139; if (!(cli=cli_initialise(NULL)) || (cli_set_port(cli, msg_port) != msg_port) || - !cli_connect(cli, server_name, &ip)) { + !cli_connect(cli, server_name, &ip, &local_binding)) { d_printf("Connection to %s failed\n", desthost); return 1; } - if (!cli_session_request(cli, &calling, &called)) { + if (!cli_session_request(cli, &calling, &called, &local_binding)) { d_printf("session request failed\n"); cli_cm_shutdown(); return 1; @@ -3393,6 +3394,9 @@ { "name-resolve", 'R', POPT_ARG_STRING, &new_name_resolve_order, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, { "message", 'M', POPT_ARG_STRING, NULL, 'M', "Send message", "HOST" }, { "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" }, + { "local_ip", 'i', POPT_ARG_STRING, NULL, 'i', "Bind to this local IP", "IP" }, + { "local_port", 'P', POPT_ARG_STRING, NULL, 'P', "Bind to this local IP Port", "number" }, + { "local_dev", 'd', POPT_ARG_STRING, NULL, 'd', "Bind to this local device", "Interface-Name" }, { "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" }, { "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" }, { "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" }, @@ -3463,6 +3467,18 @@ cli_cm_set_dest_ip( dest_ip ); } break; + case 'i': + local_binding.local_ip = inet_addr(poptGetOptArg(pc)); + cli_cm_set_local_binding(&local_binding); + break; + case 'P': + local_binding.local_port = atoi(poptGetOptArg(pc)); + cli_cm_set_local_binding(&local_binding); + break; + case 'd': + strncpy(local_binding.dev_name, poptGetOptArg(pc), sizeof(local_binding.dev_name)); + cli_cm_set_local_binding(&local_binding); + break; case 'E': if (dbf) { x_fclose(dbf); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/client/mount.cifs.c samba-3.0.23.ben/source/client/mount.cifs.c --- samba-3.0.23/source/client/mount.cifs.c 2006-06-23 06:16:53.000000000 -0700 +++ samba-3.0.23.ben/source/client/mount.cifs.c 2006-07-20 17:14:10.000000000 -0700 @@ -95,6 +95,7 @@ printf(" to a local directory.\n\nOptions:\n"); printf("\tuser=\n\tpass=\n\tdom=\n"); printf("\nLess commonly used options:"); + printf("\n\tlocal_ip=,"); printf("\n\tcredentials=,guest,perm,noperm,setuids,nosetuids,rw,ro,"); printf("\n\tsep=,iocharset=,suid,nosuid,exec,noexec,serverino,"); printf("\n\tdirectio,mapchars,nomapchars,nolock,servernetbiosname="); @@ -467,6 +468,11 @@ printf("domain name too long\n"); return 1; } + } else if (strncmp(data, "local_ip", 8) == 0) { + if (!value || !*value) { + printf("CIFS: invalid local_ip\n"); + return 1; /* needs_arg; */ + } } else if (strncmp(data, "cred", 4) == 0) { if (value && *value) { rc = open_cred_file(value); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/client/smbctool.c samba-3.0.23.ben/source/client/smbctool.c --- samba-3.0.23/source/client/smbctool.c 2006-07-10 09:27:54.000000000 -0700 +++ samba-3.0.23.ben/source/client/smbctool.c 2006-07-13 13:09:35.000000000 -0700 @@ -63,6 +63,7 @@ static BOOL translation = False; static BOOL have_ip; +static struct local_bind_info local_binding; /* clitar bits insert */ extern int blocksize; @@ -3535,6 +3536,9 @@ { "name-resolve", 'R', POPT_ARG_STRING, &new_name_resolve_order, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, { "message", 'M', POPT_ARG_STRING, NULL, 'M', "Send message", "HOST" }, { "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" }, + { "local_ip", 'i', POPT_ARG_STRING, NULL, 'i', "Bind to this local IP", "IP" }, + { "local_port", 'P', POPT_ARG_STRING, NULL, 'P', "Bind to this local IP Port", "number" }, + { "local_dev", 'd', POPT_ARG_STRING, NULL, 'd', "Bind to this local device", "Interface-Name" }, { "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" }, { "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" }, { "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" }, @@ -3604,6 +3608,18 @@ cli_cm_set_dest_ip( dest_ip ); } break; + case 'i': + local_binding.local_ip = inet_addr(poptGetOptArg(pc)); + cli_cm_set_local_binding(&local_binding); + break; + case 'P': + local_binding.local_port = atoi(poptGetOptArg(pc)); + cli_cm_set_local_binding(&local_binding); + break; + case 'd': + strncpy(local_binding.local_dev, poptGetOptArg(pc), sizeof(local_binding.local_dev)); + cli_cm_set_local_binding(&local_binding); + break; case 'E': if (dbf) { x_fclose(dbf); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/client/smbmount.c samba-3.0.23.ben/source/client/smbmount.c --- samba-3.0.23/source/client/smbmount.c 2006-04-19 19:29:46.000000000 -0700 +++ samba-3.0.23.ben/source/client/smbmount.c 2006-07-17 11:14:15.000000000 -0700 @@ -38,6 +38,7 @@ static struct in_addr dest_ip; static BOOL have_ip; +static struct local_bind_info local_binding; static int smb_port = 0; static BOOL got_user; static BOOL got_pass; @@ -150,7 +151,7 @@ /* have to open a new connection */ if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) != smb_port) || - !cli_connect(c, server_n, &ip)) { + !cli_connect(c, server_n, &ip, &local_binding)) { DEBUG(0,("%d: Connection to %s failed\n", sys_getpid(), server_n)); if (c) { cli_shutdown(c); @@ -168,7 +169,7 @@ /* Use kerberos authentication if specified */ c->use_kerberos = use_kerberos; - if (!cli_session_request(c, &calling, &called)) { + if (!cli_session_request(c, &calling, &called, &local_binding)) { char *p; DEBUG(0,("%d: session request to %s failed (%s)\n", sys_getpid(), called.name, cli_errstr(c))); @@ -681,6 +682,9 @@ dmask= directory umask\n\ debug= debug level\n\ ip= destination host or IP address\n\ + local_ip= local IP address to which we should bind\n\ + local_port= local IP port to which we should bind\n\ + local_dev= local Network device to which we should bind\n\ workgroup= workgroup on destination\n\ sockopt= TCP socket options\n\ scope= NetBIOS scope\n\ @@ -801,6 +805,13 @@ exit(1); } have_ip = True; + } else if(!strcmp(opts, "local_ip")) { + local_binding.local_ip = inet_addr(opteq+1); + } else if(!strcmp(opts, "local_port")) { + local_binding.local_port = atoi(opteq+1); + } else if(!strcmp(opts, "local_dev")) { + strncpy(local_binding.dev_name, opteq+1, + sizeof(local_binding.dev_name)); } else if(!strcmp(opts, "workgroup")) { pstrcpy(workgroup,opteq+1); } else if(!strcmp(opts, "sockopt")) { diff -Naur -X samba_excludes --recursive samba-3.0.23/source/client/smbspool.c samba-3.0.23.ben/source/client/smbspool.c --- samba-3.0.23/source/client/smbspool.c 2006-07-10 09:27:54.000000000 -0700 +++ samba-3.0.23.ben/source/client/smbspool.c 2006-07-14 16:24:11.000000000 -0700 @@ -44,8 +44,8 @@ */ static void list_devices(void); -static struct cli_state *smb_complete_connection(const char *, const char *,int , const char *, const char *, const char *, const char *, int); -static struct cli_state *smb_connect(const char *, const char *, int, const char *, const char *, const char *, const char *); +static struct cli_state *smb_complete_connection(const char *, const char *,int , const char *, const char *, const char *, const char *, int, struct local_bind_info* local_binding); +static struct cli_state *smb_connect(const char *, const char *, int, const char *, const char *, const char *, const char *, struct local_bind_info* local_binding); static int smb_print(struct cli_state *, char *, FILE *); @@ -230,7 +230,7 @@ do { - if ((cli = smb_connect(workgroup, server, port, printer, username, password, argv[2])) == NULL) + if ((cli = smb_connect(workgroup, server, port, printer, username, password, argv[2], NULL /* local_bind info, not supported currently. */)) == NULL) { if (getenv("CLASS") == NULL) { @@ -365,14 +365,15 @@ const char *password, const char *workgroup, const char *share, - int flags) + int flags, + struct local_bind_info* local_binding) { struct cli_state *cli; /* New connection */ NTSTATUS nt_status; /* Start the SMB connection */ nt_status = cli_start_connection( &cli, myname, server, NULL, port, - Undefined, flags, NULL); + Undefined, flags, NULL, local_binding); if (!NT_STATUS_IS_OK(nt_status)) { return NULL; @@ -465,7 +466,8 @@ const char *share, /* I - Printer */ const char *username, /* I - Username */ const char *password, /* I - Password */ - const char *jobusername) /* I - User who issued the print job */ + const char *jobusername, /* I - User who issued the print job */ + struct local_bind_info* local_binding) /* I - Local socket binding information */ { struct cli_state *cli; /* New connection */ pstring myname; /* Client name */ @@ -483,7 +485,7 @@ if ( username && *username ) { cli = smb_complete_connection(myname, server, port, username, - password, workgroup, share, 0 ); + password, workgroup, share, 0, local_binding); if (cli) return cli; } @@ -493,7 +495,7 @@ */ cli = smb_complete_connection(myname, server, port, jobusername, "", workgroup, share, - CLI_FULL_CONNECTION_USE_KERBEROS ); + CLI_FULL_CONNECTION_USE_KERBEROS, local_binding); if (cli ) { return cli; } @@ -505,7 +507,7 @@ } cli = smb_complete_connection(myname, server, port, pwd->pw_name, "", - workgroup, share, 0); + workgroup, share, 0, local_binding); if (cli) { return cli; } @@ -514,7 +516,7 @@ */ cli = smb_complete_connection(myname, server, port, "", "", - workgroup, share, 0); + workgroup, share, 0, local_binding); /* * Return the new connection... */ diff -Naur -X samba_excludes --recursive samba-3.0.23/source/include/libmsrpc.h samba-3.0.23.ben/source/include/libmsrpc.h --- samba-3.0.23/source/include/libmsrpc.h 2006-04-19 19:29:39.000000000 -0700 +++ samba-3.0.23.ben/source/include/libmsrpc.h 2006-07-13 16:42:01.000000000 -0700 @@ -490,7 +490,7 @@ * @return CAC_FAILURE if the operation could not be completed successfully (hnd->status will also be set with a NTSTATUS code) * @return CAC_SUCCESS if the operation succeeded */ -int cac_Connect(CacServerHandle *hnd, const char *srv); +int cac_Connect(CacServerHandle *hnd, const char *srv, struct local_bind_info* local_binding); /** diff -Naur -X samba_excludes --recursive samba-3.0.23/source/include/libsmbclient.h samba-3.0.23.ben/source/include/libsmbclient.h --- samba-3.0.23/source/include/libsmbclient.h 2006-04-19 19:29:39.000000000 -0700 +++ samba-3.0.23.ben/source/include/libsmbclient.h 2006-07-13 16:41:01.000000000 -0700 @@ -393,6 +393,11 @@ */ char * workgroup; + /** Local bind information. This can be used to cause sockets to be locally bound + * to an IP and port, and to a network interface (on Linux). + */ + struct local_bind_info local_binding; + /** username used for making connections */ char * user; @@ -687,13 +692,16 @@ * changed in smb.conf file. Allows caller to set * debugging if no smb.conf. * + * @param local_binding If specified, these values will be used to bind to the + * to the local IP address, port and/or network-device. + * * @return 0 on success, < 0 on error with errno set: * - ENOMEM Out of memory * - ENOENT The smb.conf file would not load * */ -int smbc_init(smbc_get_auth_data_fn fn, int debug); +int smbc_init(smbc_get_auth_data_fn fn, int debug, struct local_bind_info* local_binding); /**@ingroup misc * Set or retrieve the compatibility library's context pointer diff -Naur -X samba_excludes --recursive samba-3.0.23/source/include/smb.h samba-3.0.23.ben/source/include/smb.h --- samba-3.0.23/source/include/smb.h 2006-07-10 09:27:52.000000000 -0700 +++ samba-3.0.23.ben/source/include/smb.h 2006-07-13 12:38:07.000000000 -0700 @@ -1870,4 +1870,10 @@ /* Different reasons for closing a file. */ enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE}; +struct local_bind_info { + uint32 local_ip; /* 0 means don't bother binding. */ + uint16 local_port; /* 0 means 'any' */ + char dev_name[64]; /* Name of local device to which we should bind. */ +}; + #endif /* _SMB_H */ diff -Naur -X samba_excludes --recursive samba-3.0.23/source/lib/util_sock.c samba-3.0.23.ben/source/lib/util_sock.c --- samba-3.0.23/source/lib/util_sock.c 2006-05-23 11:54:32.000000000 -0700 +++ samba-3.0.23.ben/source/lib/util_sock.c 2006-07-17 11:25:08.000000000 -0700 @@ -845,7 +845,7 @@ Create an outgoing socket. timeout is in milliseconds. **************************************************************************/ -int open_socket_out(int type, struct in_addr *addr, int port ,int timeout) +int open_socket_out(int type, struct in_addr *addr, int port ,int timeout, struct local_bind_info* local_binding) { struct sockaddr_in sock_out; int res,ret; @@ -871,6 +871,48 @@ /* set it non-blocking */ set_blocking(res,False); + /* Do local binding, if we are given the information */ + if (local_binding) { + if (strlen(local_binding->dev_name)) { + /* Bind to specific device. */ +#ifndef __WIN32__ + if (setsockopt(res, SOL_SOCKET, SO_BINDTODEVICE, + local_binding->dev_name, + 16 /* max length that kernel can handle */)) { + printf("ERROR: open_socket_out, setsockopt (BINDTODEVICE): %s Not fatal in most cases..continuing...\n", + strerror(errno)); + } + else { + printf("Binding socket: %d to local device: %s\n", res, local_binding->dev_name); + } +#endif + } + + /* Bind to a local IP address, if specified */ + if (local_binding->local_ip != 0) { + struct sockaddr_in my_ip_addr; + int r; + printf("Binding socket: %d to local_ip: 0x%X\n", + res, local_binding->local_ip); + memset(&my_ip_addr, 0, sizeof(my_ip_addr)); + + my_ip_addr.sin_family = AF_INET; + my_ip_addr.sin_addr.s_addr = htonl(local_binding->local_ip); + my_ip_addr.sin_port = htons(local_binding->local_port); + + r = bind(res, (struct sockaddr*)(&my_ip_addr), sizeof(my_ip_addr)); + if (r < 0) { + //system("netstat -an"); + printf("open_socket_out: ERROR: tcp bind failed: %s, ip: 0x%X port: %i\n", + strerror(errno), local_binding->local_ip, + local_binding->local_port); + } + }/* if a local IP was specified */ + else { + printf("NOT Binding socket: %d to local_ip: 0x%X\n", res, local_binding->local_ip); + } + }/* If given local binding info */ + DEBUG(3,("Connecting to %s at port %d\n",inet_ntoa(*addr),port)); /* and connect it to the destination */ diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libads/krb5_setpw.c samba-3.0.23.ben/source/libads/krb5_setpw.c --- samba-3.0.23/source/libads/krb5_setpw.c 2006-06-23 06:16:52.000000000 -0700 +++ samba-3.0.23.ben/source/libads/krb5_setpw.c 2006-07-13 13:35:35.000000000 -0700 @@ -424,7 +424,7 @@ } else { sock = open_socket_out(SOCK_STREAM, addr, DEFAULT_KPASSWD_PORT, - LONG_CONNECT_TIMEOUT); + LONG_CONNECT_TIMEOUT, NULL /* local_binding info, not supported */); } if (sock == -1) { diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libmsrpc/libmsrpc.c samba-3.0.23.ben/source/libmsrpc/libmsrpc.c --- samba-3.0.23/source/libmsrpc/libmsrpc.c 2006-04-19 19:29:46.000000000 -0700 +++ samba-3.0.23.ben/source/libmsrpc/libmsrpc.c 2006-07-13 16:38:23.000000000 -0700 @@ -165,7 +165,7 @@ } -int cac_Connect(CacServerHandle *hnd, const char *srv) { +int cac_Connect(CacServerHandle *hnd, const char *srv, struct local_bind_info* local_binding) { if(!hnd) { return CAC_FAILURE; } @@ -187,6 +187,10 @@ if( !(hnd->_internal.ctx->internal->_initialized) ) { hnd->_internal.ctx->debug = hnd->debug; + if (local_binding) { + memcpy(&(hnd->_internal.ctx->local_binding), local_binding, sizeof(*local_binding)); + } + /*initialize the context*/ if(!smbc_init_context(hnd->_internal.ctx)) { return CAC_FAILURE; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libsmb/cliconnect.c samba-3.0.23.ben/source/libsmb/cliconnect.c --- samba-3.0.23/source/libsmb/cliconnect.c 2006-05-23 11:54:32.000000000 -0700 +++ samba-3.0.23.ben/source/libsmb/cliconnect.c 2006-07-13 12:45:53.000000000 -0700 @@ -1224,7 +1224,7 @@ ****************************************************************************/ BOOL cli_session_request(struct cli_state *cli, - struct nmb_name *calling, struct nmb_name *called) + struct nmb_name *calling, struct nmb_name *called, struct local_bind_info* local_binding) { char *p; int len = 4; @@ -1280,7 +1280,7 @@ /* SESSION RETARGET */ putip((char *)&cli->dest_ip,cli->inbuf+4); - cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, port, LONG_CONNECT_TIMEOUT); + cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, port, LONG_CONNECT_TIMEOUT, local_binding); if (cli->fd == -1) return False; @@ -1297,7 +1297,7 @@ return False; } depth++; - ret = cli_session_request(cli, calling, called); + ret = cli_session_request(cli, calling, called, local_binding); depth--; return ret; } @@ -1315,7 +1315,7 @@ Open the client sockets. ****************************************************************************/ -BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip) +BOOL cli_connect(struct cli_state *cli, const char *host, struct in_addr *ip, struct local_bind_info* local_binding) { int name_type = 0x20; char *p; @@ -1346,11 +1346,11 @@ /* try 445 first, then 139 */ int port = cli->port?cli->port:445; cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, - port, cli->timeout); + port, cli->timeout, local_binding); if (cli->fd == -1 && cli->port == 0) { port = 139; cli->fd = open_socket_out(SOCK_STREAM, &cli->dest_ip, - port, cli->timeout); + port, cli->timeout, local_binding); } if (cli->fd != -1) cli->port = port; @@ -1380,7 +1380,7 @@ const char *dest_host, struct in_addr *dest_ip, int port, int signing_state, int flags, - BOOL *retry) + BOOL *retry, struct local_bind_info* local_binding) { NTSTATUS nt_status; struct nmb_name calling; @@ -1416,7 +1416,7 @@ DEBUG(3,("Connecting to host=%s\n", dest_host)); - if (!cli_connect(cli, dest_host, &ip)) { + if (!cli_connect(cli, dest_host, &ip, local_binding)) { DEBUG(1,("cli_start_connection: failed to connect to %s (%s)\n", nmb_namestr(&called), inet_ntoa(ip))); cli_shutdown(cli); @@ -1430,7 +1430,7 @@ if (retry) *retry = True; - if (!cli_session_request(cli, &calling, &called)) { + if (!cli_session_request(cli, &calling, &called, local_binding)) { char *p; DEBUG(1,("session request to %s failed (%s)\n", called.name, cli_errstr(cli))); @@ -1489,7 +1489,7 @@ const char *user, const char *domain, const char *password, int flags, int signing_state, - BOOL *retry) + BOOL *retry, struct local_bind_info* local_binding) { NTSTATUS nt_status; struct cli_state *cli = NULL; @@ -1500,7 +1500,7 @@ } nt_status = cli_start_connection(&cli, my_name, dest_host, - dest_ip, port, signing_state, flags, retry); + dest_ip, port, signing_state, flags, retry, local_binding); if (!NT_STATUS_IS_OK(nt_status)) { return nt_status; @@ -1542,7 +1542,7 @@ ****************************************************************************/ BOOL attempt_netbios_session_request(struct cli_state *cli, const char *srchost, const char *desthost, - struct in_addr *pdest_ip) + struct in_addr *pdest_ip, struct local_bind_info* local_binding) { struct nmb_name calling, called; @@ -1558,7 +1558,7 @@ else make_nmb_name(&called, desthost, 0x20); - if (!cli_session_request(cli, &calling, &called)) { + if (!cli_session_request(cli, &calling, &called, local_binding)) { struct nmb_name smbservername; make_nmb_name(&smbservername , "*SMBSERVER", 0x20); @@ -1588,8 +1588,8 @@ cli_close_connection(cli); if (!cli_initialise(cli) || - !cli_connect(cli, desthost, pdest_ip) || - !cli_session_request(cli, &calling, &smbservername)) { + !cli_connect(cli, desthost, pdest_ip, local_binding) || + !cli_session_request(cli, &calling, &smbservername, local_binding)) { DEBUG(0,("attempt_netbios_session_request: %s rejected the session for \ name *SMBSERVER with error %s\n", desthost, cli_errstr(cli) )); return False; @@ -1650,7 +1650,8 @@ /* 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 user_auth_info *user_info, + struct local_bind_info* local_binding) { struct cli_state *cli; pstring myname; @@ -1660,7 +1661,7 @@ 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, Undefined, NULL); + CLI_FULL_CONNECTION_ANNONYMOUS_FALLBACK, Undefined, NULL, local_binding); if (NT_STATUS_IS_OK(nt_status)) { return cli; @@ -1669,7 +1670,7 @@ fstring remote_name; if (name_status_find("*", 0, 0, *server_ip, remote_name)) { - cli = get_ipc_connect(remote_name, server_ip, user_info); + cli = get_ipc_connect(remote_name, server_ip, user_info, local_binding); if (cli) return cli; } @@ -1689,7 +1690,7 @@ * entire network browse list) */ -struct cli_state *get_ipc_connect_master_ip(struct ip_service * mb_ip, pstring workgroup, struct user_auth_info *user_info) +struct cli_state *get_ipc_connect_master_ip(struct ip_service * mb_ip, pstring workgroup, struct user_auth_info *user_info, struct local_bind_info* local_binding) { static fstring name; struct cli_state *cli; @@ -1727,7 +1728,7 @@ DEBUG(4, ("found master browser %s, %s\n", name, inet_ntoa(mb_ip->ip))); - cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info); + cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info, local_binding); return cli; @@ -1738,7 +1739,8 @@ * connect to it. */ -struct cli_state *get_ipc_connect_master_ip_bcast(pstring workgroup, struct user_auth_info *user_info) +struct cli_state *get_ipc_connect_master_ip_bcast(pstring workgroup, struct user_auth_info *user_info, + struct local_bind_info* local_binding) { struct ip_service *ip_list; struct cli_state *cli; @@ -1756,7 +1758,7 @@ for (i = 0; i < count; i++) { DEBUG(99, ("Found master browser %s\n", inet_ntoa(ip_list[i].ip))); - cli = get_ipc_connect_master_ip(&ip_list[i], workgroup, user_info); + cli = get_ipc_connect_master_ip(&ip_list[i], workgroup, user_info, local_binding); if (cli) return(cli); } diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libsmb/clidfs.c samba-3.0.23.ben/source/libsmb/clidfs.c --- samba-3.0.23/source/libsmb/clidfs.c 2006-06-23 06:16:51.000000000 -0700 +++ samba-3.0.23.ben/source/libsmb/clidfs.c 2006-07-13 13:17:11.000000000 -0700 @@ -41,6 +41,7 @@ static int name_type = 0x20; static BOOL have_ip; static struct in_addr dest_ip; +static struct local_bind_info local_binding; static struct client_connection *connections; @@ -84,7 +85,7 @@ /* have to open a new connection */ if (!(c=cli_initialise(NULL)) || (cli_set_port(c, port) != port) || - !cli_connect(c, server_n, &ip)) { + !cli_connect(c, server_n, &ip, &local_binding)) { d_printf("Connection to %s failed\n", server_n); return NULL; } @@ -94,7 +95,7 @@ cli_setup_signing_state(c, signing_state); - if (!cli_session_request(c, &calling, &called)) { + if (!cli_session_request(c, &calling, &called, &local_binding)) { char *p; d_printf("session request to %s failed (%s)\n", called.name, cli_errstr(c)); @@ -346,7 +347,17 @@ /**************************************************************************** ****************************************************************************/ -void cli_cm_set_dest_ip(struct in_addr ip ) +void cli_cm_set_local_binding(struct local_bind_info* _local_binding ) +{ + if (_local_binding) { + memcpy(&local_binding, _local_binding, sizeof(local_binding)); + } + else { + memset(&local_binding, 0, sizeof(local_binding)); + } +} + +void cli_cm_set_dest_ip(struct in_addr ip) { dest_ip = ip; have_ip = True; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libsmb/libsmbclient.c samba-3.0.23.ben/source/libsmb/libsmbclient.c --- samba-3.0.23/source/libsmb/libsmbclient.c 2006-06-23 06:16:51.000000000 -0700 +++ samba-3.0.23.ben/source/libsmb/libsmbclient.c 2006-07-13 14:40:25.000000000 -0700 @@ -758,19 +758,19 @@ c.port = port_try_first; - if (!cli_connect(&c, server_n, &ip)) { + if (!cli_connect(&c, server_n, &ip, &(context->local_binding))) { /* First connection attempt failed. Try alternate port. */ c.port = port_try_next; - if (!cli_connect(&c, server_n, &ip)) { + if (!cli_connect(&c, server_n, &ip, &(context->local_binding))) { cli_shutdown(&c); errno = ETIMEDOUT; return NULL; } } - if (!cli_session_request(&c, &calling, &called)) { + if (!cli_session_request(&c, &calling, &called, &(context->local_binding))) { cli_shutdown(&c); if (strcmp(called.name, "*SMBSERVER")) { make_nmb_name(&called , "*SMBSERVER", 0x20); @@ -944,7 +944,7 @@ &ip, 0, "IPC$", "?????", username, workgroup, password, 0, - Undefined, NULL); + Undefined, NULL, &(context->local_binding)); if (! NT_STATUS_IS_OK(nt_status)) { DEBUG(1,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status))); @@ -2646,7 +2646,7 @@ inet_ntoa(ip_list[i].ip))); cli = get_ipc_connect_master_ip(&ip_list[i], - workgroup, &u_info); + workgroup, &u_info, &(context->local_binding)); /* cli == NULL is the master browser refused to talk or could not be found */ if ( !cli ) @@ -5868,6 +5868,7 @@ /* ADD REASONABLE DEFAULTS */ context->debug = 0; context->timeout = 20000; /* 20 seconds */ + memset(&context->local_binding, 0, sizeof(context->local_binding)); context->options.browse_max_lmb_count = 3; /* # LMBs to query */ context->options.urlencode_readdir_entries = False;/* backward compat */ diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libsmb/libsmb_compat.c samba-3.0.23.ben/source/libsmb/libsmb_compat.c --- samba-3.0.23/source/libsmb/libsmb_compat.c 2006-06-23 06:16:51.000000000 -0700 +++ samba-3.0.23.ben/source/libsmb/libsmb_compat.c 2006-07-13 16:28:20.000000000 -0700 @@ -113,7 +113,7 @@ -int smbc_init(smbc_get_auth_data_fn fn, int debug) +int smbc_init(smbc_get_auth_data_fn fn, int debug, struct local_bind_info* local_binding) { if (!smbc_compat_initialized) { statcont = smbc_new_context(); @@ -122,7 +122,11 @@ statcont->debug = debug; statcont->callbacks.auth_fn = fn; - + + if (local_binding) { + memcpy(&(statcont->local_binding), local_binding, sizeof(statcont->local_binding)); + } + if (!smbc_init_context(statcont)) { smbc_free_context(statcont, False); return -1; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libsmb/passchange.c samba-3.0.23.ben/source/libsmb/passchange.c --- samba-3.0.23/source/libsmb/passchange.c 2006-04-19 19:29:25.000000000 -0700 +++ samba-3.0.23.ben/source/libsmb/passchange.c 2006-07-13 13:39:26.000000000 -0700 @@ -46,7 +46,7 @@ ZERO_STRUCT(cli); - if (!cli_initialise(&cli) || !cli_connect(&cli, remote_machine, &ip)) { + if (!cli_initialise(&cli) || !cli_connect(&cli, remote_machine, &ip, NULL /* local_bind info, not supported currently. */)) { 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) ); return NT_STATUS_UNSUCCESSFUL; @@ -55,7 +55,7 @@ make_nmb_name(&calling, global_myname() , 0x0); make_nmb_name(&called , remote_machine, 0x20); - if (!cli_session_request(&cli, &calling, &called)) { + if (!cli_session_request(&cli, &calling, &called, NULL /* local_bind info, not supported currently. */)) { slprintf(err_str, err_str_len-1, "machine %s rejected the session setup. Error was : %s.\n", remote_machine, cli_errstr(&cli) ); cli_shutdown(&cli); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/libsmb/trusts_util.c samba-3.0.23.ben/source/libsmb/trusts_util.c --- samba-3.0.23/source/libsmb/trusts_util.c 2006-06-23 06:16:51.000000000 -0700 +++ samba-3.0.23.ben/source/libsmb/trusts_util.c 2006-07-13 13:30:45.000000000 -0700 @@ -169,7 +169,7 @@ /* setup the anonymous connection */ result = cli_full_connection( &cli, global_myname(), dc_name, &dc_ip, 0, "IPC$", "IPC", - "", "", "", 0, Undefined, &retry); + "", "", "", 0, Undefined, &retry, NULL /* local_bind info, not supported. */); if ( !NT_STATUS_IS_OK(result) ) goto done; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/nmbd/nmbd_synclists.c samba-3.0.23.ben/source/nmbd/nmbd_synclists.c --- samba-3.0.23/source/nmbd/nmbd_synclists.c 2005-10-17 19:45:04.000000000 -0700 +++ samba-3.0.23.ben/source/nmbd/nmbd_synclists.c 2006-07-13 13:37:42.000000000 -0700 @@ -76,14 +76,14 @@ * Patch from Andy Levine andyl@epicrealm.com. */ - if (!cli_initialise(&cli) || !cli_set_port(&cli, 139) || !cli_connect(&cli, name, &ip)) { + if (!cli_initialise(&cli) || !cli_set_port(&cli, 139) || !cli_connect(&cli, name, &ip, NULL /* local_bind info, not supported currently. */)) { return; } make_nmb_name(&calling, local_machine, 0x0); make_nmb_name(&called , name, nm_type); - if (!cli_session_request(&cli, &calling, &called)) { + if (!cli_session_request(&cli, &calling, &called, NULL /* local_bind info, not supported currently. */)) { cli_shutdown(&cli); return; } diff -Naur -X samba_excludes --recursive samba-3.0.23/source/nsswitch/winbindd_cm.c samba-3.0.23.ben/source/nsswitch/winbindd_cm.c --- samba-3.0.23/source/nsswitch/winbindd_cm.c 2006-06-23 06:16:50.000000000 -0700 +++ samba-3.0.23.ben/source/nsswitch/winbindd_cm.c 2006-07-13 13:40:38.000000000 -0700 @@ -243,7 +243,7 @@ make_nmb_name(&calling, global_myname(), 0x0); make_nmb_name(&called, "*SMBSERVER", 0x20); - if (!cli_session_request(*cli, &calling, &called)) { + if (!cli_session_request(*cli, &calling, &called, NULL /* local_bind info, not supported currently. */)) { DEBUG(8, ("cli_session_request failed for %s\n", controller)); result = NT_STATUS_UNSUCCESSFUL; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/rpcclient/cmd_spoolss.c samba-3.0.23.ben/source/rpcclient/cmd_spoolss.c --- samba-3.0.23/source/rpcclient/cmd_spoolss.c 2006-07-10 09:27:50.000000000 -0700 +++ samba-3.0.23.ben/source/rpcclient/cmd_spoolss.c 2006-07-13 16:04:13.000000000 -0700 @@ -2623,7 +2623,7 @@ lp_workgroup(), cmdline_auth_info.password, cmdline_auth_info.use_kerberos ? CLI_FULL_CONNECTION_USE_KERBEROS : 0, - cmdline_auth_info.signing_state, NULL); + cmdline_auth_info.signing_state, NULL, NULL /* local_bind info, not supported */); if ( !NT_STATUS_IS_OK(nt_status) ) return WERR_GENERAL_FAILURE; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/rpcclient/rpcclient.c samba-3.0.23.ben/source/rpcclient/rpcclient.c --- samba-3.0.23/source/rpcclient/rpcclient.c 2006-05-23 11:54:29.000000000 -0700 +++ samba-3.0.23.ben/source/rpcclient/rpcclient.c 2006-07-13 14:47:44.000000000 -0700 @@ -695,6 +695,7 @@ NTSTATUS nt_status; static int opt_port = 0; fstring new_workgroup; + struct local_bind_info local_binding; /* make sure the vars that get altered (4th field) are in a fixed location or certain compilers complain */ @@ -704,12 +705,17 @@ {"command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated cmds", "COMMANDS"}, {"dest-ip", 'I', POPT_ARG_STRING, &opt_ipaddr, 'I', "Specify destination IP address", "IP"}, {"port", 'p', POPT_ARG_INT, &opt_port, 'p', "Specify port number", "PORT"}, + { "local_ip", 'i', POPT_ARG_STRING, NULL, 'i', "Bind to this local IP", "IP" }, + { "local_port", 'P', POPT_ARG_STRING, NULL, 'P', "Bind to this local IP Port", "number" }, + { "local_dev", 'd', POPT_ARG_STRING, NULL, 'd', "Bind to this local device", "Interface-Name" }, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS POPT_TABLEEND }; + memset(&local_binding, 0, sizeof(local_binding)); + load_case_tables(); ZERO_STRUCT(server_ip); @@ -739,7 +745,17 @@ opt_ipaddr); return 1; } - } + break; + case 'i': + local_binding.local_ip = inet_addr(poptGetOptArg(pc)); + break; + case 'P': + local_binding.local_port = atoi(poptGetOptArg(pc)); + break; + case 'd': + strncpy(local_binding.dev_name, poptGetOptArg(pc), sizeof(local_binding.dev_name)); + break; + }/* switch */ } /* Get server as remaining unparsed argument. Print usage if more @@ -799,7 +815,7 @@ lp_workgroup(), cmdline_auth_info.password, cmdline_auth_info.use_kerberos ? CLI_FULL_CONNECTION_USE_KERBEROS : 0, - cmdline_auth_info.signing_state,NULL); + cmdline_auth_info.signing_state,NULL, &local_binding); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(0,("Cannot connect to server. Error was %s\n", nt_errstr(nt_status))); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/rpc_server/srv_spoolss_nt.c samba-3.0.23.ben/source/rpc_server/srv_spoolss_nt.c --- samba-3.0.23/source/rpc_server/srv_spoolss_nt.c 2006-06-09 12:30:31.000000000 -0700 +++ samba-3.0.23.ben/source/rpc_server/srv_spoolss_nt.c 2006-07-13 13:19:57.000000000 -0700 @@ -2541,7 +2541,8 @@ "", /* username */ "", /* domain */ "", /* password */ - 0, lp_client_signing(), NULL ); + 0, lp_client_signing(), NULL, + NULL /* local_binding_info, not currently supported. */); if ( !NT_STATUS_IS_OK( ret ) ) { DEBUG(2,("spoolss_connect_to_client: connection to [%s] failed!\n", diff -Naur -X samba_excludes --recursive samba-3.0.23/source/smbd/change_trust_pw.c samba-3.0.23.ben/source/smbd/change_trust_pw.c --- samba-3.0.23/source/smbd/change_trust_pw.c 2005-10-17 19:44:56.000000000 -0700 +++ samba-3.0.23.ben/source/smbd/change_trust_pw.c 2006-07-13 12:49:39.000000000 -0700 @@ -61,7 +61,7 @@ NULL, 0, "IPC$", "IPC", "", "", - "", 0, Undefined, NULL))) { + "", 0, Undefined, NULL, NULL))) { DEBUG(0,("modify_trust_password: Connection to %s failed!\n", dc_name)); nt_status = NT_STATUS_UNSUCCESSFUL; goto failed; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/net_ads.c samba-3.0.23.ben/source/utils/net_ads.c --- samba-3.0.23/source/utils/net_ads.c 2006-06-23 06:16:53.000000000 -0700 +++ samba-3.0.23.ben/source/utils/net_ads.c 2006-07-13 16:22:01.000000000 -0700 @@ -783,7 +783,7 @@ /* make RPC calls here */ if ( !NT_STATUS_IS_OK(connect_to_ipc_krb5(&cli, &ads->ldap_ip, - ads->config.ldap_server_name)) ) + ads->config.ldap_server_name, NULL /* local_bind info, not supported currently. */)) ) { goto done; } @@ -893,7 +893,7 @@ int ret = -1; struct cli_state *cli = NULL; - if ( !NT_STATUS_IS_OK(connect_to_ipc_krb5(&cli, ip, servername)) ) + if ( !NT_STATUS_IS_OK(connect_to_ipc_krb5(&cli, ip, servername, NULL /* local_bind info, not supported currently. */)) ) goto done; saf_store( cli->server_domain, cli->desthost ); @@ -1123,7 +1123,7 @@ /* Verify that everything is ok */ - if ( net_rpc_join_ok(short_domain_name, ads->config.ldap_server_name, &ads->ldap_ip) != 0 ) { + if ( net_rpc_join_ok(short_domain_name, ads->config.ldap_server_name, &ads->ldap_ip, NULL /* local_bind info, not supported */) != 0 ) { d_fprintf(stderr, "Failed to verify membership in domain!\n"); return -1; } @@ -1320,7 +1320,7 @@ opt_user_name, opt_workgroup, opt_password ? opt_password : "", CLI_FULL_CONNECTION_USE_KERBEROS, - Undefined, NULL); + Undefined, NULL, NULL /* local_bind info, not supported currently. */); if (NT_STATUS_IS_ERR(nt_status)) { d_fprintf(stderr, "Unable to open a connnection to %s to obtain data " diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/net.c samba-3.0.23.ben/source/utils/net.c --- samba-3.0.23/source/utils/net.c 2006-06-09 12:30:32.000000000 -0700 +++ samba-3.0.23.ben/source/utils/net.c 2006-07-13 13:48:05.000000000 -0700 @@ -162,7 +162,8 @@ NTSTATUS connect_to_service(struct cli_state **c, struct in_addr *server_ip, const char *server_name, const char *service_name, - const char *service_type) + const char *service_type, + struct local_bind_info* local_binding) { NTSTATUS nt_status; @@ -177,7 +178,7 @@ server_ip, opt_port, service_name, service_type, opt_user_name, opt_workgroup, - opt_password, 0, Undefined, NULL); + opt_password, 0, Undefined, NULL, local_binding); if (NT_STATUS_IS_OK(nt_status)) { return nt_status; @@ -207,16 +208,17 @@ connect to \\server\ipc$ ****************************************************************************/ NTSTATUS connect_to_ipc(struct cli_state **c, struct in_addr *server_ip, - const char *server_name) + const char *server_name, struct local_bind_info* local_binding) { - return connect_to_service(c, server_ip, server_name, "IPC$", "IPC"); + return connect_to_service(c, server_ip, server_name, "IPC$", "IPC", local_binding); } /**************************************************************************** connect to \\server\ipc$ anonymously ****************************************************************************/ NTSTATUS connect_to_ipc_anonymous(struct cli_state **c, - struct in_addr *server_ip, const char *server_name) + struct in_addr *server_ip, const char *server_name, + struct local_bind_info* local_binding) { NTSTATUS nt_status; @@ -224,7 +226,7 @@ server_ip, opt_port, "IPC$", "IPC", "", "", - "", 0, Undefined, NULL); + "", 0, Undefined, NULL, local_binding); if (NT_STATUS_IS_OK(nt_status)) { return nt_status; @@ -238,7 +240,8 @@ connect to \\server\ipc$ using KRB5 ****************************************************************************/ NTSTATUS connect_to_ipc_krb5(struct cli_state **c, - struct in_addr *server_ip, const char *server_name) + struct in_addr *server_ip, const char *server_name, + struct local_bind_info* local_binding) { NTSTATUS nt_status; @@ -247,7 +250,7 @@ "IPC$", "IPC", opt_user_name, opt_workgroup, opt_password, CLI_FULL_CONNECTION_USE_KERBEROS, - Undefined, NULL); + Undefined, NULL, local_binding); if (NT_STATUS_IS_OK(nt_status)) { return nt_status; @@ -285,7 +288,7 @@ } /* make a connection to a named pipe */ - nt_status = connect_to_ipc(&cli_tmp, NULL, server_name); + nt_status = connect_to_ipc(&cli_tmp, NULL, server_name, NULL /* local_bind info*/); if (!NT_STATUS_IS_OK(nt_status)) { SAFE_FREE(server_name); return nt_status; @@ -413,11 +416,12 @@ struct cli_state *net_make_ipc_connection( unsigned flags ) { - return net_make_ipc_connection_ex( NULL, NULL, NULL, flags ); + return net_make_ipc_connection_ex( NULL, NULL, NULL, flags, NULL /* local_bind info, not supported currently. */ ); } struct cli_state *net_make_ipc_connection_ex( const char *domain, const char *server, - struct in_addr *ip, unsigned flags) + struct in_addr *ip, unsigned flags, + struct local_bind_info* local_binding) { char *server_name = NULL; struct in_addr server_ip; @@ -435,9 +439,9 @@ } if (flags & NET_FLAGS_ANONYMOUS) { - nt_status = connect_to_ipc_anonymous(&cli, &server_ip, server_name); + nt_status = connect_to_ipc_anonymous(&cli, &server_ip, server_name, local_binding); } else { - nt_status = connect_to_ipc(&cli, &server_ip, server_name); + nt_status = connect_to_ipc(&cli, &server_ip, server_name, local_binding); } /* store the server in the affinity cache if it was a PDC */ diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/netlookup.c samba-3.0.23.ben/source/utils/netlookup.c --- samba-3.0.23/source/utils/netlookup.c 2006-04-19 19:29:41.000000000 -0700 +++ samba-3.0.23.ben/source/utils/netlookup.c 2006-07-13 13:59:50.000000000 -0700 @@ -103,7 +103,7 @@ #endif 0, Undefined, - NULL); + NULL, NULL /* local_bind info */); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(2,("create_cs: Connect failed. Error was %s\n", nt_errstr(nt_status))); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/net_rpc.c samba-3.0.23.ben/source/utils/net_rpc.c --- samba-3.0.23/source/utils/net_rpc.c 2006-07-10 09:27:53.000000000 -0700 +++ samba-3.0.23.ben/source/utils/net_rpc.c 2006-07-13 13:53:19.000000000 -0700 @@ -3716,7 +3716,7 @@ /* open share source */ nt_status = connect_to_service(&cp_clistate.cli_share_src, &cli->dest_ip, cli->desthost, - netname, "A:"); + netname, "A:", NULL /* local_bind info, not supported currently. */); if (!NT_STATUS_IS_OK(nt_status)) goto done; @@ -3725,7 +3725,7 @@ if (net_mode_share == NET_MODE_SHARE_MIGRATE) { /* open share destination */ nt_status = connect_to_service(&cp_clistate.cli_share_dst, - NULL, dst, netname, "A:"); + NULL, dst, netname, "A:", NULL /* local_bind info, not supported currently. */); if (!NT_STATUS_IS_OK(nt_status)) goto done; @@ -5632,7 +5632,7 @@ } /* connect to ipc$ as username/password */ - nt_status = connect_to_ipc(&cli, &server_ip, pdc_name); + nt_status = connect_to_ipc(&cli, &server_ip, pdc_name, NULL /* local_bind info, not supported currently. */); if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) { /* Is it trusting domain account for sure ? */ @@ -5649,7 +5649,7 @@ * Connect to \\server\ipc$ again (this time anonymously) */ - nt_status = connect_to_ipc_anonymous(&cli, &server_ip, (char*)pdc_name); + nt_status = connect_to_ipc_anonymous(&cli, &server_ip, (char*)pdc_name, NULL /* local_bind info, not supported currently. */); if (NT_STATUS_IS_ERR(nt_status)) { DEBUG(0, ("Couldn't connect to domain %s controller. Error was %s.\n", @@ -6282,10 +6282,10 @@ if (cli_initialise(&cli) == False) return False; - if (!cli_connect(&cli, server_name, &server_ip)) + if (!cli_connect(&cli, server_name, &server_ip, NULL /* local_bind info, not supported currently. */)) goto done; if (!attempt_netbios_session_request(&cli, global_myname(), - server_name, &server_ip)) + server_name, &server_ip, NULL /* local_bind info, not supported currently. */)) goto done; if (!cli_negprot(&cli)) goto done; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/net_rpc_join.c samba-3.0.23.ben/source/utils/net_rpc_join.c --- samba-3.0.23/source/utils/net_rpc_join.c 2006-06-23 06:16:53.000000000 -0700 +++ samba-3.0.23.ben/source/utils/net_rpc_join.c 2006-07-13 13:57:21.000000000 -0700 @@ -41,7 +41,8 @@ * @return A shell status integer (0 for success) * **/ -int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip ) +int net_rpc_join_ok(const char *domain, const char *server, struct in_addr *ip, + struct local_bind_info* local_binding) { uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS|NETLOGON_NEG_SCHANNEL; struct cli_state *cli = NULL; @@ -50,7 +51,7 @@ NTSTATUS ntret = NT_STATUS_UNSUCCESSFUL; /* Connect to remote machine */ - if (!(cli = net_make_ipc_connection_ex(domain, server, ip, (NET_FLAGS_ANONYMOUS|NET_FLAGS_PDC)))) { + if (!(cli = net_make_ipc_connection_ex(domain, server, ip, (NET_FLAGS_ANONYMOUS|NET_FLAGS_PDC), local_binding))) { return -1; } @@ -405,7 +406,7 @@ } /* double-check, connection from scratch */ - retval = net_rpc_join_ok(domain, cli->desthost, &cli->dest_ip); + retval = net_rpc_join_ok(domain, cli->desthost, &cli->dest_ip, NULL /* local_bind info, not supported currently. */); done: @@ -437,7 +438,7 @@ char *domain = smb_xstrdup(opt_target_workgroup); /* Display success or failure */ - if (net_rpc_join_ok(domain, NULL, NULL) != 0) { + if (net_rpc_join_ok(domain, NULL, NULL, NULL /* local_bind info, not supported currently. */) != 0) { fprintf(stderr,"Join to domain '%s' is not valid\n",domain); free(domain); return -1; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/net_rpc_printer.c samba-3.0.23.ben/source/utils/net_rpc_printer.c --- samba-3.0.23/source/utils/net_rpc_printer.c 2006-04-19 19:29:41.000000000 -0700 +++ samba-3.0.23.ben/source/utils/net_rpc_printer.c 2006-07-13 13:59:04.000000000 -0700 @@ -1717,7 +1717,7 @@ /* open print$-share on the src server */ nt_status = connect_to_service(&cli_share_src, &cli->dest_ip, - cli->desthost, "print$", "A:"); + cli->desthost, "print$", "A:", NULL /* local_bind info, not supported currently. */); if (!NT_STATUS_IS_OK(nt_status)) goto done; @@ -1726,7 +1726,7 @@ /* open print$-share on the dst server */ nt_status = connect_to_service(&cli_share_dst, &cli_dst->dest_ip, - cli_dst->desthost, "print$", "A:"); + cli_dst->desthost, "print$", "A:", NULL /* local_bind info, not supported currently. */); if (!NT_STATUS_IS_OK(nt_status)) return nt_status; diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/net_time.c samba-3.0.23.ben/source/utils/net_time.c --- samba-3.0.23/source/utils/net_time.c 2006-06-23 06:16:53.000000000 -0700 +++ samba-3.0.23.ben/source/utils/net_time.c 2006-07-13 13:58:17.000000000 -0700 @@ -24,7 +24,8 @@ /* return the time on a server. This does not require any authentication */ -static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone) +static time_t cli_servertime(const char *host, struct in_addr *ip, int *zone, + struct local_bind_info* local_binding) { struct nmb_name calling, called; time_t ret = 0; @@ -33,7 +34,7 @@ cli = cli_initialise(NULL); if (!cli) goto done; - if (!cli_connect(cli, host, ip)) { + if (!cli_connect(cli, host, ip, local_binding)) { fprintf(stderr,"Can't contact server\n"); goto done; } @@ -45,7 +46,7 @@ make_nmb_name(&called, "*SMBSERVER", 0x20); } - if (!cli_session_request(cli, &calling, &called)) { + if (!cli_session_request(cli, &calling, &called, local_binding)) { fprintf(stderr,"Session request failed\n"); goto done; } @@ -65,7 +66,7 @@ /* find the servers time on the opt_host host */ static time_t nettime(int *zone) { - return cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, zone); + return cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, zone, NULL /* local_bind info, not supported currently. */); } /* return a time as a string ready to be passed to /bin/date */ @@ -179,7 +180,7 @@ } /* default - print the time */ - t = cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, NULL); + t = cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL, NULL, NULL /* local_bind info, not supported currently. */); if (t == 0) return -1; d_printf("%s", ctime(&t)); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/smbcacls.c samba-3.0.23.ben/source/utils/smbcacls.c --- samba-3.0.23/source/utils/smbcacls.c 2006-06-23 06:16:53.000000000 -0700 +++ samba-3.0.23.ben/source/utils/smbcacls.c 2006-07-13 16:05:20.000000000 -0700 @@ -789,7 +789,7 @@ share, "?????", cmdline_auth_info.username, lp_workgroup(), cmdline_auth_info.password, 0, - cmdline_auth_info.signing_state, NULL))) { + cmdline_auth_info.signing_state, NULL, NULL /* local_bind info, not supported */))) { return c; } else { DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status))); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/smbcquotas.c samba-3.0.23.ben/source/utils/smbcquotas.c --- samba-3.0.23/source/utils/smbcquotas.c 2006-04-19 19:29:41.000000000 -0700 +++ samba-3.0.23.ben/source/utils/smbcquotas.c 2006-07-13 16:05:51.000000000 -0700 @@ -376,7 +376,7 @@ share, "?????", cmdline_auth_info.username, lp_workgroup(), cmdline_auth_info.password, 0, - cmdline_auth_info.signing_state, NULL))) { + cmdline_auth_info.signing_state, NULL, NULL /* local_bind info, not supported */))) { return c; } else { DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status))); diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/smbget.c samba-3.0.23.ben/source/utils/smbget.c --- samba-3.0.23/source/utils/smbget.c 2006-01-24 15:46:40.000000000 -0800 +++ samba-3.0.23.ben/source/utils/smbget.c 2006-07-13 16:51:40.000000000 -0700 @@ -581,7 +581,7 @@ return 1; } - if(smbc_init(get_auth_data, debuglevel) < 0) { + if(smbc_init(get_auth_data, debuglevel, NULL /* local_bind info, not supported */) < 0) { fprintf(stderr, "Unable to initialize libsmbclient\n"); return 1; } diff -Naur -X samba_excludes --recursive samba-3.0.23/source/utils/smbtree.c samba-3.0.23.ben/source/utils/smbtree.c --- samba-3.0.23/source/utils/smbtree.c 2006-05-23 11:54:35.000000000 -0700 +++ samba-3.0.23.ben/source/utils/smbtree.c 2006-07-13 14:42:27.000000000 -0700 @@ -85,11 +85,11 @@ master_workgroup)); use_bcast = True; } else if(!use_bcast) { - if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info))) + if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info, NULL /* local_bind info, not supported */))) return False; } - if (!(cli = get_ipc_connect_master_ip_bcast(master_workgroup, user_info))) { + if (!(cli = get_ipc_connect_master_ip_bcast(master_workgroup, user_info, NULL /* local_bind info, not supported */))) { DEBUG(4, ("Unable to find master browser by " "broadcast\n")); return False; @@ -117,7 +117,7 @@ return False; } - if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info))) + if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info, NULL /* local_bind info, not supported */))) return False; if (!cli_NetServerEnum(cli, workgroup, SV_TYPE_ALL, add_name, @@ -185,7 +185,7 @@ { struct cli_state *cli; - if (!(cli = get_ipc_connect(server_name, NULL, user_info))) + if (!(cli = get_ipc_connect(server_name, NULL, user_info, NULL /* local_bind info, not supported */))) return False; if (get_rpc_shares(cli, add_name, &shares)) diff -Naur -X samba_excludes --recursive samba-3.0.23/source/web/diagnose.c samba-3.0.23.ben/source/web/diagnose.c --- samba-3.0.23/source/web/diagnose.c 2005-12-20 07:28:39.000000000 -0800 +++ samba-3.0.23.ben/source/web/diagnose.c 2006-07-13 13:38:40.000000000 -0700 @@ -65,7 +65,7 @@ if (!cli_initialise(&cli)) return False; - if (!cli_connect(&cli, global_myname(), &loopback_ip)) { + if (!cli_connect(&cli, global_myname(), &loopback_ip, NULL /* local_bind info*/)) { cli_shutdown(&cli); return False; }