#include "../libcli/security/dom_sid.h"
#include "../libcli/security/security_token.h"
#include "lib/id_cache.h"
-
-extern bool global_machine_password_needs_changing;
+#include "serverid.h"
/* Internal message queue for deferred opens. */
struct pending_message_list {
return true;
}
- DEBUG(10,("pid[%d] wait for socket lock\n", (int)sys_getpid()));
+ DEBUG(10,("pid[%d] wait for socket lock\n", (int)getpid()));
do {
ok = fcntl_lock(
sconn->smb1.echo_handler.socket_lock_fd,
- SMB_F_SETLKW, 0, 0, F_WRLCK);
+ F_SETLKW, 0, 0, F_WRLCK);
} while (!ok && (errno == EINTR));
if (!ok) {
return false;
}
- DEBUG(10,("pid[%d] got for socket lock\n", (int)sys_getpid()));
+ DEBUG(10,("pid[%d] got for socket lock\n", (int)getpid()));
return true;
}
do {
ok = fcntl_lock(
sconn->smb1.echo_handler.socket_lock_fd,
- SMB_F_SETLKW, 0, 0, F_UNLCK);
+ F_SETLKW, 0, 0, F_UNLCK);
} while (!ok && (errno == EINTR));
if (!ok) {
return false;
}
- DEBUG(10,("pid[%d] unlocked socket\n", (int)sys_getpid()));
+ DEBUG(10,("pid[%d] unlocked socket\n", (int)getpid()));
return true;
}
* client failed.
*/
DEBUG(1,("pid[%d] Error writing %d bytes to client %s. %d. (%s)\n",
- (int)sys_getpid(), (int)len,
+ (int)getpid(), (int)len,
get_peer_addr(sconn->sock, addr, sizeof(addr)),
(int)ret, strerror(errno) ));
size_t unread_bytes, bool encrypted,
uint32_t seqnum)
{
+ struct smbXsrv_tcon *tcon;
+ NTSTATUS status;
+ NTTIME now;
size_t req_size = smb_len(inbuf) + 4;
+
/* Ensure we have at least smb_size bytes. */
if (req_size < smb_size) {
DEBUG(0,("init_smb_request: invalid request size %u\n",
(unsigned int)req_size ));
return false;
}
+
+ req->request_time = timeval_current();
+ now = timeval_to_nttime(&req->request_time);
+
req->cmd = CVAL(inbuf, smb_com);
req->flags2 = SVAL(inbuf, smb_flg2);
req->smbpid = SVAL(inbuf, smb_pid);
req->unread_bytes = unread_bytes;
req->encrypted = encrypted;
req->sconn = sconn;
- req->conn = conn_find(sconn,req->tid);
+ status = smb1srv_tcon_lookup(sconn->conn, req->tid, now, &tcon);
+ if (NT_STATUS_IS_OK(status)) {
+ req->conn = tcon->compat;
+ } else {
+ req->conn = NULL;
+ }
req->chain_fsp = NULL;
- req->chain_outbuf = NULL;
- req->done = false;
req->smb2req = NULL;
req->priv_paths = NULL;
+ req->chain = NULL;
smb_init_perfcount_data(&req->pcd);
/* Ensure we have at least wct words and 2 bytes of bcc. */
schedule it for immediate processing.
****************************************************************************/
-void schedule_deferred_open_message_smb(struct smbd_server_connection *sconn,
+bool schedule_deferred_open_message_smb(struct smbd_server_connection *sconn,
uint64_t mid)
{
struct pending_message_list *pml;
int i = 0;
if (sconn->using_smb2) {
- schedule_deferred_open_message_smb2(sconn, mid);
- return;
+ return schedule_deferred_open_message_smb2(sconn, mid);
}
for (pml = sconn->deferred_open_queue; pml; pml = pml->next) {
TALLOC_FREE(pml->te);
pml->te = te;
DLIST_PROMOTE(sconn->deferred_open_queue, pml);
- return;
+ return true;
}
}
DEBUG(10,("schedule_deferred_open_message_smb: failed to "
"find message mid %llu\n",
(unsigned long long)mid ));
+
+ return false;
}
/****************************************************************************
len = smb_len_tcp(data)+4;
for (i=1;i<100;i++) {
- if (asprintf(&fname, "/tmp/%s.%d.%s", name, i,
- type ? "req" : "resp") == -1) {
+ fname = talloc_asprintf(talloc_tos(),
+ "/tmp/%s.%d.%s",
+ name,
+ i,
+ type ? "req" : "resp");
+ if (fname == NULL) {
return;
}
fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644);
if (fd != -1 || errno != EEXIST) break;
+ TALLOC_FREE(fname);
}
if (fd != -1) {
ssize_t ret = write(fd, data, len);
close(fd);
DEBUG(0,("created %s len %lu\n", fname, (unsigned long)len));
}
- SAFE_FREE(fname);
+ TALLOC_FREE(fname);
}
/****************************************************************************
static connection_struct *switch_message(uint8 type, struct smb_request *req)
{
int flags;
- uint16 session_tag;
+ uint64_t session_tag;
connection_struct *conn = NULL;
struct smbd_server_connection *sconn = req->sconn;
+ NTTIME now = timeval_to_nttime(&req->request_time);
+ struct smbXsrv_session *session = NULL;
+ NTSTATUS status;
errno = 0;
conn = req->conn;
DEBUG(3,("switch message %s (pid %d) conn 0x%lx\n", smb_fn_name(type),
- (int)sys_getpid(), (unsigned long)conn));
+ (int)getpid(), (unsigned long)conn));
smb_dump(smb_fn_name(type), 1, (const char *)req->inbuf);
* JRA.
*/
+ /*
+ * lookup an existing session
+ *
+ * Note: for now we only check for NT_STATUS_NETWORK_SESSION_EXPIRED
+ * here, the main check is still in change_to_user()
+ */
+ status = smb1srv_session_lookup(sconn->conn,
+ session_tag,
+ now,
+ &session);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_SESSION_EXPIRED)) {
+ switch (type) {
+ case SMBsesssetupX:
+ status = NT_STATUS_OK;
+ break;
+ default:
+ DEBUG(1,("Error: session %llu is expired, mid=%llu.\n",
+ (unsigned long long)session_tag,
+ (unsigned long long)req->mid));
+ reply_nterror(req, NT_STATUS_NETWORK_SESSION_EXPIRED);
+ return conn;
+ }
+ }
+
if (session_tag != sconn->smb1.sessions.last_session_tag) {
- user_struct *vuser = NULL;
+ struct user_struct *vuser = NULL;
sconn->smb1.sessions.last_session_tag = session_tag;
- if(session_tag != UID_FIELD_INVALID) {
- vuser = get_valid_user_struct(sconn, session_tag);
- if (vuser) {
- set_current_user_info(
- vuser->session_info->unix_info->sanitized_username,
- vuser->session_info->unix_info->unix_name,
- vuser->session_info->info->domain_name);
- }
+ if (session) {
+ vuser = session->compat;
+ }
+ if (vuser) {
+ set_current_user_info(
+ vuser->session_info->unix_info->sanitized_username,
+ vuser->session_info->unix_info->unix_name,
+ vuser->session_info->info->domain_name);
}
}
conn = switch_message(req->cmd, req);
- if (req->done) {
- TALLOC_FREE(req);
- return;
- }
-
if (req->outbuf == NULL) {
return;
}
bool encrypted,
struct smb_perfcount_data *deferred_pcd)
{
- struct connection_struct *conn = NULL;
struct smb_request **reqs = NULL;
- struct smb_request *req, *first_req, *last_req;
- unsigned i, num_reqs;
- NTSTATUS status;
+ struct smb_request *req;
+ unsigned num_reqs;
bool ok;
ok = smb1_parse_chain(talloc_tos(), (uint8_t *)inbuf, sconn, encrypted,
seqnum, &reqs, &num_reqs);
if (!ok) {
- status = NT_STATUS_INVALID_PARAMETER;
- goto error;
+ char errbuf[smb_size];
+ error_packet(errbuf, 0, 0, NT_STATUS_INVALID_PARAMETER,
+ __LINE__, __FILE__);
+ if (!srv_send_smb(sconn, errbuf, true, seqnum, encrypted,
+ NULL)) {
+ exit_server_cleanly("construct_reply_chain: "
+ "srv_send_smb failed.");
+ }
+ return;
}
+ req = reqs[0];
+ req->inbuf = (uint8_t *)talloc_move(reqs, &inbuf);
+
+ req->conn = switch_message(req->cmd, req);
+
+ if (req->outbuf == NULL) {
+ /*
+ * Request has suspended itself, will come
+ * back here.
+ */
+ return;
+ }
+ smb_request_done(req);
+}
+
+/*
+ * To be called from an async SMB handler that is potentially chained
+ * when it is finished for shipping.
+ */
+
+void smb_request_done(struct smb_request *req)
+{
+ struct smb_request **reqs = NULL;
+ struct smb_request *first_req;
+ size_t i, num_reqs, next_index;
+ NTSTATUS status;
+
+ if (req->chain == NULL) {
+ first_req = req;
+ goto shipit;
+ }
+
+ reqs = req->chain;
+ num_reqs = talloc_array_length(reqs);
+
for (i=0; i<num_reqs; i++) {
- req = reqs[i];
+ if (reqs[i] == req) {
+ break;
+ }
+ }
+ if (i == num_reqs) {
+ /*
+ * Invalid chain, should not happen
+ */
+ status = NT_STATUS_INTERNAL_ERROR;
+ goto error;
+ }
+ next_index = i+1;
- if (i > 0) {
- /*
- * Get the session and tree ids and chain fsp
- * from the previous request into the current
- * one
- */
- struct smb_request *prev_req = reqs[i-1];
- const uint8_t *prev_outbuf = prev_req->outbuf;
+ while ((next_index < num_reqs) && (IVAL(req->outbuf, smb_rcls) == 0)) {
+ struct smb_request *next = reqs[next_index];
+ struct smbXsrv_tcon *tcon;
+ NTTIME now = timeval_to_nttime(&req->request_time);
- req->vuid = SVAL(prev_outbuf, smb_uid);
- req->tid = SVAL(prev_outbuf, smb_tid);
- req->conn = conn_find(req->sconn, req->tid);
- req->chain_fsp = prev_req->chain_fsp;
+ next->vuid = SVAL(req->outbuf, smb_uid);
+ next->tid = SVAL(req->outbuf, smb_tid);
+ status = smb1srv_tcon_lookup(req->sconn->conn, req->tid,
+ now, &tcon);
+ if (NT_STATUS_IS_OK(status)) {
+ req->conn = tcon->compat;
+ } else {
+ req->conn = NULL;
}
- req->inbuf = (uint8_t *)inbuf;
- conn = switch_message(req->cmd, req);
+ next->chain_fsp = req->chain_fsp;
+ next->inbuf = (uint8_t *)req->inbuf;
+
+ req = next;
+ req->conn = switch_message(req->cmd, req);
if (req->outbuf == NULL) {
- if (open_was_deferred(req->sconn, req->mid)) {
- TALLOC_FREE(reqs);
- return;
- }
- status = NT_STATUS_INTERNAL_ERROR;
- goto error;
- }
- if (IVAL(req->outbuf, smb_rcls) != 0) {
- break;
+ /*
+ * Request has suspended itself, will come
+ * back here.
+ */
+ return;
}
+ next_index += 1;
}
first_req = reqs[0];
- last_req = req;
-
- if (i == 0) {
- /*
- * The first request already gave an error, no need to
- * do any splicing
- */
- goto shipit;
- }
for (i=1; i<next_index; i++) {
- req = reqs[i];
+ bool ok;
- ok = smb_splice_chain(&first_req->outbuf, req->outbuf);
+ ok = smb_splice_chain(&first_req->outbuf, reqs[i]->outbuf);
if (!ok) {
status = NT_STATUS_INTERNAL_ERROR;
goto error;
}
- if (req == last_req) {
- break;
- }
}
- SSVAL(first_req->outbuf, smb_uid, SVAL(last_req->outbuf, smb_uid));
- SSVAL(first_req->outbuf, smb_tid, SVAL(last_req->outbuf, smb_tid));
+ SSVAL(first_req->outbuf, smb_uid, SVAL(req->outbuf, smb_uid));
+ SSVAL(first_req->outbuf, smb_tid, SVAL(req->outbuf, smb_tid));
/*
* This scary statement intends to set the
*/
SSVAL(first_req->outbuf, smb_flg2,
(SVAL(first_req->outbuf, smb_flg2) & ~FLAGS2_32_BIT_ERROR_CODES)
- |(SVAL(last_req->outbuf, smb_flg2) & FLAGS2_32_BIT_ERROR_CODES));
+ |(SVAL(req->outbuf, smb_flg2) & FLAGS2_32_BIT_ERROR_CODES));
/*
* Transfer the error codes from the subrequest to the main one
*/
- SSVAL(first_req->outbuf, smb_rcls, SVAL(last_req->outbuf, smb_rcls));
- SSVAL(first_req->outbuf, smb_err, SVAL(last_req->outbuf, smb_err));
+ SSVAL(first_req->outbuf, smb_rcls, SVAL(req->outbuf, smb_rcls));
+ SSVAL(first_req->outbuf, smb_err, SVAL(req->outbuf, smb_err));
- goto shipit;
+ _smb_setlen_large(
+ first_req->outbuf, talloc_get_size(first_req->outbuf) - 4);
shipit:
- _smb_setlen_large(first_req->outbuf,
- talloc_get_size(first_req->outbuf) - 4);
-
if (!srv_send_smb(first_req->sconn,
(char *)first_req->outbuf,
true, first_req->seqnum+1,
- IS_CONN_ENCRYPTED(conn)||first_req->encrypted,
+ IS_CONN_ENCRYPTED(req->conn)||first_req->encrypted,
&first_req->pcd)) {
exit_server_cleanly("construct_reply_chain: srv_send_smb "
"failed.");
}
- TALLOC_FREE(reqs);
+ TALLOC_FREE(req); /* non-chained case */
+ TALLOC_FREE(reqs); /* chained case */
return;
error:
{
char errbuf[smb_size];
error_packet(errbuf, 0, 0, status, __LINE__, __FILE__);
- if (!srv_send_smb(sconn, errbuf, true, seqnum, encrypted,
+ if (!srv_send_smb(req->sconn, errbuf, true,
+ req->seqnum+1, req->encrypted,
NULL)) {
exit_server_cleanly("construct_reply_chain: "
"srv_send_smb failed.");
}
}
- TALLOC_FREE(reqs);
+ TALLOC_FREE(req); /* non-chained case */
+ TALLOC_FREE(reqs); /* chained case */
}
/****************************************************************************
struct smb_request ***reqs, unsigned *num_reqs)
{
struct smb1_parse_chain_state state;
+ unsigned i;
state.mem_ctx = mem_ctx;
state.buf = buf;
TALLOC_FREE(state.reqs);
return false;
}
+ for (i=0; i<state.num_reqs; i++) {
+ state.reqs[i]->chain = state.reqs;
+ }
*reqs = state.reqs;
*num_reqs = state.num_reqs;
return true;
}
#ifdef CLUSTER_SUPPORT
+
+struct smbd_release_ip_state {
+ struct smbd_server_connection *sconn;
+ char addr[INET6_ADDRSTRLEN];
+};
+
/****************************************************************************
received when we should release a specific IP
****************************************************************************/
static void release_ip(const char *ip, void *priv)
{
- const char *addr = (const char *)priv;
+ struct smbd_release_ip_state *state =
+ talloc_get_type_abort(priv,
+ struct smbd_release_ip_state);
+ const char *addr = state->addr;
const char *p = addr;
if (strncmp("::ffff:", addr, 7) == 0) {
"our address is %s\n", ip, p));
if ((strcmp(p, ip) == 0) || ((p != addr) && strcmp(addr, ip) == 0)) {
- /* we can't afford to do a clean exit - that involves
- database writes, which would potentially mean we
- are still running after the failover has finished -
- we have to get rid of this process ID straight
- away */
DEBUG(0,("Got release IP message for our IP %s - exiting immediately\n",
ip));
- /* note we must exit with non-zero status so the unclean handler gets
- called in the parent, so that the brl database is tickled */
- _exit(1);
+ /*
+ * With SMB2 we should do a clean disconnect,
+ * the previous_session_id in the session setup
+ * will cleanup the old session, tcons and opens.
+ *
+ * A clean disconnect is needed in order to support
+ * durable handles.
+ *
+ * Note: typically this is never triggered
+ * as we got a TCP RST (triggered by ctdb event scripts)
+ * before we get CTDB_SRVID_RELEASE_IP.
+ *
+ * We used to call _exit(1) here, but as this was mostly never
+ * triggered and has implication on our process model,
+ * we can just use smbd_server_connection_terminate()
+ * (also for SMB1).
+ */
+ smbd_server_connection_terminate(state->sconn,
+ "CTDB_SRVID_RELEASE_IP");
+ return;
}
}
+static NTSTATUS smbd_register_ips(struct smbd_server_connection *sconn,
+ struct sockaddr_storage *srv,
+ struct sockaddr_storage *clnt)
+{
+ struct smbd_release_ip_state *state;
+ struct ctdbd_connection *cconn;
+
+ cconn = messaging_ctdbd_connection();
+ if (cconn == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ state = talloc_zero(sconn, struct smbd_release_ip_state);
+ if (state == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ state->sconn = sconn;
+ if (print_sockaddr(state->addr, sizeof(state->addr), srv) == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ return ctdbd_register_ips(cconn, srv, clnt, release_ip, state);
+}
+
static int client_get_tcp_info(int sock, struct sockaddr_storage *server,
struct sockaddr_storage *client)
{
/* check if we need to reload services */
check_reload(sconn, time_mono(NULL));
- /* Change machine password if neccessary. */
- attempt_machine_password_change();
-
/*
* Force a log file check.
*/
if (!fd_is_readable(sconn->sock)) {
DEBUG(10,("echo_handler[%d] the parent smbd was faster\n",
- (int)sys_getpid()));
+ (int)getpid()));
ok = smbd_unlock_socket_internal(sconn);
if (!ok) {
if (tevent_req_nterror(req, status)) {
tevent_req_nterror(req, status);
DEBUG(1, ("echo_handler[%d]: receive_smb_raw_talloc failed: %s\n",
- (int)sys_getpid(), nt_errstr(status)));
+ (int)getpid(), nt_errstr(status)));
return;
}
DEBUG(1, ("writev to parent failed: %s\n", strerror(err)));
exit(1);
}
- DEBUG(10,("echo_handler[%d]: forwarded pdu to main\n", (int)sys_getpid()));
+ DEBUG(10,("echo_handler[%d]: forwarded pdu to main\n", (int)getpid()));
smbd_echo_activate_writer(state);
}
iov->iov_len = buflen;
DEBUG(10,("echo_handler[%d]: forward to main\n",
- (int)sys_getpid()));
+ (int)getpid()));
smbd_echo_activate_writer(state);
}
goto fail;
}
- child = sys_fork();
+ child = fork();
if (child == 0) {
NTSTATUS status;
listener_pipe[1] = -1;
sconn->smb1.echo_handler.trusted_fd = listener_pipe[0];
- DEBUG(10,("fork_echo_handler: main[%d] echo_child[%d]\n", (int)sys_getpid(), child));
+ DEBUG(10,("fork_echo_handler: main[%d] echo_child[%d]\n", (int)getpid(), child));
/*
* Without smb signing this is the same as the normal smbd
return false;
}
-#if CLUSTER_SUPPORT
-
-static NTSTATUS smbd_register_ips(struct smbd_server_connection *sconn,
- struct sockaddr_storage *srv,
- struct sockaddr_storage *clnt)
-{
- struct ctdbd_connection *cconn;
- char tmp_addr[INET6_ADDRSTRLEN];
- char *addr;
-
- cconn = messaging_ctdbd_connection();
- if (cconn == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
-
- client_socket_addr(sconn->sock, tmp_addr, sizeof(tmp_addr));
- addr = talloc_strdup(cconn, tmp_addr);
- if (addr == NULL) {
- return NT_STATUS_NO_MEMORY;
- }
- return ctdbd_register_ips(cconn, srv, clnt, release_ip, addr);
-}
-
-#endif
-
static bool uid_in_use(const struct user_struct *user, uid_t uid)
{
while (user) {
id_cache_delete_from_cache(&id);
}
+NTSTATUS smbXsrv_connection_init_tables(struct smbXsrv_connection *conn,
+ enum protocol_types protocol)
+{
+ NTSTATUS status;
+
+ set_Protocol(protocol);
+ conn->protocol = protocol;
+
+ if (protocol >= PROTOCOL_SMB2_02) {
+ status = smb2srv_session_table_init(conn);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = smb2srv_open_table_init(conn);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ } else {
+ status = smb1srv_session_table_init(conn);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = smb1srv_tcon_table_init(conn);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ status = smb1srv_open_table_init(conn);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+static void smbd_tevent_trace_callback(enum tevent_trace_point point,
+ void *private_data)
+{
+ struct smbXsrv_connection *conn =
+ talloc_get_type_abort(private_data,
+ struct smbXsrv_connection);
+
+ switch (point) {
+ case TEVENT_TRACE_BEFORE_WAIT:
+ /*
+ * This just removes compiler warning
+ * without profile support
+ */
+ conn->smbd_idle_profstamp = 0;
+ START_PROFILE_STAMP(smbd_idle, conn->smbd_idle_profstamp);
+ break;
+ case TEVENT_TRACE_AFTER_WAIT:
+ END_PROFILE_STAMP(smbd_idle, conn->smbd_idle_profstamp);
+ break;
+ }
+}
+
/****************************************************************************
Process commands from the client
****************************************************************************/
void smbd_process(struct tevent_context *ev_ctx,
- struct smbd_server_connection *sconn)
+ struct messaging_context *msg_ctx,
+ int sock_fd,
+ bool interactive)
{
TALLOC_CTX *frame = talloc_stackframe();
+ struct smbXsrv_connection *conn;
+ struct smbd_server_connection *sconn;
struct sockaddr_storage ss;
struct sockaddr *sa = NULL;
socklen_t sa_socklen;
char *rhost;
int ret;
+ conn = talloc_zero(ev_ctx, struct smbXsrv_connection);
+ if (conn == NULL) {
+ DEBUG(0,("talloc_zero(struct smbXsrv_connection)\n"));
+ exit_server_cleanly("talloc_zero(struct smbXsrv_connection).\n");
+ }
+
+ conn->ev_ctx = ev_ctx;
+ conn->msg_ctx = msg_ctx;
+
+ sconn = talloc_zero(conn, struct smbd_server_connection);
+ if (!sconn) {
+ exit_server("failed to create smbd_server_connection");
+ }
+
+ conn->sconn = sconn;
+ sconn->conn = conn;
+
+ /*
+ * TODO: remove this...:-)
+ */
+ global_smbXsrv_connection = conn;
+
+ sconn->ev_ctx = ev_ctx;
+ sconn->msg_ctx = msg_ctx;
+ sconn->sock = sock_fd;
+ sconn->smb1.echo_handler.trusted_fd = -1;
+ sconn->smb1.echo_handler.socket_lock_fd = -1;
+
+ if (!interactive) {
+ smbd_setup_sig_term_handler(sconn);
+ smbd_setup_sig_hup_handler(sconn);
+
+ if (!serverid_register(messaging_server_id(msg_ctx),
+ FLAG_MSG_GENERAL|FLAG_MSG_SMBD
+ |FLAG_MSG_DBWRAP
+ |FLAG_MSG_PRINT_GENERAL)) {
+ exit_server_cleanly("Could not register myself in "
+ "serverid.tdb");
+ }
+ }
+
if (lp_srv_maxprotocol() >= PROTOCOL_SMB2_02) {
/*
* We're not making the decision here,
tsocket_address_string(remote_address, talloc_tos()),
tsocket_address_string(local_address, talloc_tos())));
- init_modules();
+ if (lp_preload_modules()) {
+ smb_load_modules(lp_preload_modules());
+ }
smb_perfcount_init();
exit_server("Could not open account policy tdb.\n");
}
- if (*lp_rootdir()) {
- if (chroot(lp_rootdir()) != 0) {
- DEBUG(0,("Failed to change root to %s\n", lp_rootdir()));
+ if (*lp_rootdir(talloc_tos())) {
+ if (chroot(lp_rootdir(talloc_tos())) != 0) {
+ DEBUG(0,("Failed to change root to %s\n",
+ lp_rootdir(talloc_tos())));
exit_server("Failed to chroot()");
}
if (chdir("/") == -1) {
- DEBUG(0,("Failed to chdir to / on chroot to %s\n", lp_rootdir()));
+ DEBUG(0,("Failed to chdir to / on chroot to %s\n", lp_rootdir(talloc_tos())));
exit_server("Failed to chroot()");
}
- DEBUG(0,("Changed root to %s\n", lp_rootdir()));
+ DEBUG(0,("Changed root to %s\n", lp_rootdir(talloc_tos())));
}
if (!srv_init_signing(sconn)) {
exit_server("Failed to init smb_signing");
}
+ if (!file_init(sconn)) {
+ exit_server("file_init() failed");
+ }
+
/* Setup oplocks */
if (!init_oplocks(sconn))
exit_server("Failed to init oplocks");
sconn->nbt.got_session = false;
- sconn->smb1.negprot.max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
+ sconn->smb1.negprot.max_recv = MIN(lp_max_xmit(),BUFFER_SIZE);
sconn->smb1.sessions.done_sesssetup = false;
sconn->smb1.sessions.max_send = BUFFER_SIZE;
sconn->smb1.sessions.last_session_tag = UID_FIELD_INVALID;
- /* this holds info on user ids that are already validated for this VC */
- sconn->smb1.sessions.next_vuid = VUID_OFFSET;
- conn_init(sconn);
if (!init_dptrs(sconn)) {
exit_server("init_dptrs() failed");
}
exit_server("failed to create smbd_server_connection fde");
}
+ sconn->conn->local_address = sconn->local_address;
+ sconn->conn->remote_address = sconn->remote_address;
+ sconn->conn->remote_hostname = sconn->remote_hostname;
+ sconn->conn->protocol = PROTOCOL_NONE;
+
TALLOC_FREE(frame);
+ tevent_set_trace_callback(ev_ctx, smbd_tevent_trace_callback, conn);
+
while (True) {
frame = talloc_stackframe_pool(8192);