Changeset 745 for trunk/server/source4/smbd/service_stream.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source4/smbd/service_stream.c
r414 r745 27 27 #include "cluster/cluster.h" 28 28 #include "param/param.h" 29 #include "../lib/tsocket/tsocket.h" 29 30 30 31 /* the range of ports to try for dcerpc over tcp endpoints */ … … 98 99 } 99 100 100 static void stream_io_handler_fde(struct tevent_context *ev, struct tevent_fd *fde, 101 void stream_io_handler_fde(struct tevent_context *ev, struct tevent_fd *fde, 101 102 uint16_t flags, void *private_data) 102 103 { … … 121 122 struct loadparm_context *lp_ctx, 122 123 const struct model_ops *model_ops, 123 struct socket_context *sock,124 124 const struct stream_server_ops *stream_ops, 125 125 struct messaging_context *msg_ctx, … … 132 132 NT_STATUS_HAVE_NO_MEMORY(srv_conn); 133 133 134 talloc_steal(srv_conn, sock);135 136 134 srv_conn->private_data = private_data; 137 135 srv_conn->model_ops = model_ops; 138 srv_conn->socket = sock;136 srv_conn->socket = NULL; 139 137 srv_conn->server_id = cluster_id(0, 0); 140 138 srv_conn->ops = stream_ops; … … 142 140 srv_conn->event.ctx = ev; 143 141 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; 151 143 152 144 *_srv_conn = srv_conn; … … 165 157 struct stream_socket *stream_socket = talloc_get_type(private_data, struct stream_socket); 166 158 struct stream_connection *srv_conn; 167 struct socket_address *c, *s;168 159 169 160 srv_conn = talloc_zero(ev, struct stream_connection); … … 183 174 srv_conn->lp_ctx = lp_ctx; 184 175 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)))) { 186 177 stream_terminate_connection(srv_conn, "denied by access rules"); 187 178 return; … … 197 188 /* setup to receive internal messages on this connection */ 198 189 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); 203 192 if (!srv_conn->msg_ctx) { 204 193 stream_terminate_connection(srv_conn, "messaging_init() failed"); … … 206 195 } 207 196 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; 211 211 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]", 213 216 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)); 216 220 if (title) { 217 221 stream_connection_set_title(srv_conn, title); 218 222 } 219 } 220 talloc_free(c); 221 talloc_free(s); 223 talloc_free(tmp_ctx); 224 } 222 225 223 226 /* we're now ready to start receiving events on this stream */ … … 240 243 connection. When done, it calls stream_new_connection() 241 244 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, 243 246 stream_socket->sock, 244 247 stream_new_connection, stream_socket); … … 253 256 to the socket implementation - JRV20070903 254 257 */ 255 NTSTATUS stream_setup_socket(struct tevent_context *event_context, 258 NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx, 259 struct tevent_context *event_context, 256 260 struct loadparm_context *lp_ctx, 257 261 const struct model_ops *model_ops, … … 269 273 int i; 270 274 271 stream_socket = talloc_zero( event_context, struct stream_socket);275 stream_socket = talloc_zero(mem_ctx, struct stream_socket); 272 276 NT_STATUS_HAVE_NO_MEMORY(stream_socket); 273 277
Note:
See TracChangeset
for help on using the changeset viewer.