This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
goto decoding;
if (*p == '/') {
+ int wl = strlen(context->workgroup);
- strncpy(server, context->workgroup,
- ((strlen(context->workgroup) < 16)
- ? strlen(context->workgroup)
- : 16));
- server[server_len - 1] = '\0';
+ if (wl > 16) {
+ wl = 16;
+ }
+
+ strncpy(server, context->workgroup, wl);
+ server[wl] = '\0';
return 0;
-
}
/*
smbc_check_server(SMBCCTX * context,
SMBCSRV * server)
{
- if ( send_keepalive(server->cli->fd) == False )
- return 1;
+ socklen_t size;
+ struct sockaddr addr;
+
+ /*
+ * Although the use of port 139 is not a guarantee that we're using
+ * netbios, we assume so. We don't want to send a keepalive packet if
+ * not netbios because it's not valid, and Vista, at least,
+ * disconnects the client on such a request.
+ */
+ if (server->cli->port == 139) {
+ /* Assuming netbios. Send a keepalive packet */
+ if ( send_keepalive(server->cli->fd) == False ) {
+ return 1;
+ }
+ } else {
+ /*
+ * Assuming not netbios. Try a different method to detect if
+ * the connection is still alive.
+ */
+ size = sizeof(addr);
+ if (getpeername(server->cli->fd, &addr, &size) == -1) {
+ return 1;
+ }
+ }
/* connection is ok */
return 0;
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);
fstring password,
POLICY_HND *pol)
{
+ int flags;
struct in_addr ip;
struct cli_state *ipc_cli;
struct rpc_pipe_client *pipe_hnd;
}
}
+ flags = 0;
+ if (context->flags & SMB_CTX_FLAG_USE_KERBEROS) {
+ flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
+ }
+
zero_ip(&ip);
nt_status = cli_full_connection(&ipc_cli,
global_myname(), server,
&ip, 0, "IPC$", "?????",
username, workgroup,
- password, 0,
+ password, flags,
Undefined, NULL);
if (! NT_STATUS_IS_OK(nt_status)) {
DEBUG(1,("cli_full_connection failed! (%s)\n",
}
/*d_printf(">>>open: resolved %s as %s\n", path, targetpath);*/
- if ( targetcli->dfsroot )
- {
- pstring temppath;
- pstrcpy(temppath, targetpath);
- cli_dfs_make_full_path( targetpath, targetcli->desthost, targetcli->share, temppath);
- }
-
if ((fd = cli_open(targetcli, targetpath, flags,
context->internal->_share_mode)) < 0) {
return False;
}
- if ( targetcli->dfsroot )
- {
- pstring temppath;
- pstrcpy(temppath, targetpath);
- cli_dfs_make_full_path(targetpath, targetcli->desthost,
- targetcli->share, temppath);
- }
-
if (!srv->no_pathinfo2 &&
cli_qpathinfo2(targetcli, targetpath,
create_time_ts,
}
if (!NT_STATUS_IS_OK(rpccli_lsa_lookup_names(pipe_hnd, ipc_cli->mem_ctx,
- pol, 1, &str, NULL, &sids,
+ pol, 1, &str, NULL, 1, &sids,
&types))) {
result = False;
goto done;
return -1;
}
n = strlen(p);
- } else {
+ } else if (sidstr[0] != '\0') {
n = snprintf(buf, bufsize,
",OWNER:%s", sidstr);
}
return -1;
}
n = strlen(p);
- } else {
+ } else if (sidstr[0] != '\0') {
n = snprintf(buf, bufsize,
",GROUP:%s", sidstr);
}
ace->access_mask);
}
}
- if (n > bufsize) {
+ if (!determine_size && n > bufsize) {
errno = ERANGE;
return -1;
}
ipc_srv = smbc_attr_server(context, server, share,
workgroup, user, password,
&pol);
- srv->no_nt_session = True;
+ if (! ipc_srv) {
+ srv->no_nt_session = True;
+ }
} else {
ipc_srv = NULL;
}
ipc_srv = smbc_attr_server(context, server, share,
workgroup, user, password,
&pol);
- srv->no_nt_session = True;
+ if (! ipc_srv) {
+ srv->no_nt_session = True;
+ }
} else {
ipc_srv = NULL;
}