Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/smbd/process.c

    r599 r745  
    44   Copyright (C) Andrew Tridgell 1992-1998
    55   Copyright (C) Volker Lendecke 2005-2007
    6    
     6
    77   This program is free software; you can redistribute it and/or modify
    88   it under the terms of the GNU General Public License as published by
    99   the Free Software Foundation; either version 3 of the License, or
    1010   (at your option) any later version.
    11    
     11
    1212   This program is distributed in the hope that it will be useful,
    1313   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1414   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1515   GNU General Public License for more details.
    16    
     16
    1717   You should have received a copy of the GNU General Public License
    1818   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2020
    2121#include "includes.h"
     22#include "../lib/tsocket/tsocket.h"
     23#include "system/filesys.h"
     24#include "smbd/smbd.h"
    2225#include "smbd/globals.h"
    23 #include "../librpc/gen_ndr/srv_dfs.h"
    24 #include "../librpc/gen_ndr/srv_dssetup.h"
    25 #include "../librpc/gen_ndr/srv_echo.h"
    26 #include "../librpc/gen_ndr/srv_eventlog.h"
    27 #include "../librpc/gen_ndr/srv_initshutdown.h"
    28 #include "../librpc/gen_ndr/srv_lsa.h"
    29 #include "../librpc/gen_ndr/srv_netlogon.h"
    30 #include "../librpc/gen_ndr/srv_ntsvcs.h"
    31 #include "../librpc/gen_ndr/srv_samr.h"
    32 #include "../librpc/gen_ndr/srv_spoolss.h"
    33 #include "../librpc/gen_ndr/srv_srvsvc.h"
    34 #include "../librpc/gen_ndr/srv_svcctl.h"
    35 #include "../librpc/gen_ndr/srv_winreg.h"
    36 #include "../librpc/gen_ndr/srv_wkssvc.h"
     26#include "librpc/gen_ndr/netlogon.h"
     27#include "../lib/async_req/async_sock.h"
     28#include "ctdbd_conn.h"
     29#include "../lib/util/select.h"
     30#include "printing/pcap.h"
     31#include "system/select.h"
     32#include "passdb.h"
     33#include "auth.h"
     34#include "messages.h"
     35#include "smbprofile.h"
     36#include "rpc_server/spoolss/srv_spoolss_nt.h"
     37#include "libsmb/libsmb.h"
     38#ifdef __OS2__
     39#define pipe(A) os2_pipe(A)
     40#endif
    3741
    3842extern bool global_machine_password_needs_changing;
     
    4044static void construct_reply_common(struct smb_request *req, const char *inbuf,
    4145                                   char *outbuf);
     46static struct pending_message_list *get_deferred_open_message_smb(uint64_t mid);
     47
     48static bool smbd_lock_socket_internal(struct smbd_server_connection *sconn)
     49{
     50        bool ok;
     51
     52        if (sconn->smb1.echo_handler.socket_lock_fd == -1) {
     53                return true;
     54        }
     55
     56        sconn->smb1.echo_handler.ref_count++;
     57
     58        if (sconn->smb1.echo_handler.ref_count > 1) {
     59                return true;
     60        }
     61
     62        DEBUG(10,("pid[%d] wait for socket lock\n", (int)sys_getpid()));
     63
     64        do {
     65                ok = fcntl_lock(
     66                        sconn->smb1.echo_handler.socket_lock_fd,
     67                        SMB_F_SETLKW, 0, 0, F_WRLCK);
     68        } while (!ok && (errno == EINTR));
     69
     70        if (!ok) {
     71                DEBUG(1, ("fcntl_lock failed: %s\n", strerror(errno)));
     72                return false;
     73        }
     74
     75        DEBUG(10,("pid[%d] got for socket lock\n", (int)sys_getpid()));
     76
     77        return true;
     78}
     79
     80void smbd_lock_socket(struct smbd_server_connection *sconn)
     81{
     82        if (!smbd_lock_socket_internal(sconn)) {
     83                exit_server_cleanly("failed to lock socket");
     84        }
     85}
     86
     87static bool smbd_unlock_socket_internal(struct smbd_server_connection *sconn)
     88{
     89        bool ok;
     90
     91        if (sconn->smb1.echo_handler.socket_lock_fd == -1) {
     92                return true;
     93        }
     94
     95        sconn->smb1.echo_handler.ref_count--;
     96
     97        if (sconn->smb1.echo_handler.ref_count > 0) {
     98                return true;
     99        }
     100
     101        do {
     102                ok = fcntl_lock(
     103                        sconn->smb1.echo_handler.socket_lock_fd,
     104                        SMB_F_SETLKW, 0, 0, F_UNLCK);
     105        } while (!ok && (errno == EINTR));
     106
     107        if (!ok) {
     108                DEBUG(1, ("fcntl_lock failed: %s\n", strerror(errno)));
     109                return false;
     110        }
     111
     112        DEBUG(10,("pid[%d] unlocked socket\n", (int)sys_getpid()));
     113
     114        return true;
     115}
     116
     117void smbd_unlock_socket(struct smbd_server_connection *sconn)
     118{
     119        if (!smbd_unlock_socket_internal(sconn)) {
     120                exit_server_cleanly("failed to unlock socket");
     121        }
     122}
    42123
    43124/* Accessor function for smb_read_error for smbd functions. */
     
    47128****************************************************************************/
    48129
    49 bool srv_send_smb(int fd, char *buffer,
     130bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
    50131                  bool do_signing, uint32_t seqnum,
    51132                  bool do_encrypt,
     
    57138        char *buf_out = buffer;
    58139
     140        smbd_lock_socket(sconn);
     141
    59142        if (do_signing) {
    60143                /* Sign the outgoing packet if required. */
    61                 srv_calculate_sign_mac(smbd_server_conn, buf_out, seqnum);
     144                srv_calculate_sign_mac(sconn, buf_out, seqnum);
    62145        }
    63146
     
    74157        len = smb_len(buf_out) + 4;
    75158
    76         ret = write_data(fd,buf_out+nwritten,len - nwritten);
     159        ret = write_data(sconn->sock, buf_out+nwritten, len - nwritten);
    77160        if (ret <= 0) {
    78                 DEBUG(0,("Error writing %d bytes to client. %d. (%s)\n",
    79                          (int)len,(int)ret, strerror(errno) ));
     161
     162                char addr[INET6_ADDRSTRLEN];
     163                /*
     164                 * Try and give an error message saying what
     165                 * client failed.
     166                 */
     167                DEBUG(1,("pid[%d] Error writing %d bytes to client %s. %d. (%s)\n",
     168                         (int)sys_getpid(), (int)len,
     169                         get_peer_addr(sconn->sock, addr, sizeof(addr)),
     170                         (int)ret, strerror(errno) ));
     171
    80172                srv_free_enc_buffer(buf_out);
    81173                goto out;
     
    86178out:
    87179        SMB_PERFCOUNT_END(pcd);
     180
     181        smbd_unlock_socket(sconn);
    88182        return true;
    89183}
     
    139233                                      unsigned int timeout, ssize_t len)
    140234{
     235        NTSTATUS status;
     236
    141237        if (len <= 0) {
    142238                return NT_STATUS_OK;
    143239        }
    144240
    145         return read_fd_with_timeout(fd, buffer, len, len, timeout, NULL);
     241        status = read_fd_with_timeout(fd, buffer, len, len, timeout, NULL);
     242        if (!NT_STATUS_IS_OK(status)) {
     243                char addr[INET6_ADDRSTRLEN];
     244                DEBUG(0, ("read_fd_with_timeout failed for client %s read "
     245                          "error = %s.\n",
     246                          get_peer_addr(fd, addr, sizeof(addr)),
     247                          nt_errstr(status)));
     248        }
     249        return status;
    146250}
    147251
     
    164268static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx,
    165269                                                    const char lenbuf[4],
    166                                                     int fd, char **buffer,
     270                                                    struct smbd_server_connection *sconn,
     271                                                    int sock,
     272                                                    char **buffer,
    167273                                                    unsigned int timeout,
    168274                                                    size_t *p_unread,
     
    178284
    179285        status = read_fd_with_timeout(
    180                 fd, writeX_header + 4,
     286                sock, writeX_header + 4,
    181287                STANDARD_WRITE_AND_X_HEADER_SIZE,
    182288                STANDARD_WRITE_AND_X_HEADER_SIZE,
     
    184290
    185291        if (!NT_STATUS_IS_OK(status)) {
     292                DEBUG(0, ("read_fd_with_timeout failed for client %s read "
     293                          "error = %s.\n", sconn->client_id.addr,
     294                          nt_errstr(status)));
    186295                return status;
    187296        }
     
    192301         */
    193302
    194         if (is_valid_writeX_buffer((uint8_t *)writeX_header)) {
     303        if (is_valid_writeX_buffer(sconn, (uint8_t *)writeX_header)) {
    195304                /*
    196305                 * If the data offset is beyond what
     
    202311                if (doff > STANDARD_WRITE_AND_X_HEADER_SIZE) {
    203312                        size_t drain = doff - STANDARD_WRITE_AND_X_HEADER_SIZE;
    204                         if (drain_socket(smbd_server_fd(), drain) != drain) {
     313                        if (drain_socket(sock, drain) != drain) {
    205314                                smb_panic("receive_smb_raw_talloc_partial_read:"
    206315                                        " failed to drain pending bytes");
     
    257366        if(toread > 0) {
    258367                status = read_packet_remainder(
    259                         fd, (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE,
     368                        sock,
     369                        (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE,
    260370                        timeout, toread);
    261371
     
    271381}
    272382
    273 static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd,
     383static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx,
     384                                       struct smbd_server_connection *sconn,
     385                                       int sock,
    274386                                       char **buffer, unsigned int timeout,
    275387                                       size_t *p_unread, size_t *plen)
     
    282394        *p_unread = 0;
    283395
    284         status = read_smb_length_return_keepalive(fd, lenbuf, timeout, &len);
     396        status = read_smb_length_return_keepalive(sock, lenbuf, timeout,
     397                                                  &len);
    285398        if (!NT_STATUS_IS_OK(status)) {
    286                 DEBUG(10, ("receive_smb_raw: %s\n", nt_errstr(status)));
    287399                return status;
    288400        }
     
    291403            (smb_len_large(lenbuf) > /* Could be a UNIX large writeX. */
    292404                (min_recv_size + STANDARD_WRITE_AND_X_HEADER_SIZE)) &&
    293             !srv_is_signing_active(smbd_server_conn)) {
     405            !srv_is_signing_active(sconn) &&
     406            sconn->smb1.echo_handler.trusted_fde == NULL) {
    294407
    295408                return receive_smb_raw_talloc_partial_read(
    296                         mem_ctx, lenbuf, fd, buffer, timeout, p_unread, plen);
     409                        mem_ctx, lenbuf, sconn, sock, buffer, timeout,
     410                        p_unread, plen);
    297411        }
    298412
     
    315429        memcpy(*buffer, lenbuf, sizeof(lenbuf));
    316430
    317         status = read_packet_remainder(fd, (*buffer)+4, timeout, len);
     431        status = read_packet_remainder(sock, (*buffer)+4, timeout, len);
    318432        if (!NT_STATUS_IS_OK(status)) {
    319433                return status;
     
    324438}
    325439
    326 static NTSTATUS receive_smb_talloc(TALLOC_CTX *mem_ctx, int fd,
     440static NTSTATUS receive_smb_talloc(TALLOC_CTX *mem_ctx,
     441                                   struct smbd_server_connection *sconn,
     442                                   int sock,
    327443                                   char **buffer, unsigned int timeout,
    328444                                   size_t *p_unread, bool *p_encrypted,
    329445                                   size_t *p_len,
    330                                    uint32_t *seqnum)
     446                                   uint32_t *seqnum,
     447                                   bool trusted_channel)
    331448{
    332449        size_t len = 0;
     
    335452        *p_encrypted = false;
    336453
    337         status = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout,
     454        status = receive_smb_raw_talloc(mem_ctx, sconn, sock, buffer, timeout,
    338455                                        p_unread, &len);
    339456        if (!NT_STATUS_IS_OK(status)) {
     457                DEBUG(1, ("read_smb_length_return_keepalive failed for "
     458                          "client %s read error = %s.\n",
     459                          sconn->client_id.addr, nt_errstr(status)));
    340460                return status;
    341461        }
     
    353473
    354474        /* Check the incoming SMB signature. */
    355         if (!srv_check_sign_mac(smbd_server_conn, *buffer, seqnum)) {
     475        if (!srv_check_sign_mac(sconn, *buffer, seqnum, trusted_channel)) {
    356476                DEBUG(0, ("receive_smb: SMB Signature verification failed on "
    357477                          "incoming packet!\n"));
     
    367487 */
    368488
    369 void init_smb_request(struct smb_request *req,
    370                         const uint8 *inbuf,
    371                         size_t unread_bytes,
    372                         bool encrypted)
    373 {
    374         struct smbd_server_connection *sconn = smbd_server_conn;
     489static bool init_smb_request(struct smb_request *req,
     490                             struct smbd_server_connection *sconn,
     491                             const uint8 *inbuf,
     492                             size_t unread_bytes, bool encrypted,
     493                             uint32_t seqnum)
     494{
    375495        size_t req_size = smb_len(inbuf) + 4;
    376496        /* Ensure we have at least smb_size bytes. */
     
    378498                DEBUG(0,("init_smb_request: invalid request size %u\n",
    379499                        (unsigned int)req_size ));
    380                 exit_server_cleanly("Invalid SMB request");
     500                return false;
    381501        }
    382502        req->cmd    = CVAL(inbuf, smb_com);
    383503        req->flags2 = SVAL(inbuf, smb_flg2);
    384504        req->smbpid = SVAL(inbuf, smb_pid);
    385         req->mid    = SVAL(inbuf, smb_mid);
    386         req->seqnum = 0;
     505        req->mid    = (uint64_t)SVAL(inbuf, smb_mid);
     506        req->seqnum = seqnum;
    387507        req->vuid   = SVAL(inbuf, smb_uid);
    388508        req->tid    = SVAL(inbuf, smb_tid);
     
    393513        req->unread_bytes = unread_bytes;
    394514        req->encrypted = encrypted;
     515        req->sconn = sconn;
    395516        req->conn = conn_find(sconn,req->tid);
    396517        req->chain_fsp = NULL;
    397518        req->chain_outbuf = NULL;
    398519        req->done = false;
     520        req->smb2req = NULL;
    399521        smb_init_perfcount_data(&req->pcd);
    400522
     
    404526                        (unsigned int)req->wct,
    405527                        (unsigned int)req_size));
    406                 exit_server_cleanly("Invalid SMB request");
     528                return false;
    407529        }
    408530        /* Ensure bcc is correct. */
     
    413535                        (unsigned int)req->wct,
    414536                        (unsigned int)req_size));
    415                 exit_server_cleanly("Invalid SMB request");
     537                return false;
    416538        }
    417539
    418540        req->outbuf = NULL;
     541        return true;
    419542}
    420543
     
    432555                                           struct pending_message_list);
    433556        TALLOC_CTX *mem_ctx = talloc_tos();
    434         uint16_t mid = SVAL(msg->buf.data,smb_mid);
     557        uint64_t mid = (uint64_t)SVAL(msg->buf.data,smb_mid);
    435558        uint8_t *inbuf;
    436559
     
    444567        /* We leave this message on the queue so the open code can
    445568           know this is a retry. */
    446         DEBUG(5,("smbd_deferred_open_timer: trigger mid %u.\n",
    447                 (unsigned int)mid ));
     569        DEBUG(5,("smbd_deferred_open_timer: trigger mid %llu.\n",
     570                (unsigned long long)mid ));
    448571
    449572        /* Mark the message as processed so this is not
     
    456579
    457580        /* If it's still there and was processed, remove it. */
    458         msg = get_open_deferred_message(mid);
     581        msg = get_deferred_open_message_smb(mid);
    459582        if (msg && msg->processed) {
    460                 remove_deferred_open_smb_message(mid);
     583                remove_deferred_open_message_smb(mid);
    461584        }
    462585}
     
    528651****************************************************************************/
    529652
    530 void remove_deferred_open_smb_message(uint16 mid)
     653void remove_deferred_open_message_smb(uint64_t mid)
    531654{
    532655        struct pending_message_list *pml;
    533656
     657        if (smbd_server_conn->using_smb2) {
     658                remove_deferred_open_message_smb2(smbd_server_conn, mid);
     659                return;
     660        }
     661
    534662        for (pml = deferred_open_queue; pml; pml = pml->next) {
    535                 if (mid == SVAL(pml->buf.data,smb_mid)) {
    536                         DEBUG(10,("remove_deferred_open_smb_message: "
    537                                   "deleting mid %u len %u\n",
    538                                   (unsigned int)mid,
     663                if (mid == (uint64_t)SVAL(pml->buf.data,smb_mid)) {
     664                        DEBUG(10,("remove_deferred_open_message_smb: "
     665                                  "deleting mid %llu len %u\n",
     666                                  (unsigned long long)mid,
    539667                                  (unsigned int)pml->buf.length ));
    540668                        DLIST_REMOVE(deferred_open_queue, pml);
     
    550678****************************************************************************/
    551679
    552 void schedule_deferred_open_smb_message(uint16 mid)
     680void schedule_deferred_open_message_smb(uint64_t mid)
    553681{
    554682        struct pending_message_list *pml;
    555683        int i = 0;
    556684
     685        if (smbd_server_conn->using_smb2) {
     686                schedule_deferred_open_message_smb2(smbd_server_conn, mid);
     687                return;
     688        }
     689
    557690        for (pml = deferred_open_queue; pml; pml = pml->next) {
    558                 uint16 msg_mid = SVAL(pml->buf.data,smb_mid);
    559 
    560                 DEBUG(10,("schedule_deferred_open_smb_message: [%d] msg_mid = %u\n", i++,
    561                         (unsigned int)msg_mid ));
     691                uint64_t msg_mid = (uint64_t)SVAL(pml->buf.data,smb_mid);
     692
     693                DEBUG(10,("schedule_deferred_open_message_smb: [%d] "
     694                        "msg_mid = %llu\n",
     695                        i++,
     696                        (unsigned long long)msg_mid ));
    562697
    563698                if (mid == msg_mid) {
     
    567702                                /* A processed message should not be
    568703                                 * rescheduled. */
    569                                 DEBUG(0,("schedule_deferred_open_smb_message: LOGIC ERROR "
    570                                         "message mid %u was already processed\n",
    571                                         msg_mid ));
     704                                DEBUG(0,("schedule_deferred_open_message_smb: LOGIC ERROR "
     705                                        "message mid %llu was already processed\n",
     706                                        (unsigned long long)msg_mid ));
    572707                                continue;
    573708                        }
    574709
    575                         DEBUG(10,("schedule_deferred_open_smb_message: scheduling mid %u\n",
    576                                 mid ));
     710                        DEBUG(10,("schedule_deferred_open_message_smb: "
     711                                "scheduling mid %llu\n",
     712                                (unsigned long long)mid ));
    577713
    578714                        te = event_add_timed(smbd_event_context(),
     
    582718                                             pml);
    583719                        if (!te) {
    584                                 DEBUG(10,("schedule_deferred_open_smb_message: "
    585                                           "event_add_timed() failed, skipping mid %u\n",
    586                                           mid ));
     720                                DEBUG(10,("schedule_deferred_open_message_smb: "
     721                                        "event_add_timed() failed, "
     722                                        "skipping mid %llu\n",
     723                                        (unsigned long long)msg_mid ));
    587724                        }
    588725
     
    594731        }
    595732
    596         DEBUG(10,("schedule_deferred_open_smb_message: failed to find message mid %u\n",
    597                 mid ));
     733        DEBUG(10,("schedule_deferred_open_message_smb: failed to "
     734                "find message mid %llu\n",
     735                (unsigned long long)mid ));
    598736}
    599737
     
    602740****************************************************************************/
    603741
    604 bool open_was_deferred(uint16 mid)
     742bool open_was_deferred(uint64_t mid)
    605743{
    606744        struct pending_message_list *pml;
    607745
     746        if (smbd_server_conn->using_smb2) {
     747                return open_was_deferred_smb2(smbd_server_conn, mid);
     748        }
     749
    608750        for (pml = deferred_open_queue; pml; pml = pml->next) {
    609                 if (SVAL(pml->buf.data,smb_mid) == mid && !pml->processed) {
     751                if (((uint64_t)SVAL(pml->buf.data,smb_mid)) == mid && !pml->processed) {
    610752                        return True;
    611753                }
     
    618760****************************************************************************/
    619761
    620 struct pending_message_list *get_open_deferred_message(uint16 mid)
     762static struct pending_message_list *get_deferred_open_message_smb(uint64_t mid)
    621763{
    622764        struct pending_message_list *pml;
    623765
    624766        for (pml = deferred_open_queue; pml; pml = pml->next) {
    625                 if (SVAL(pml->buf.data,smb_mid) == mid) {
     767                if (((uint64_t)SVAL(pml->buf.data,smb_mid)) == mid) {
    626768                        return pml;
    627769                }
    628770        }
    629771        return NULL;
     772}
     773
     774/****************************************************************************
     775 Get the state data queued by this mid.
     776****************************************************************************/
     777
     778bool get_deferred_open_message_state(struct smb_request *smbreq,
     779                                struct timeval *p_request_time,
     780                                void **pp_state)
     781{
     782        struct pending_message_list *pml;
     783
     784        if (smbd_server_conn->using_smb2) {
     785                return get_deferred_open_message_state_smb2(smbreq->smb2req,
     786                                        p_request_time,
     787                                        pp_state);
     788        }
     789
     790        pml = get_deferred_open_message_smb(smbreq->mid);
     791        if (!pml) {
     792                return false;
     793        }
     794        if (p_request_time) {
     795                *p_request_time = pml->request_time;
     796        }
     797        if (pp_state) {
     798                *pp_state = (void *)pml->private_data.data;
     799        }
     800        return true;
    630801}
    631802
     
    635806****************************************************************************/
    636807
    637 bool push_deferred_smb_message(struct smb_request *req,
     808bool push_deferred_open_message_smb(struct smb_request *req,
    638809                               struct timeval request_time,
    639810                               struct timeval timeout,
     811                               struct file_id id,
    640812                               char *private_data, size_t priv_len)
    641813{
    642814        struct timeval end_time;
    643815
     816        if (req->smb2req) {
     817                return push_deferred_open_message_smb2(req->smb2req,
     818                                                request_time,
     819                                                timeout,
     820                                                id,
     821                                                private_data,
     822                                                priv_len);
     823        }
     824
    644825        if (req->unread_bytes) {
    645                 DEBUG(0,("push_deferred_smb_message: logic error ! "
     826                DEBUG(0,("push_deferred_open_message_smb: logic error ! "
    646827                        "unread_bytes = %u\n",
    647828                        (unsigned int)req->unread_bytes ));
    648                 smb_panic("push_deferred_smb_message: "
     829                smb_panic("push_deferred_open_message_smb: "
    649830                        "logic error unread_bytes != 0" );
    650831        }
     
    652833        end_time = timeval_sum(&request_time, &timeout);
    653834
    654         DEBUG(10,("push_deferred_open_smb_message: pushing message len %u mid %u "
    655                   "timeout time [%u.%06u]\n",
    656                   (unsigned int) smb_len(req->inbuf)+4, (unsigned int)req->mid,
    657                   (unsigned int)end_time.tv_sec,
    658                   (unsigned int)end_time.tv_usec));
     835        DEBUG(10,("push_deferred_open_message_smb: pushing message "
     836                "len %u mid %llu timeout time [%u.%06u]\n",
     837                (unsigned int) smb_len(req->inbuf)+4,
     838                (unsigned long long)req->mid,
     839                (unsigned int)end_time.tv_sec,
     840                (unsigned int)end_time.tv_usec));
    659841
    660842        return push_queued_message(req, request_time, end_time,
     
    773955                                  void *private_data)
    774956{
     957        struct messaging_context *msg_ctx = talloc_get_type_abort(
     958                private_data, struct messaging_context);
    775959        change_to_root_user();
    776960        DEBUG(1,("Reloading services after SIGHUP\n"));
    777         reload_services(False);
    778 }
    779 
    780 void smbd_setup_sig_hup_handler(void)
     961        reload_services(msg_ctx, smbd_server_conn->sock, False);
     962        if (am_parent) {
     963                pcap_cache_reload(ev, msg_ctx, &reload_pcap_change_notify);
     964        }
     965}
     966
     967void smbd_setup_sig_hup_handler(struct tevent_context *ev,
     968                                struct messaging_context *msg_ctx)
    781969{
    782970        struct tevent_signal *se;
    783971
    784         se = tevent_add_signal(smbd_event_context(),
    785                                smbd_event_context(),
    786                                SIGHUP, 0,
    787                                smbd_sig_hup_handler,
    788                                NULL);
     972        se = tevent_add_signal(ev, ev, SIGHUP, 0, smbd_sig_hup_handler,
     973                               msg_ctx);
    789974        if (!se) {
    790975                exit_server("failed to setup SIGHUP handler");
     
    794979static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *conn)
    795980{
    796         fd_set r_fds, w_fds;
    797         int selrtn;
    798         struct timeval to;
    799         int maxfd = 0;
    800 
    801         to.tv_sec = SMBD_SELECT_TIMEOUT;
    802         to.tv_usec = 0;
    803 
    804         /*
    805          * Setup the select fd sets.
    806          */
    807 
    808         FD_ZERO(&r_fds);
    809         FD_ZERO(&w_fds);
     981        int timeout;
     982        int num_pfds = 0;
     983        int ret;
     984        bool retry;
     985
     986        timeout = SMBD_SELECT_TIMEOUT * 1000;
    810987
    811988        /*
     
    814991         */
    815992
    816         {
    817                 struct timeval now;
    818                 GetTimeOfDay(&now);
    819 
    820                 event_add_to_select_args(smbd_event_context(), &now,
    821                                          &r_fds, &w_fds, &to, &maxfd);
    822         }
     993        event_add_to_poll_args(smbd_event_context(), conn,
     994                               &conn->pfds, &num_pfds, &timeout);
    823995
    824996        /* Process a signal and timed events now... */
    825         if (run_events(smbd_event_context(), 0, NULL, NULL)) {
     997        if (run_events_poll(smbd_event_context(), 0, NULL, 0)) {
    826998                return NT_STATUS_RETRY;
    827999        }
     
    8311003                START_PROFILE(smbd_idle);
    8321004
    833                 selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&to);
     1005                ret = sys_poll(conn->pfds, num_pfds, timeout);
    8341006                sav = errno;
    8351007
     
    8381010        }
    8391011
    840         if (selrtn == -1 && errno != EINTR) {
     1012        if (ret == -1) {
     1013                if (errno == EINTR) {
     1014                        return NT_STATUS_RETRY;
     1015                }
    8411016                return map_nt_error_from_unix(errno);
    8421017        }
    8431018
    844         if (run_events(smbd_event_context(), selrtn, &r_fds, &w_fds)) {
     1019        retry = run_events_poll(smbd_event_context(), ret, conn->pfds,
     1020                                num_pfds);
     1021        if (retry) {
    8451022                return NT_STATUS_RETRY;
    8461023        }
    8471024
    848         /* Check if error */
    849         if (selrtn == -1) {
    850                 /* something is wrong. Maybe the socket is dead? */
    851                 return map_nt_error_from_unix(errno);
    852         }
    853 
    8541025        /* Did we timeout ? */
    855         if (selrtn == 0) {
     1026        if (ret == 0) {
    8561027                return NT_STATUS_RETRY;
    8571028        }
     
    8661037 */
    8671038
    868 NTSTATUS allow_new_trans(struct trans_state *list, int mid)
     1039NTSTATUS allow_new_trans(struct trans_state *list, uint64_t mid)
    8691040{
    8701041        int count = 0;
     
    12681439        uint16 session_tag;
    12691440        connection_struct *conn = NULL;
    1270         struct smbd_server_connection *sconn = smbd_server_conn;
     1441        struct smbd_server_connection *sconn = req->sconn;
    12711442
    12721443        errno = 0;
     
    13201491                        if (vuser) {
    13211492                                set_current_user_info(
    1322                                         vuser->server_info->sanitized_username,
    1323                                         vuser->server_info->unix_name,
    1324                                         pdb_get_domain(vuser->server_info
    1325                                                        ->sam_account));
     1493                                        vuser->session_info->sanitized_username,
     1494                                        vuser->session_info->unix_name,
     1495                                        vuser->session_info->info3->base.domain.string);
    13261496                        }
    13271497                }
     
    13471517                if (!change_to_user(conn,session_tag)) {
    13481518                        DEBUG(0, ("Error: Could not change to user. Removing "
    1349                             "deferred open, mid=%d.\n", req->mid));
     1519                                "deferred open, mid=%llu.\n",
     1520                                (unsigned long long)req->mid));
    13501521                        reply_force_doserror(req, ERRSRV, ERRbaduid);
    13511522                        return conn;
     
    13961567        if ((flags & AS_GUEST)
    13971568            && (!change_to_guest() ||
    1398                 !check_access(smbd_server_fd(), lp_hostsallow(-1),
    1399                               lp_hostsdeny(-1)))) {
     1569                !allow_access(lp_hostsdeny(-1), lp_hostsallow(-1),
     1570                              sconn->client_id.name,
     1571                              sconn->client_id.addr))) {
    14001572                reply_nterror(req, NT_STATUS_ACCESS_DENIED);
    14011573                return conn;
     
    14101582****************************************************************************/
    14111583
    1412 static void construct_reply(char *inbuf, int size, size_t unread_bytes,
     1584static void construct_reply(struct smbd_server_connection *sconn,
     1585                            char *inbuf, int size, size_t unread_bytes,
    14131586                            uint32_t seqnum, bool encrypted,
    14141587                            struct smb_perfcount_data *deferred_pcd)
     
    14211594        }
    14221595
    1423         init_smb_request(req, (uint8 *)inbuf, unread_bytes, encrypted);
     1596        if (!init_smb_request(req, sconn, (uint8 *)inbuf, unread_bytes,
     1597                              encrypted, seqnum)) {
     1598                exit_server_cleanly("Invalid SMB request");
     1599        }
     1600
    14241601        req->inbuf  = (uint8_t *)talloc_move(req, &inbuf);
    1425         req->seqnum = seqnum;
    14261602
    14271603        /* we popped this message off the queue - keep original perf data */
     
    14381614        if (req->unread_bytes) {
    14391615                /* writeX failed. drain socket. */
    1440                 if (drain_socket(smbd_server_fd(), req->unread_bytes) !=
     1616                if (drain_socket(req->sconn->sock, req->unread_bytes) !=
    14411617                                req->unread_bytes) {
    14421618                        smb_panic("failed to drain pending bytes");
     
    14581634        }
    14591635
    1460         if (!srv_send_smb(smbd_server_fd(),
     1636        if (!srv_send_smb(req->sconn,
    14611637                        (char *)req->outbuf,
    14621638                        true, req->seqnum+1,
     
    14741650 Process an smb from the client
    14751651****************************************************************************/
    1476 static void process_smb(struct smbd_server_connection *conn,
     1652static void process_smb(struct smbd_server_connection *sconn,
    14771653                        uint8_t *inbuf, size_t nread, size_t unread_bytes,
    14781654                        uint32_t seqnum, bool encrypted,
     
    14851661        DEBUG( 6, ( "got message type 0x%x of len 0x%x\n", msg_type,
    14861662                    smb_len(inbuf) ) );
    1487         DEBUG( 3, ( "Transaction %d of length %d (%u toread)\n", trans_num,
    1488                                 (int)nread,
    1489                                 (unsigned int)unread_bytes ));
     1663        DEBUG(3, ("Transaction %d of length %d (%u toread)\n",
     1664                  sconn->trans_num, (int)nread, (unsigned int)unread_bytes));
    14901665
    14911666        if (msg_type != 0) {
     
    14931668                 * NetBIOS session request, keepalive, etc.
    14941669                 */
    1495                 reply_special((char *)inbuf, nread);
     1670                reply_special(sconn, (char *)inbuf, nread);
    14961671                goto done;
    14971672        }
    14981673
    1499         if (smbd_server_conn->allow_smb2) {
     1674        if (sconn->using_smb2) {
     1675                /* At this point we're not really using smb2,
     1676                 * we make the decision here.. */
    15001677                if (smbd_is_smb2_header(inbuf, nread)) {
    1501                         smbd_smb2_first_negprot(smbd_server_conn, inbuf, nread);
     1678                        smbd_smb2_first_negprot(sconn, inbuf, nread);
    15021679                        return;
    1503                 }
    1504                 smbd_server_conn->allow_smb2 = false;
     1680                } else if (nread >= smb_size && valid_smb_header(inbuf)
     1681                                && CVAL(inbuf, smb_com) != 0x72) {
     1682                        /* This is a non-negprot SMB1 packet.
     1683                           Disable SMB2 from now on. */
     1684                        sconn->using_smb2 = false;
     1685                }
    15051686        }
    15061687
    15071688        show_msg((char *)inbuf);
    15081689
    1509         construct_reply((char *)inbuf,nread,unread_bytes,seqnum,encrypted,deferred_pcd);
    1510         trans_num++;
     1690        construct_reply(sconn, (char *)inbuf, nread, unread_bytes, seqnum,
     1691                        encrypted, deferred_pcd);
     1692        sconn->trans_num++;
    15111693
    15121694done:
    1513         conn->smb1.num_requests++;
     1695        sconn->num_requests++;
    15141696
    15151697        /* The timeout_processing function isn't run nearly
     
    15201702           tradeoff of performance vs log file size overrun. */
    15211703
    1522         if ((conn->smb1.num_requests % 50) == 0 &&
     1704        if ((sconn->num_requests % 50) == 0 &&
    15231705            need_to_check_log_size()) {
    15241706                change_to_root_user();
     
    15591741{
    15601742        srv_set_message(outbuf,0,0,false);
    1561        
     1743
    15621744        SCVAL(outbuf, smb_com, req->cmd);
    15631745        SIVAL(outbuf,smb_rcls,0);
     
    18912073                           talloc_get_size(req->chain_outbuf) - 4);
    18922074
    1893                 if (!srv_send_smb(smbd_server_fd(), (char *)req->chain_outbuf,
     2075                if (!srv_send_smb(req->sconn, (char *)req->chain_outbuf,
    18942076                                  true, req->seqnum+1,
    18952077                                  IS_CONN_ENCRYPTED(req->conn)
     
    20312213        show_msg((char *)(req->chain_outbuf));
    20322214
    2033         if (!srv_send_smb(smbd_server_fd(), (char *)req->chain_outbuf,
     2215        if (!srv_send_smb(req->sconn, (char *)req->chain_outbuf,
    20342216                          true, req->seqnum+1,
    20352217                          IS_CONN_ENCRYPTED(req->conn)||req->encrypted,
    20362218                          &req->pcd)) {
    2037                 exit_server_cleanly("construct_reply: srv_send_smb failed.");
     2219                exit_server_cleanly("chain_reply: srv_send_smb failed.");
    20382220        }
    20392221        TALLOC_FREE(req->chain_outbuf);
     
    20452227****************************************************************************/
    20462228
    2047 void check_reload(time_t t)
    2048 {
    2049         time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
    2050 
    2051         if(last_smb_conf_reload_time == 0) {
     2229static void check_reload(struct smbd_server_connection *sconn, time_t t)
     2230{
     2231
     2232        if (last_smb_conf_reload_time == 0) {
    20522233                last_smb_conf_reload_time = t;
    2053                 /* Our printing subsystem might not be ready at smbd start up.
    2054                    Then no printer is available till the first printers check
    2055                    is performed.  A lower initial interval circumvents this. */
    2056                 if ( printcap_cache_time > 60 )
    2057                         last_printer_reload_time = t - printcap_cache_time + 60;
    2058                 else
    2059                         last_printer_reload_time = t;
    2060         }
    2061 
    2062         if (mypid != getpid()) { /* First time or fork happened meanwhile */
    2063                 /* randomize over 60 second the printcap reload to avoid all
    2064                  * process hitting cupsd at the same time */
    2065                 int time_range = 60;
    2066 
    2067                 last_printer_reload_time += random() % time_range;
    2068                 mypid = getpid();
    20692234        }
    20702235
    20712236        if (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK) {
    2072                 reload_services(True);
     2237                reload_services(sconn->msg_ctx, sconn->sock, True);
    20732238                last_smb_conf_reload_time = t;
    20742239        }
    2075 
    2076         /* 'printcap cache time = 0' disable the feature */
    2077        
    2078         if ( printcap_cache_time != 0 )
    2079         {
    2080                 /* see if it's time to reload or if the clock has been set back */
    2081                
    2082                 if ( (t >= last_printer_reload_time+printcap_cache_time)
    2083                         || (t-last_printer_reload_time  < 0) )
    2084                 {
    2085                         DEBUG( 3,( "Printcap cache time expired.\n"));
    2086                         pcap_cache_reload(&reload_printers);
    2087                         last_printer_reload_time = t;
    2088                 }
    2089         }
     2240}
     2241
     2242static bool fd_is_readable(int fd)
     2243{
     2244        int ret, revents;
     2245
     2246        ret = poll_one_fd(fd, POLLIN|POLLHUP, 0, &revents);
     2247
     2248        return ((ret > 0) && ((revents & (POLLIN|POLLHUP|POLLERR)) != 0));
     2249
    20902250}
    20912251
     
    20952255}
    20962256
    2097 static void smbd_server_connection_read_handler(struct smbd_server_connection *conn)
     2257static void smbd_server_connection_read_handler(
     2258        struct smbd_server_connection *conn, int fd)
    20982259{
    20992260        uint8_t *inbuf = NULL;
     
    21052266        uint32_t seqnum;
    21062267
    2107         /* TODO: make this completely nonblocking */
    2108 
    2109         status = receive_smb_talloc(mem_ctx, smbd_server_fd(),
    2110                                     (char **)(void *)&inbuf,
    2111                                     0, /* timeout */
    2112                                     &unread_bytes,
    2113                                     &encrypted,
    2114                                     &inbuf_len, &seqnum);
     2268        bool from_client = (conn->sock == fd);
     2269
     2270        if (from_client) {
     2271                smbd_lock_socket(conn);
     2272
     2273                if (lp_async_smb_echo_handler() && !fd_is_readable(fd)) {
     2274                        DEBUG(10,("the echo listener was faster\n"));
     2275                        smbd_unlock_socket(conn);
     2276                        return;
     2277                }
     2278
     2279                /* TODO: make this completely nonblocking */
     2280                status = receive_smb_talloc(mem_ctx, conn, fd,
     2281                                            (char **)(void *)&inbuf,
     2282                                            0, /* timeout */
     2283                                            &unread_bytes,
     2284                                            &encrypted,
     2285                                            &inbuf_len, &seqnum,
     2286                                            false /* trusted channel */);
     2287                smbd_unlock_socket(conn);
     2288        } else {
     2289                /* TODO: make this completely nonblocking */
     2290                status = receive_smb_talloc(mem_ctx, conn, fd,
     2291                                            (char **)(void *)&inbuf,
     2292                                            0, /* timeout */
     2293                                            &unread_bytes,
     2294                                            &encrypted,
     2295                                            &inbuf_len, &seqnum,
     2296                                            true /* trusted channel */);
     2297        }
     2298
    21152299        if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
    21162300                goto process;
     
    21382322        if (flags & EVENT_FD_WRITE) {
    21392323                smbd_server_connection_write_handler(conn);
    2140         } else if (flags & EVENT_FD_READ) {
    2141                 smbd_server_connection_read_handler(conn);
    2142         }
    2143 }
    2144 
     2324                return;
     2325        }
     2326        if (flags & EVENT_FD_READ) {
     2327                smbd_server_connection_read_handler(conn, conn->sock);
     2328                return;
     2329        }
     2330}
     2331
     2332static void smbd_server_echo_handler(struct event_context *ev,
     2333                                     struct fd_event *fde,
     2334                                     uint16_t flags,
     2335                                     void *private_data)
     2336{
     2337        struct smbd_server_connection *conn = talloc_get_type(private_data,
     2338                                              struct smbd_server_connection);
     2339
     2340        if (flags & EVENT_FD_WRITE) {
     2341                smbd_server_connection_write_handler(conn);
     2342                return;
     2343        }
     2344        if (flags & EVENT_FD_READ) {
     2345                smbd_server_connection_read_handler(
     2346                        conn, conn->smb1.echo_handler.trusted_fd);
     2347                return;
     2348        }
     2349}
    21452350
    21462351/****************************************************************************
     
    21492354static void release_ip(const char *ip, void *priv)
    21502355{
    2151         char addr[INET6_ADDRSTRLEN];
    2152         char *p = addr;
    2153 
    2154         client_socket_addr(get_client_fd(),addr,sizeof(addr));
     2356        const char *addr = (const char *)priv;
     2357        const char *p = addr;
    21552358
    21562359        if (strncmp("::ffff:", addr, 7) == 0) {
    21572360                p = addr + 7;
    21582361        }
     2362
     2363        DEBUG(10, ("Got release IP message for %s, "
     2364                   "our address is %s\n", ip, p));
    21592365
    21602366        if ((strcmp(p, ip) == 0) || ((p != addr) && strcmp(addr, ip) == 0)) {
     
    21752381                           uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
    21762382{
    2177         release_ip((char *)data->data, NULL);
     2383        struct smbd_server_connection *sconn = talloc_get_type_abort(
     2384                private_data, struct smbd_server_connection);
     2385
     2386        release_ip((char *)data->data, sconn->client_id.addr);
    21782387}
    21792388
    21802389#ifdef CLUSTER_SUPPORT
    2181 static int client_get_tcp_info(struct sockaddr_storage *server,
     2390static int client_get_tcp_info(int sock, struct sockaddr_storage *server,
    21822391                               struct sockaddr_storage *client)
    21832392{
    21842393        socklen_t length;
    2185         if (server_fd == -1) {
     2394        length = sizeof(*server);
     2395        if (getsockname(sock, (struct sockaddr *)server, &length) != 0) {
    21862396                return -1;
    21872397        }
    2188         length = sizeof(*server);
    2189         if (getsockname(server_fd, (struct sockaddr *)server, &length) != 0) {
    2190                 return -1;
    2191         }
    21922398        length = sizeof(*client);
    2193         if (getpeername(server_fd, (struct sockaddr *)client, &length) != 0) {
     2399        if (getpeername(sock, (struct sockaddr *)client, &length) != 0) {
    21942400                return -1;
    21952401        }
     
    22032409static bool keepalive_fn(const struct timeval *now, void *private_data)
    22042410{
    2205         if (!send_keepalive(smbd_server_fd())) {
    2206                 DEBUG( 2, ( "Keepalive failed - exiting.\n" ) );
     2411        struct smbd_server_connection *sconn = smbd_server_conn;
     2412        bool ret;
     2413
     2414        if (sconn->using_smb2) {
     2415                /* Don't do keepalives on an SMB2 connection. */
     2416                return false;
     2417        }
     2418
     2419        smbd_lock_socket(smbd_server_conn);
     2420        ret = send_keepalive(sconn->sock);
     2421        smbd_unlock_socket(smbd_server_conn);
     2422
     2423        if (!ret) {
     2424                char addr[INET6_ADDRSTRLEN];
     2425                /*
     2426                 * Try and give an error message saying what
     2427                 * client failed.
     2428                 */
     2429                DEBUG(0, ("send_keepalive failed for client %s. "
     2430                          "Error %s - exiting\n",
     2431                          get_peer_addr(sconn->sock, addr, sizeof(addr)),
     2432                          strerror(errno)));
    22072433                return False;
    22082434        }
     
    22152441static bool deadtime_fn(const struct timeval *now, void *private_data)
    22162442{
    2217         struct smbd_server_connection *sconn = smbd_server_conn;
     2443        struct smbd_server_connection *sconn =
     2444                (struct smbd_server_connection *)private_data;
     2445
    22182446        if ((conn_num_open(sconn) == 0)
    22192447            || (conn_idle_all(sconn, now->tv_sec))) {
    22202448                DEBUG( 2, ( "Closing idle connection\n" ) );
    2221                 messaging_send(smbd_messaging_context(), procid_self(),
     2449                messaging_send(sconn->msg_ctx,
     2450                               messaging_server_id(sconn->msg_ctx),
    22222451                               MSG_SHUTDOWN, &data_blob_null);
    22232452                return False;
     
    22332462static bool housekeeping_fn(const struct timeval *now, void *private_data)
    22342463{
     2464        struct smbd_server_connection *sconn = talloc_get_type_abort(
     2465                private_data, struct smbd_server_connection);
     2466
     2467        DEBUG(5, ("housekeeping\n"));
     2468
    22352469        change_to_root_user();
    22362470
    22372471        /* update printer queue caches if necessary */
    2238         update_monitored_printq_cache();
     2472        update_monitored_printq_cache(sconn->msg_ctx);
    22392473
    22402474        /* check if we need to reload services */
    2241         check_reload(time(NULL));
     2475        check_reload(sconn, time_mono(NULL));
    22422476
    22432477        /* Change machine password if neccessary. */
     
    22522486}
    22532487
     2488static int create_unlink_tmp(const char *dir)
     2489{
     2490        char *fname;
     2491        int fd;
     2492
     2493        fname = talloc_asprintf(talloc_tos(), "%s/listenerlock_XXXXXX", dir);
     2494        if (fname == NULL) {
     2495                errno = ENOMEM;
     2496                return -1;
     2497        }
     2498        fd = mkstemp(fname);
     2499        if (fd == -1) {
     2500                TALLOC_FREE(fname);
     2501                return -1;
     2502        }
     2503        if (unlink(fname) == -1) {
     2504                int sys_errno = errno;
     2505                close(fd);
     2506                TALLOC_FREE(fname);
     2507                errno = sys_errno;
     2508                return -1;
     2509        }
     2510        TALLOC_FREE(fname);
     2511        return fd;
     2512}
     2513
     2514struct smbd_echo_state {
     2515        struct tevent_context *ev;
     2516        struct iovec *pending;
     2517        struct smbd_server_connection *sconn;
     2518        int parent_pipe;
     2519
     2520        struct tevent_fd *parent_fde;
     2521
     2522        struct tevent_fd *read_fde;
     2523        struct tevent_req *write_req;
     2524};
     2525
     2526static void smbd_echo_writer_done(struct tevent_req *req);
     2527
     2528static void smbd_echo_activate_writer(struct smbd_echo_state *state)
     2529{
     2530        int num_pending;
     2531
     2532        if (state->write_req != NULL) {
     2533                return;
     2534        }
     2535
     2536        num_pending = talloc_array_length(state->pending);
     2537        if (num_pending == 0) {
     2538                return;
     2539        }
     2540
     2541        state->write_req = writev_send(state, state->ev, NULL,
     2542                                       state->parent_pipe, false,
     2543                                       state->pending, num_pending);
     2544        if (state->write_req == NULL) {
     2545                DEBUG(1, ("writev_send failed\n"));
     2546                exit(1);
     2547        }
     2548
     2549        talloc_steal(state->write_req, state->pending);
     2550        state->pending = NULL;
     2551
     2552        tevent_req_set_callback(state->write_req, smbd_echo_writer_done,
     2553                                state);
     2554}
     2555
     2556static void smbd_echo_writer_done(struct tevent_req *req)
     2557{
     2558        struct smbd_echo_state *state = tevent_req_callback_data(
     2559                req, struct smbd_echo_state);
     2560        ssize_t written;
     2561        int err;
     2562
     2563        written = writev_recv(req, &err);
     2564        TALLOC_FREE(req);
     2565        state->write_req = NULL;
     2566        if (written == -1) {
     2567                DEBUG(1, ("writev to parent failed: %s\n", strerror(err)));
     2568                exit(1);
     2569        }
     2570        DEBUG(10,("echo_handler[%d]: forwarded pdu to main\n", (int)sys_getpid()));
     2571        smbd_echo_activate_writer(state);
     2572}
     2573
     2574static bool smbd_echo_reply(uint8_t *inbuf, size_t inbuf_len,
     2575                            uint32_t seqnum)
     2576{
     2577        struct smb_request req;
     2578        uint16_t num_replies;
     2579        size_t out_len;
     2580        char *outbuf;
     2581        bool ok;
     2582
     2583        if ((inbuf_len == 4) && (CVAL(inbuf, 0) == SMBkeepalive)) {
     2584                DEBUG(10, ("Got netbios keepalive\n"));
     2585                /*
     2586                 * Just swallow it
     2587                 */
     2588                return true;
     2589        }
     2590
     2591        if (inbuf_len < smb_size) {
     2592                DEBUG(10, ("Got short packet: %d bytes\n", (int)inbuf_len));
     2593                return false;
     2594        }
     2595        if (!valid_smb_header(inbuf)) {
     2596                DEBUG(10, ("Got invalid SMB header\n"));
     2597                return false;
     2598        }
     2599
     2600        if (!init_smb_request(&req, smbd_server_conn, inbuf, 0, false,
     2601                              seqnum)) {
     2602                return false;
     2603        }
     2604        req.inbuf = inbuf;
     2605
     2606        DEBUG(10, ("smbecho handler got cmd %d (%s)\n", (int)req.cmd,
     2607                   smb_messages[req.cmd].name
     2608                   ? smb_messages[req.cmd].name : "unknown"));
     2609
     2610        if (req.cmd != SMBecho) {
     2611                return false;
     2612        }
     2613        if (req.wct < 1) {
     2614                return false;
     2615        }
     2616
     2617        num_replies = SVAL(req.vwv+0, 0);
     2618        if (num_replies != 1) {
     2619                /* Not a Windows "Hey, you're still there?" request */
     2620                return false;
     2621        }
     2622
     2623        if (!create_outbuf(talloc_tos(), &req, (char *)req.inbuf, &outbuf,
     2624                           1, req.buflen)) {
     2625                DEBUG(10, ("create_outbuf failed\n"));
     2626                return false;
     2627        }
     2628        req.outbuf = (uint8_t *)outbuf;
     2629
     2630        SSVAL(req.outbuf, smb_vwv0, num_replies);
     2631
     2632        if (req.buflen > 0) {
     2633                memcpy(smb_buf(req.outbuf), req.buf, req.buflen);
     2634        }
     2635
     2636        out_len = smb_len(req.outbuf) + 4;
     2637
     2638        ok = srv_send_smb(req.sconn,
     2639                          (char *)outbuf,
     2640                          true, seqnum+1,
     2641                          false, &req.pcd);
     2642        TALLOC_FREE(outbuf);
     2643        if (!ok) {
     2644                exit(1);
     2645        }
     2646
     2647        return true;
     2648}
     2649
     2650static void smbd_echo_exit(struct tevent_context *ev,
     2651                           struct tevent_fd *fde, uint16_t flags,
     2652                           void *private_data)
     2653{
     2654        DEBUG(2, ("smbd_echo_exit: lost connection to parent\n"));
     2655        exit(0);
     2656}
     2657
     2658static void smbd_echo_reader(struct tevent_context *ev,
     2659                             struct tevent_fd *fde, uint16_t flags,
     2660                             void *private_data)
     2661{
     2662        struct smbd_echo_state *state = talloc_get_type_abort(
     2663                private_data, struct smbd_echo_state);
     2664        struct smbd_server_connection *sconn = state->sconn;
     2665        size_t unread, num_pending;
     2666        NTSTATUS status;
     2667        struct iovec *tmp;
     2668        size_t iov_len;
     2669        uint32_t seqnum = 0;
     2670        bool reply;
     2671        bool ok;
     2672        bool encrypted = false;
     2673
     2674        smb_msleep(1000);
     2675
     2676        ok = smbd_lock_socket_internal(sconn);
     2677        if (!ok) {
     2678                DEBUG(0, ("%s: failed to lock socket\n",
     2679                        __location__));
     2680                exit(1);
     2681        }
     2682
     2683        if (!fd_is_readable(sconn->sock)) {
     2684                DEBUG(10,("echo_handler[%d] the parent smbd was faster\n",
     2685                          (int)sys_getpid()));
     2686                ok = smbd_unlock_socket_internal(sconn);
     2687                if (!ok) {
     2688                        DEBUG(1, ("%s: failed to unlock socket in\n",
     2689                                __location__));
     2690                        exit(1);
     2691                }
     2692                return;
     2693        }
     2694
     2695        num_pending = talloc_array_length(state->pending);
     2696        tmp = talloc_realloc(state, state->pending, struct iovec,
     2697                             num_pending+1);
     2698        if (tmp == NULL) {
     2699                DEBUG(1, ("talloc_realloc failed\n"));
     2700                exit(1);
     2701        }
     2702        state->pending = tmp;
     2703
     2704        DEBUG(10,("echo_handler[%d]: reading pdu\n", (int)sys_getpid()));
     2705
     2706        status = receive_smb_talloc(state->pending, sconn, sconn->sock,
     2707                                    (char **)(void *)&state->pending[num_pending].iov_base,
     2708                                    0 /* timeout */,
     2709                                    &unread,
     2710                                    &encrypted,
     2711                                    &iov_len,
     2712                                    &seqnum,
     2713                                    false /* trusted_channel*/);
     2714        if (!NT_STATUS_IS_OK(status)) {
     2715                DEBUG(1, ("echo_handler[%d]: receive_smb_raw_talloc failed: %s\n",
     2716                          (int)sys_getpid(), nt_errstr(status)));
     2717                exit(1);
     2718        }
     2719        state->pending[num_pending].iov_len = iov_len;
     2720
     2721        ok = smbd_unlock_socket_internal(sconn);
     2722        if (!ok) {
     2723                DEBUG(1, ("%s: failed to unlock socket in\n",
     2724                        __location__));
     2725                exit(1);
     2726        }
     2727
     2728        reply = smbd_echo_reply((uint8_t *)state->pending[num_pending].iov_base,
     2729                                state->pending[num_pending].iov_len,
     2730                                seqnum);
     2731        if (reply) {
     2732                DEBUG(10,("echo_handler[%d]: replied to client\n", (int)sys_getpid()));
     2733                /* no check, shrinking by some bytes does not fail */
     2734                state->pending = talloc_realloc(state, state->pending,
     2735                                                struct iovec,
     2736                                                num_pending);
     2737                return;
     2738        }
     2739
     2740        if (state->pending[num_pending].iov_len >= smb_size) {
     2741                /*
     2742                 * place the seqnum in the packet so that the main process
     2743                 * can reply with signing
     2744                 */
     2745                SIVAL((uint8_t *)state->pending[num_pending].iov_base,
     2746                      smb_ss_field, seqnum);
     2747                SIVAL((uint8_t *)state->pending[num_pending].iov_base,
     2748                      smb_ss_field+4, NT_STATUS_V(NT_STATUS_OK));
     2749        }
     2750
     2751        DEBUG(10,("echo_handler[%d]: forward to main\n", (int)sys_getpid()));
     2752        smbd_echo_activate_writer(state);
     2753}
     2754
     2755static void smbd_echo_loop(struct smbd_server_connection *sconn,
     2756                           int parent_pipe)
     2757{
     2758        struct smbd_echo_state *state;
     2759
     2760        state = talloc_zero(sconn, struct smbd_echo_state);
     2761        if (state == NULL) {
     2762                DEBUG(1, ("talloc failed\n"));
     2763                return;
     2764        }
     2765        state->sconn = sconn;
     2766        state->parent_pipe = parent_pipe;
     2767        state->ev = s3_tevent_context_init(state);
     2768        if (state->ev == NULL) {
     2769                DEBUG(1, ("tevent_context_init failed\n"));
     2770                TALLOC_FREE(state);
     2771                return;
     2772        }
     2773        state->parent_fde = tevent_add_fd(state->ev, state, parent_pipe,
     2774                                        TEVENT_FD_READ, smbd_echo_exit,
     2775                                        state);
     2776        if (state->parent_fde == NULL) {
     2777                DEBUG(1, ("tevent_add_fd failed\n"));
     2778                TALLOC_FREE(state);
     2779                return;
     2780        }
     2781        state->read_fde = tevent_add_fd(state->ev, state, sconn->sock,
     2782                                        TEVENT_FD_READ, smbd_echo_reader,
     2783                                        state);
     2784        if (state->read_fde == NULL) {
     2785                DEBUG(1, ("tevent_add_fd failed\n"));
     2786                TALLOC_FREE(state);
     2787                return;
     2788        }
     2789
     2790        while (true) {
     2791                if (tevent_loop_once(state->ev) == -1) {
     2792                        DEBUG(1, ("tevent_loop_once failed: %s\n",
     2793                                  strerror(errno)));
     2794                        break;
     2795                }
     2796        }
     2797        TALLOC_FREE(state);
     2798}
     2799
     2800/*
     2801 * Handle SMBecho requests in a forked child process
     2802 */
     2803static bool fork_echo_handler(struct smbd_server_connection *sconn)
     2804{
     2805        int listener_pipe[2];
     2806        int res;
     2807        pid_t child;
     2808
     2809        res = pipe(listener_pipe);
     2810        if (res == -1) {
     2811                DEBUG(1, ("pipe() failed: %s\n", strerror(errno)));
     2812                return false;
     2813        }
     2814        sconn->smb1.echo_handler.socket_lock_fd = create_unlink_tmp(lp_lockdir());
     2815        if (sconn->smb1.echo_handler.socket_lock_fd == -1) {
     2816                DEBUG(1, ("Could not create lock fd: %s\n", strerror(errno)));
     2817                goto fail;
     2818        }
     2819
     2820        child = sys_fork();
     2821        if (child == 0) {
     2822                NTSTATUS status;
     2823
     2824                close(listener_pipe[0]);
     2825                set_blocking(listener_pipe[1], false);
     2826
     2827                status = reinit_after_fork(sconn->msg_ctx,
     2828                                           smbd_event_context(),
     2829                                           procid_self(), false);
     2830                if (!NT_STATUS_IS_OK(status)) {
     2831                        DEBUG(1, ("reinit_after_fork failed: %s\n",
     2832                                  nt_errstr(status)));
     2833                        exit(1);
     2834                }
     2835                smbd_echo_loop(sconn, listener_pipe[1]);
     2836                exit(0);
     2837        }
     2838        close(listener_pipe[1]);
     2839        listener_pipe[1] = -1;
     2840        sconn->smb1.echo_handler.trusted_fd = listener_pipe[0];
     2841
     2842        DEBUG(10,("fork_echo_handler: main[%d] echo_child[%d]\n", (int)sys_getpid(), child));
     2843
     2844        /*
     2845         * Without smb signing this is the same as the normal smbd
     2846         * listener. This needs to change once signing comes in.
     2847         */
     2848        sconn->smb1.echo_handler.trusted_fde = event_add_fd(smbd_event_context(),
     2849                                        sconn,
     2850                                        sconn->smb1.echo_handler.trusted_fd,
     2851                                        EVENT_FD_READ,
     2852                                        smbd_server_echo_handler,
     2853                                        sconn);
     2854        if (sconn->smb1.echo_handler.trusted_fde == NULL) {
     2855                DEBUG(1, ("event_add_fd failed\n"));
     2856                goto fail;
     2857        }
     2858
     2859        return true;
     2860
     2861fail:
     2862        if (listener_pipe[0] != -1) {
     2863                close(listener_pipe[0]);
     2864        }
     2865        if (listener_pipe[1] != -1) {
     2866                close(listener_pipe[1]);
     2867        }
     2868        sconn->smb1.echo_handler.trusted_fd = -1;
     2869        if (sconn->smb1.echo_handler.socket_lock_fd != -1) {
     2870                close(sconn->smb1.echo_handler.socket_lock_fd);
     2871        }
     2872        sconn->smb1.echo_handler.trusted_fd = -1;
     2873        sconn->smb1.echo_handler.socket_lock_fd = -1;
     2874        return false;
     2875}
     2876
     2877#if CLUSTER_SUPPORT
     2878
     2879static NTSTATUS smbd_register_ips(struct smbd_server_connection *sconn,
     2880                                  struct sockaddr_storage *srv,
     2881                                  struct sockaddr_storage *clnt)
     2882{
     2883        struct ctdbd_connection *cconn;
     2884        char tmp_addr[INET6_ADDRSTRLEN];
     2885        char *addr;
     2886
     2887        cconn = messaging_ctdbd_connection();
     2888        if (cconn == NULL) {
     2889                return NT_STATUS_NO_MEMORY;
     2890        }
     2891
     2892        client_socket_addr(sconn->sock, tmp_addr, sizeof(tmp_addr));
     2893        addr = talloc_strdup(cconn, tmp_addr);
     2894        if (addr == NULL) {
     2895                return NT_STATUS_NO_MEMORY;
     2896        }
     2897        return ctdbd_register_ips(cconn, srv, clnt, release_ip, addr);
     2898}
     2899
     2900#endif
     2901
    22542902/****************************************************************************
    22552903 Process commands from the client
    22562904****************************************************************************/
    22572905
    2258 void smbd_process(void)
     2906void smbd_process(struct smbd_server_connection *sconn)
    22592907{
    22602908        TALLOC_CTX *frame = talloc_stackframe();
    2261         char remaddr[INET6_ADDRSTRLEN];
     2909        struct sockaddr_storage ss;
     2910        struct sockaddr *sa = NULL;
     2911        socklen_t sa_socklen;
     2912        struct tsocket_address *local_address = NULL;
     2913        struct tsocket_address *remote_address = NULL;
     2914        const char *remaddr = NULL;
     2915        int ret;
    22622916
    22632917        if (lp_maxprotocol() == PROTOCOL_SMB2 &&
    2264             lp_security() != SEC_SHARE) {
    2265                 smbd_server_conn->allow_smb2 = true;
     2918            !lp_async_smb_echo_handler()) {
     2919                /*
     2920                 * We're not making the decision here,
     2921                 * we're just allowing the client
     2922                 * to decide between SMB1 and SMB2
     2923                 * with the first negprot
     2924                 * packet.
     2925                 */
     2926                sconn->using_smb2 = true;
    22662927        }
    22672928
    22682929        /* Ensure child is set to blocking mode */
    2269         set_blocking(smbd_server_fd(),True);
    2270 
    2271         set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");
    2272         set_socket_options(smbd_server_fd(), lp_socket_options());
     2930        set_blocking(sconn->sock,True);
     2931
     2932        set_socket_options(sconn->sock, "SO_KEEPALIVE");
     2933        set_socket_options(sconn->sock, lp_socket_options());
     2934
     2935        sa = (struct sockaddr *)(void *)&ss;
     2936        sa_socklen = sizeof(ss);
     2937        ret = getpeername(sconn->sock, sa, &sa_socklen);
     2938        if (ret != 0) {
     2939                int level = (errno == ENOTCONN)?2:0;
     2940                DEBUG(level,("getpeername() failed - %s\n", strerror(errno)));
     2941                exit_server_cleanly("getpeername() failed.\n");
     2942        }
     2943        ret = tsocket_address_bsd_from_sockaddr(sconn,
     2944                                                sa, sa_socklen,
     2945                                                &remote_address);
     2946        if (ret != 0) {
     2947                DEBUG(0,("%s: tsocket_address_bsd_from_sockaddr remote failed - %s\n",
     2948                        __location__, strerror(errno)));
     2949                exit_server_cleanly("tsocket_address_bsd_from_sockaddr remote failed.\n");
     2950        }
     2951
     2952        sa = (struct sockaddr *)(void *)&ss;
     2953        sa_socklen = sizeof(ss);
     2954        ret = getsockname(sconn->sock, sa, &sa_socklen);
     2955        if (ret != 0) {
     2956                int level = (errno == ENOTCONN)?2:0;
     2957                DEBUG(level,("getsockname() failed - %s\n", strerror(errno)));
     2958                exit_server_cleanly("getsockname() failed.\n");
     2959        }
     2960        ret = tsocket_address_bsd_from_sockaddr(sconn,
     2961                                                sa, sa_socklen,
     2962                                                &local_address);
     2963        if (ret != 0) {
     2964                DEBUG(0,("%s: tsocket_address_bsd_from_sockaddr remote failed - %s\n",
     2965                        __location__, strerror(errno)));
     2966                exit_server_cleanly("tsocket_address_bsd_from_sockaddr remote failed.\n");
     2967        }
     2968
     2969        sconn->local_address = local_address;
     2970        sconn->remote_address = remote_address;
     2971
     2972        if (tsocket_address_is_inet(remote_address, "ip")) {
     2973                remaddr = tsocket_address_inet_addr_string(
     2974                                sconn->remote_address,
     2975                                talloc_tos());
     2976                if (remaddr == NULL) {
     2977
     2978                }
     2979        } else {
     2980                remaddr = "0.0.0.0";
     2981        }
    22732982
    22742983        /* this is needed so that we get decent entries
    22752984           in smbstatus for port 445 connects */
    2276         set_remote_machine_name(get_peer_addr(smbd_server_fd(),
    2277                                               remaddr,
    2278                                               sizeof(remaddr)),
    2279                                               false);
    2280         reload_services(true);
     2985        set_remote_machine_name(remaddr, false);
     2986        reload_services(sconn->msg_ctx, sconn->sock, true);
    22812987
    22822988        /*
     
    22872993         */
    22882994
    2289         if (!check_access(smbd_server_fd(), lp_hostsallow(-1),
    2290                           lp_hostsdeny(-1))) {
    2291                 char addr[INET6_ADDRSTRLEN];
    2292 
     2995        if (!allow_access(lp_hostsdeny(-1), lp_hostsallow(-1),
     2996                          sconn->client_id.name,
     2997                          sconn->client_id.addr)) {
    22932998                /*
    22942999                 * send a negative session response "not listening on calling
     
    22963001                 */
    22973002                unsigned char buf[5] = {0x83, 0, 0, 1, 0x81};
    2298                 DEBUG( 1, ("Connection denied from %s\n",
    2299                            client_addr(get_client_fd(),addr,sizeof(addr)) ) );
    2300                 (void)srv_send_smb(smbd_server_fd(),(char *)buf, false,
     3003                DEBUG( 1, ("Connection denied from %s to %s\n",
     3004                           tsocket_address_string(remote_address, talloc_tos()),
     3005                           tsocket_address_string(local_address, talloc_tos())));
     3006                (void)srv_send_smb(sconn,(char *)buf, false,
    23013007                                   0, false, NULL);
    23023008                exit_server_cleanly("connection denied");
    23033009        }
    23043010
    2305         static_init_rpc;
     3011        DEBUG(10, ("Connection allowed from %s to %s\n",
     3012                   tsocket_address_string(remote_address, talloc_tos()),
     3013                   tsocket_address_string(local_address, talloc_tos())));
    23063014
    23073015        init_modules();
     
    23253033        }
    23263034
    2327         if (!srv_init_signing(smbd_server_conn)) {
     3035        if (!srv_init_signing(sconn)) {
    23283036                exit_server("Failed to init smb_signing");
    23293037        }
    23303038
     3039        if (lp_async_smb_echo_handler() && !fork_echo_handler(sconn)) {
     3040                exit_server("Failed to fork echo handler");
     3041        }
     3042
    23313043        /* Setup oplocks */
    2332         if (!init_oplocks(smbd_messaging_context()))
     3044        if (!init_oplocks(sconn->msg_ctx))
    23333045                exit_server("Failed to init oplocks");
    23343046
    2335         /* Setup aio signal handler. */
    2336         initialize_async_io_handler();
    2337 
    23383047        /* register our message handlers */
    2339         messaging_register(smbd_messaging_context(), NULL,
     3048        messaging_register(sconn->msg_ctx, NULL,
    23403049                           MSG_SMB_FORCE_TDIS, msg_force_tdis);
    2341         messaging_register(smbd_messaging_context(), NULL,
     3050        messaging_register(sconn->msg_ctx, sconn,
    23423051                           MSG_SMB_RELEASE_IP, msg_release_ip);
    2343         messaging_register(smbd_messaging_context(), NULL,
     3052        messaging_register(sconn->msg_ctx, NULL,
    23443053                           MSG_SMB_CLOSE_FILE, msg_close_file);
    23453054
     
    23483057         * MSGs to all child processes
    23493058         */
    2350         messaging_deregister(smbd_messaging_context(),
     3059        messaging_deregister(sconn->msg_ctx,
    23513060                             MSG_DEBUG, NULL);
    2352         messaging_register(smbd_messaging_context(), NULL,
     3061        messaging_register(sconn->msg_ctx, NULL,
    23533062                           MSG_DEBUG, debug_message);
    23543063
     
    23643073        if (!(event_add_idle(smbd_event_context(), NULL,
    23653074                             timeval_set(IDLE_CLOSED_TIMEOUT, 0),
    2366                              "deadtime", deadtime_fn, NULL))) {
     3075                             "deadtime", deadtime_fn, sconn))) {
    23673076                DEBUG(0, ("Could not add deadtime event\n"));
    23683077                exit(1);
     
    23713080        if (!(event_add_idle(smbd_event_context(), NULL,
    23723081                             timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
    2373                              "housekeeping", housekeeping_fn, NULL))) {
     3082                             "housekeeping", housekeeping_fn, sconn))) {
    23743083                DEBUG(0, ("Could not add housekeeping event\n"));
    23753084                exit(1);
     
    23883097                struct sockaddr_storage srv, clnt;
    23893098
    2390                 if (client_get_tcp_info(&srv, &clnt) == 0) {
    2391 
     3099                if (client_get_tcp_info(sconn->sock, &srv, &clnt) == 0) {
    23923100                        NTSTATUS status;
    2393 
    2394                         status = ctdbd_register_ips(
    2395                                 messaging_ctdbd_connection(),
    2396                                 &srv, &clnt, release_ip, NULL);
    2397 
     3101                        status = smbd_register_ips(sconn, &srv, &clnt);
    23983102                        if (!NT_STATUS_IS_OK(status)) {
    23993103                                DEBUG(0, ("ctdbd_register_ips failed: %s\n",
     
    24103114#endif
    24113115
    2412         smbd_server_conn->nbt.got_session = false;
    2413 
    2414         smbd_server_conn->smb1.negprot.max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
    2415 
    2416         smbd_server_conn->smb1.sessions.done_sesssetup = false;
    2417         smbd_server_conn->smb1.sessions.max_send = BUFFER_SIZE;
    2418         smbd_server_conn->smb1.sessions.last_session_tag = UID_FIELD_INVALID;
     3116        sconn->nbt.got_session = false;
     3117
     3118        sconn->smb1.negprot.max_recv = MIN(lp_maxxmit(),BUFFER_SIZE);
     3119
     3120        sconn->smb1.sessions.done_sesssetup = false;
     3121        sconn->smb1.sessions.max_send = BUFFER_SIZE;
     3122        sconn->smb1.sessions.last_session_tag = UID_FIELD_INVALID;
    24193123        /* users from session setup */
    2420         smbd_server_conn->smb1.sessions.session_userlist = NULL;
     3124        sconn->smb1.sessions.session_userlist = NULL;
    24213125        /* workgroup from session setup. */
    2422         smbd_server_conn->smb1.sessions.session_workgroup = NULL;
     3126        sconn->smb1.sessions.session_workgroup = NULL;
    24233127        /* this holds info on user ids that are already validated for this VC */
    2424         smbd_server_conn->smb1.sessions.validated_users = NULL;
    2425         smbd_server_conn->smb1.sessions.next_vuid = VUID_OFFSET;
    2426         smbd_server_conn->smb1.sessions.num_validated_vuids = 0;
    2427 #ifdef HAVE_NETGROUP
    2428         smbd_server_conn->smb1.sessions.my_yp_domain = NULL;
    2429 #endif
    2430 
    2431         conn_init(smbd_server_conn);
    2432         if (!init_dptrs(smbd_server_conn)) {
     3128        sconn->smb1.sessions.validated_users = NULL;
     3129        sconn->smb1.sessions.next_vuid = VUID_OFFSET;
     3130        sconn->smb1.sessions.num_validated_vuids = 0;
     3131
     3132        conn_init(sconn);
     3133        if (!init_dptrs(sconn)) {
    24333134                exit_server("init_dptrs() failed");
    24343135        }
    24353136
    2436         smbd_server_conn->smb1.fde = event_add_fd(smbd_event_context(),
    2437                                                   smbd_server_conn,
    2438                                                   smbd_server_fd(),
     3137        sconn->smb1.fde = event_add_fd(smbd_event_context(),
     3138                                                  sconn,
     3139                                                  sconn->sock,
    24393140                                                  EVENT_FD_READ,
    24403141                                                  smbd_server_connection_handler,
    2441                                                   smbd_server_conn);
    2442         if (!smbd_server_conn->smb1.fde) {
     3142                                                  sconn);
     3143        if (!sconn->smb1.fde) {
    24433144                exit_server("failed to create smbd_server_connection fde");
    24443145        }
     
    24533154                errno = 0;
    24543155
    2455                 status = smbd_server_connection_loop_once(smbd_server_conn);
     3156                status = smbd_server_connection_loop_once(sconn);
    24563157                if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY) &&
    24573158                    !NT_STATUS_IS_OK(status)) {
Note: See TracChangeset for help on using the changeset viewer.