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/source4/smbd/service_stream.c

    r414 r745  
    2727#include "cluster/cluster.h"
    2828#include "param/param.h"
     29#include "../lib/tsocket/tsocket.h"
    2930
    3031/* the range of ports to try for dcerpc over tcp endpoints */
     
    9899}
    99100
    100 static void stream_io_handler_fde(struct tevent_context *ev, struct tevent_fd *fde,
     101void stream_io_handler_fde(struct tevent_context *ev, struct tevent_fd *fde,
    101102                                  uint16_t flags, void *private_data)
    102103{
     
    121122                                     struct loadparm_context *lp_ctx,
    122123                                     const struct model_ops *model_ops,
    123                                      struct socket_context *sock,
    124124                                     const struct stream_server_ops *stream_ops,
    125125                                     struct messaging_context *msg_ctx,
     
    132132        NT_STATUS_HAVE_NO_MEMORY(srv_conn);
    133133
    134         talloc_steal(srv_conn, sock);
    135 
    136134        srv_conn->private_data  = private_data;
    137135        srv_conn->model_ops     = model_ops;
    138         srv_conn->socket        = sock;
     136        srv_conn->socket        = NULL;
    139137        srv_conn->server_id     = cluster_id(0, 0);
    140138        srv_conn->ops           = stream_ops;
     
    142140        srv_conn->event.ctx     = ev;
    143141        srv_conn->lp_ctx        = lp_ctx;
    144         srv_conn->event.fde     = tevent_add_fd(ev, srv_conn, socket_get_fd(sock),
    145                                                 TEVENT_FD_READ,
    146                                                 stream_io_handler_fde, srv_conn);
    147         if (!srv_conn->event.fde) {
    148                 talloc_free(srv_conn);
    149                 return NT_STATUS_NO_MEMORY;
    150         }
     142        srv_conn->event.fde     = NULL;
    151143
    152144        *_srv_conn = srv_conn;
     
    165157        struct stream_socket *stream_socket = talloc_get_type(private_data, struct stream_socket);
    166158        struct stream_connection *srv_conn;
    167         struct socket_address *c, *s;
    168159
    169160        srv_conn = talloc_zero(ev, struct stream_connection);
     
    183174        srv_conn->lp_ctx        = lp_ctx;
    184175
    185         if (!socket_check_access(sock, "smbd", lp_hostsallow(NULL, lp_default_service(lp_ctx)), lp_hostsdeny(NULL, lp_default_service(lp_ctx)))) {
     176        if (!socket_check_access(sock, "smbd", lpcfg_hostsallow(NULL, lpcfg_default_service(lp_ctx)), lpcfg_hostsdeny(NULL, lpcfg_default_service(lp_ctx)))) {
    186177                stream_terminate_connection(srv_conn, "denied by access rules");
    187178                return;
     
    197188        /* setup to receive internal messages on this connection */
    198189        srv_conn->msg_ctx = messaging_init(srv_conn,
    199                                            lp_messaging_path(srv_conn, lp_ctx),
    200                                            srv_conn->server_id,
    201                                            lp_iconv_convenience(lp_ctx),
    202                                            ev);
     190                                           lpcfg_messaging_path(srv_conn, lp_ctx),
     191                                           srv_conn->server_id, ev);
    203192        if (!srv_conn->msg_ctx) {
    204193                stream_terminate_connection(srv_conn, "messaging_init() failed");
     
    206195        }
    207196
    208         c = socket_get_peer_addr(sock, ev);
    209         s = socket_get_my_addr(sock, ev);
    210         if (s && c) {
     197        srv_conn->remote_address = socket_get_remote_addr(srv_conn->socket, srv_conn);
     198        if (!srv_conn->remote_address) {
     199                stream_terminate_connection(srv_conn, "socket_get_remote_addr() failed");
     200                return;
     201        }
     202
     203        srv_conn->local_address = socket_get_local_addr(srv_conn->socket, srv_conn);
     204        if (!srv_conn->local_address) {
     205                stream_terminate_connection(srv_conn, "socket_get_local_addr() failed");
     206                return;
     207        }
     208
     209        {
     210                TALLOC_CTX *tmp_ctx;
    211211                const char *title;
    212                 title = talloc_asprintf(s, "conn[%s] c[%s:%u] s[%s:%u] server_id[%s]",
     212
     213                tmp_ctx = talloc_new(srv_conn);
     214
     215                title = talloc_asprintf(tmp_ctx, "conn[%s] c[%s] s[%s] server_id[%s]",
    213216                                        stream_socket->ops->name,
    214                                         c->addr, c->port, s->addr, s->port,
    215                                         cluster_id_string(s, server_id));
     217                                        tsocket_address_string(srv_conn->remote_address, tmp_ctx),
     218                                        tsocket_address_string(srv_conn->local_address, tmp_ctx),
     219                                        cluster_id_string(tmp_ctx, server_id));
    216220                if (title) {
    217221                        stream_connection_set_title(srv_conn, title);
    218222                }
    219         }
    220         talloc_free(c);
    221         talloc_free(s);
     223                talloc_free(tmp_ctx);
     224        }
    222225
    223226        /* we're now ready to start receiving events on this stream */
     
    240243           connection.  When done, it calls stream_new_connection()
    241244           with the newly created socket */
    242         stream_socket->model_ops->accept_connection(ev, stream_socket->lp_ctx, 
     245        stream_socket->model_ops->accept_connection(ev, stream_socket->lp_ctx,
    243246                                                    stream_socket->sock,
    244247                                                    stream_new_connection, stream_socket);
     
    253256         to the socket implementation - JRV20070903
    254257 */
    255 NTSTATUS stream_setup_socket(struct tevent_context *event_context,
     258NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx,
     259                             struct tevent_context *event_context,
    256260                             struct loadparm_context *lp_ctx,
    257261                             const struct model_ops *model_ops,
     
    269273        int i;
    270274
    271         stream_socket = talloc_zero(event_context, struct stream_socket);
     275        stream_socket = talloc_zero(mem_ctx, struct stream_socket);
    272276        NT_STATUS_HAVE_NO_MEMORY(stream_socket);
    273277
Note: See TracChangeset for help on using the changeset viewer.