Changeset 988 for vendor/current/source3/smbd/globals.h
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/smbd/globals.h
r860 r988 20 20 21 21 #include "system/select.h" 22 23 #if defined(WITH_AIO) 24 struct aio_extra; 25 extern struct aio_extra *aio_list_head; 26 extern struct tevent_signal *aio_signal_event; 27 extern int aio_pending_size; 28 extern int outstanding_aio_calls; 29 #endif 22 #include "librpc/gen_ndr/smbXsrv.h" 23 #include "smbprofile.h" 30 24 31 25 #ifdef USE_DMAPI … … 33 27 extern struct smbd_dmapi_context *dmapi_ctx; 34 28 #endif 35 36 extern bool dfree_broken;37 29 38 30 /* how many write cache buffers have been allocated */ … … 59 51 60 52 struct msg_state; 61 extern struct msg_state *smbd_msg_state;62 53 63 54 extern bool logged_ioctl_message; … … 67 58 extern time_t last_smb_conf_reload_time; 68 59 extern time_t last_printer_reload_time; 60 extern pid_t background_lpq_updater_pid; 61 69 62 /**************************************************************************** 70 63 structure to hold a linked list of queued messages. 71 64 for processing. 72 65 ****************************************************************************/ 73 struct pending_message_list;74 extern struct pending_message_list *deferred_open_queue;75 66 extern uint32_t common_flags2; 76 67 77 struct smb_srv_trans_enc_ctx; 78 extern struct smb_srv_trans_enc_ctx *partial_srv_trans_enc_ctx; 79 extern struct smb_srv_trans_enc_ctx *srv_trans_enc_ctx; 68 extern struct smb_trans_enc_state *partial_srv_trans_enc_ctx; 69 extern struct smb_trans_enc_state *srv_trans_enc_ctx; 80 70 81 71 struct sec_ctx { … … 99 89 struct conn_ctx { 100 90 connection_struct *conn; 101 uint 16vuid;91 uint64_t vuid; 102 92 }; 103 93 /* A stack of current_user connection contexts. */ … … 110 100 extern char *LastDir; 111 101 112 /* Current number of oplocks we have outstanding. */ 113 extern int32_t exclusive_oplocks_open; 114 extern int32_t level_II_oplocks_open; 115 extern struct kernel_oplocks *koplocks; 116 117 extern int am_parent; 118 extern struct event_context *smbd_event_ctx; 119 extern struct messaging_context *smbd_msg_ctx; 102 struct smbd_parent_context; 103 extern struct smbd_parent_context *am_parent; 120 104 extern struct memcache *smbd_memcache_ctx; 121 105 extern bool exit_firsttime; 122 struct child_pid;123 extern struct child_pid *children;124 extern int num_children;125 106 126 107 struct tstream_context; 127 108 struct smbd_smb2_request; 128 struct smbd_smb2_session; 129 struct smbd_smb2_tcon; 130 131 DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbd_server_connection *sconn); 132 133 void smbd_lock_socket(struct smbd_server_connection *sconn); 134 void smbd_unlock_socket(struct smbd_server_connection *sconn); 135 136 NTSTATUS smb2_signing_sign_pdu(DATA_BLOB session_key, 137 struct iovec *vector, 138 int count); 139 NTSTATUS smb2_signing_check_pdu(DATA_BLOB session_key, 140 const struct iovec *vector, 141 int count); 109 110 DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbXsrv_connection *xconn); 111 112 void smbd_lock_socket(struct smbXsrv_connection *xconn); 113 void smbd_unlock_socket(struct smbXsrv_connection *xconn); 142 114 143 115 NTSTATUS smbd_do_locking(struct smb_request *req, … … 145 117 uint8_t type, 146 118 int32_t timeout, 147 uint16_t num_ulocks,148 struct smbd_lock_element *ulocks,149 119 uint16_t num_locks, 150 120 struct smbd_lock_element *locks, 151 121 bool *async); 122 NTSTATUS smbd_do_unlocking(struct smb_request *req, 123 files_struct *fsp, 124 uint16_t num_ulocks, 125 struct smbd_lock_element *ulocks); 152 126 153 127 NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, … … 167 141 unsigned int *pdata_size); 168 142 143 NTSTATUS smbd_do_setfsinfo(connection_struct *conn, 144 struct smb_request *req, 145 TALLOC_CTX *mem_ctx, 146 uint16_t info_level, 147 files_struct *fsp, 148 const DATA_BLOB *pdata); 149 169 150 NTSTATUS smbd_do_setfilepathinfo(connection_struct *conn, 170 151 struct smb_request *req, … … 176 157 int *ret_data_size); 177 158 178 NTSTATUS smbd_do_qfsinfo(connection_struct *conn, 159 NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn, 160 connection_struct *conn, 179 161 TALLOC_CTX *mem_ctx, 180 162 uint16_t info_level, … … 207 189 long *_prev_offset); 208 190 209 boolsmbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,191 NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx, 210 192 connection_struct *conn, 211 193 struct dptr_struct *dirptr, 212 uint16 flags2,194 uint16_t flags2, 213 195 const char *path_mask, 214 uint32 dirtype,196 uint32_t dirtype, 215 197 int info_level, 216 198 int requires_resume_key, … … 223 205 char *end_data, 224 206 int space_remaining, 225 bool *out_of_space,226 207 bool *got_exact_match, 227 208 int *_last_entry_off, … … 230 211 NTSTATUS smbd_calculate_access_mask(connection_struct *conn, 231 212 const struct smb_filename *smb_fname, 232 bool file_existed,213 bool use_privs, 233 214 uint32_t access_mask, 234 215 uint32_t *access_mask_out); 235 NTSTATUS smbd_check_open_rights(struct connection_struct *conn,236 const struct smb_filename *smb_fname,237 uint32_t access_mask,238 uint32_t *access_granted);239 216 240 217 void smbd_notify_cancel_by_smbreq(const struct smb_request *smbreq); 241 218 242 void smbd_server_connection_terminate_ex(struct smb d_server_connection *sconn,219 void smbd_server_connection_terminate_ex(struct smbXsrv_connection *xconn, 243 220 const char *reason, 244 221 const char *location); 245 #define smbd_server_connection_terminate(sconn, reason) \ 246 smbd_server_connection_terminate_ex(sconn, reason, __location__) 247 248 struct server_id sconn_server_id(const struct smbd_server_connection *sconn); 222 #define smbd_server_connection_terminate(xconn, reason) \ 223 smbd_server_connection_terminate_ex(xconn, reason, __location__) 249 224 250 225 const char *smb2_opcode_name(uint16_t opcode); 251 226 bool smbd_is_smb2_header(const uint8_t *inbuf, size_t size); 252 227 228 NTSTATUS smbd_add_connection(struct smbXsrv_client *client, int sock_fd, 229 struct smbXsrv_connection **_xconn); 230 253 231 void reply_smb2002(struct smb_request *req, uint16_t choice); 254 void smbd_smb2_first_negprot(struct smbd_server_connection *sconn, 255 const uint8_t *inbuf, size_t size); 232 void reply_smb20ff(struct smb_request *req, uint16_t choice); 233 void smbd_smb2_process_negprot(struct smbXsrv_connection *xconn, 234 uint64_t expected_seq_low, 235 const uint8_t *inpdu, size_t size); 236 237 DATA_BLOB smbd_smb2_generate_outbody(struct smbd_smb2_request *req, size_t size); 256 238 257 239 NTSTATUS smbd_smb2_request_error_ex(struct smbd_smb2_request *req, … … 268 250 smbd_smb2_request_done_ex(req, NT_STATUS_OK, body, dyn, __location__) 269 251 270 NTSTATUS smbd_smb2_send_oplock_break(struct smbd_server_connection *sconn, 271 uint64_t file_id_persistent, 272 uint64_t file_id_volatile, 252 NTSTATUS smbd_smb2_send_oplock_break(struct smbXsrv_connection *xconn, 253 struct smbXsrv_session *session, 254 struct smbXsrv_tcon *tcon, 255 struct smbXsrv_open *op, 273 256 uint8_t oplock_level); 257 NTSTATUS smbd_smb2_send_lease_break(struct smbXsrv_connection *xconn, 258 uint16_t new_epoch, 259 uint32_t lease_flags, 260 struct smb2_lease_key *lease_key, 261 uint32_t current_lease_state, 262 uint32_t new_lease_state); 274 263 275 264 NTSTATUS smbd_smb2_request_pending_queue(struct smbd_smb2_request *req, 276 struct tevent_req *subreq); 277 278 NTSTATUS smbd_smb2_request_check_session(struct smbd_smb2_request *req); 279 NTSTATUS smbd_smb2_request_check_tcon(struct smbd_smb2_request *req); 265 struct tevent_req *subreq, 266 uint32_t defer_time); 280 267 281 268 struct smb_request *smbd_smb2_fake_smb_request(struct smbd_smb2_request *req); 269 size_t smbd_smb2_unread_bytes(struct smbd_smb2_request *req); 282 270 void remove_smb2_chained_fsp(files_struct *fsp); 271 272 NTSTATUS smbd_smb2_request_verify_creditcharge(struct smbd_smb2_request *req, 273 uint32_t data_length); 283 274 284 275 NTSTATUS smbd_smb2_request_verify_sizes(struct smbd_smb2_request *req, 285 276 size_t expected_body_size); 286 277 278 enum protocol_types smbd_smb2_protocol_dialect_match(const uint8_t *indyn, 279 const int dialect_count, 280 uint16_t *dialect); 287 281 NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req); 288 282 NTSTATUS smbd_smb2_request_process_sesssetup(struct smbd_smb2_request *req); … … 297 291 NTSTATUS smbd_smb2_request_process_write(struct smbd_smb2_request *req); 298 292 NTSTATUS smb2_write_complete(struct tevent_req *req, ssize_t nwritten, int err); 293 NTSTATUS smb2_write_complete_nosync(struct tevent_req *req, ssize_t nwritten, 294 int err); 299 295 NTSTATUS smbd_smb2_request_process_lock(struct smbd_smb2_request *req); 300 296 NTSTATUS smbd_smb2_request_process_ioctl(struct smbd_smb2_request *req); 301 297 NTSTATUS smbd_smb2_request_process_keepalive(struct smbd_smb2_request *req); 302 NTSTATUS smbd_smb2_request_process_ find(struct smbd_smb2_request *req);298 NTSTATUS smbd_smb2_request_process_query_directory(struct smbd_smb2_request *req); 303 299 NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req); 304 300 NTSTATUS smbd_smb2_request_process_getinfo(struct smbd_smb2_request *req); … … 310 306 void *private_data); 311 307 308 struct deferred_open_record; 309 312 310 /* SMB1 -> SMB2 glue. */ 313 void send_break_message_smb2(files_struct *fsp, int level); 311 void send_break_message_smb2(files_struct *fsp, 312 uint32_t break_from, 313 uint32_t break_to); 314 314 struct blocking_lock_record *get_pending_smb2req_blr(struct smbd_smb2_request *smb2req); 315 315 bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck, … … 333 333 bool get_deferred_open_message_state_smb2(struct smbd_smb2_request *smb2req, 334 334 struct timeval *p_request_time, 335 void **pp_state);336 bool open_was_deferred_smb2( struct smbd_server_connection *sconn,337 335 struct deferred_open_record **open_rec); 336 bool open_was_deferred_smb2( 337 struct smbXsrv_connection *xconn, uint64_t mid); 338 338 void remove_deferred_open_message_smb2( 339 struct smb d_server_connection *sconn, uint64_t mid);340 voidschedule_deferred_open_message_smb2(341 struct smb d_server_connection *sconn, uint64_t mid);339 struct smbXsrv_connection *xconn, uint64_t mid); 340 bool schedule_deferred_open_message_smb2( 341 struct smbXsrv_connection *xconn, uint64_t mid); 342 342 bool push_deferred_open_message_smb2(struct smbd_smb2_request *smb2req, 343 struct timeval request_time, 344 struct timeval timeout, 345 struct file_id id, 346 char *private_data, 347 size_t priv_len); 343 struct timeval request_time, 344 struct timeval timeout, 345 struct file_id id, 346 struct deferred_open_record *open_rec); 347 348 struct smbXsrv_client; 349 350 struct smbXsrv_preauth { 351 uint8_t sha512_value[64]; 352 }; 353 354 struct smbXsrv_connection { 355 struct smbXsrv_connection *prev, *next; 356 357 struct smbXsrv_client *client; 358 359 360 const struct tsocket_address *local_address; 361 const struct tsocket_address *remote_address; 362 const char *remote_hostname; 363 364 struct tevent_context *ev_ctx; 365 struct messaging_context *msg_ctx; 366 367 enum protocol_types protocol; 368 369 struct { 370 NTSTATUS status; 371 int sock; 372 struct tevent_fd *fde; 373 374 struct { 375 bool got_session; 376 } nbt; 377 } transport; 378 379 struct { 380 struct { 381 /* 382 * fd for the fcntl lock and process shared 383 * robust mutex to coordinate access to the 384 * client socket. When the system supports 385 * process shared robust mutexes, those are 386 * used. If not, then the fcntl lock will be 387 * used. 388 */ 389 int socket_lock_fd; 390 #ifdef HAVE_ROBUST_MUTEXES 391 pthread_mutex_t *socket_mutex; 392 #endif 393 394 /* 395 * fd for the trusted pipe from 396 * echo handler child 397 */ 398 int trusted_fd; 399 400 /* 401 * fde for the trusted_fd 402 */ 403 struct tevent_fd *trusted_fde; 404 405 /* 406 * Reference count for the fcntl lock to 407 * allow recursive locks. 408 */ 409 int ref_count; 410 } echo_handler; 411 412 struct { 413 bool encrypted_passwords; 414 bool spnego; 415 struct auth4_context *auth_context; 416 bool done; 417 /* 418 * Size of the data we can receive. Set by us. 419 * Can be modified by the max xmit parameter. 420 */ 421 int max_recv; 422 } negprot; 423 424 struct { 425 bool done_sesssetup; 426 /* 427 * Size of data we can send to client. Set 428 * by the client for all protocols above CORE. 429 * Set by us for CORE protocol. 430 */ 431 int max_send; 432 } sessions; 433 struct smb_signing_state *signing_state; 434 435 struct { 436 uint16_t client_major; 437 uint16_t client_minor; 438 uint32_t client_cap_low; 439 uint32_t client_cap_high; 440 } unix_info; 441 442 struct msg_state *msg_state; 443 } smb1; 444 struct { 445 struct smbd_smb2_request_read_state { 446 struct smbd_smb2_request *req; 447 struct { 448 uint8_t nbt[NBT_HDR_SIZE]; 449 bool done; 450 } hdr; 451 struct iovec vector; 452 bool doing_receivefile; 453 size_t min_recv_size; 454 size_t pktfull; 455 size_t pktlen; 456 uint8_t *pktbuf; 457 } request_read_state; 458 struct smbd_smb2_send_queue *send_queue; 459 size_t send_queue_len; 460 461 struct { 462 /* 463 * seq_low is the lowest sequence number 464 * we will accept. 465 */ 466 uint64_t seq_low; 467 /* 468 * seq_range is the range of credits we have 469 * granted from the sequence windows starting 470 * at seq_low. 471 * 472 * This gets incremented when new credits are 473 * granted and gets decremented when the 474 * lowest sequence number is consumed 475 * (when seq_low gets incremented). 476 */ 477 uint16_t seq_range; 478 /* 479 * The number of credits we have currently granted 480 * to the client. 481 * 482 * This gets incremented when new credits are 483 * granted and gets decremented when any credit 484 * is comsumed. 485 * 486 * Note: the decrementing is different compared 487 * to seq_range. 488 */ 489 uint16_t granted; 490 /* 491 * The maximum number of credits we will ever 492 * grant to the client. 493 * 494 * Typically we will only grant 1/16th of 495 * max_credits. 496 * 497 * This is the "server max credits" parameter. 498 */ 499 uint16_t max; 500 /* 501 * a bitmap of size max_credits 502 */ 503 struct bitmap *bitmap; 504 bool multicredit; 505 } credits; 506 507 bool allow_2ff; 508 struct { 509 uint32_t capabilities; 510 struct GUID guid; 511 bool guid_verified; 512 uint16_t security_mode; 513 uint16_t num_dialects; 514 uint16_t *dialects; 515 } client; 516 struct { 517 uint32_t capabilities; 518 struct GUID guid; 519 uint16_t security_mode; 520 uint16_t dialect; 521 uint32_t max_trans; 522 uint32_t max_read; 523 uint32_t max_write; 524 uint16_t cipher; 525 } server; 526 527 struct smbXsrv_preauth preauth; 528 529 struct smbd_smb2_request *requests; 530 } smb2; 531 }; 532 533 const char *smbXsrv_connection_dbg(const struct smbXsrv_connection *xconn); 534 535 NTSTATUS smbXsrv_version_global_init(const struct server_id *server_id); 536 uint32_t smbXsrv_version_global_current(void); 537 538 struct smbXsrv_client_table; 539 NTSTATUS smbXsrv_client_global_init(void); 540 NTSTATUS smbXsrv_client_create(TALLOC_CTX *mem_ctx, 541 struct tevent_context *ev_ctx, 542 struct messaging_context *msg_ctx, 543 NTTIME now, 544 struct smbXsrv_client **_client); 545 NTSTATUS smbXsrv_client_update(struct smbXsrv_client *client); 546 NTSTATUS smbXsrv_client_remove(struct smbXsrv_client *client); 547 NTSTATUS smb2srv_client_lookup_global(struct smbXsrv_client *client, 548 struct GUID client_guid, 549 TALLOC_CTX *mem_ctx, 550 struct smbXsrv_client_global0 **_pass); 551 NTSTATUS smb2srv_client_connection_pass(struct smbd_smb2_request *smb2req, 552 struct smbXsrv_client_global0 *global); 553 554 NTSTATUS smbXsrv_connection_init_tables(struct smbXsrv_connection *conn, 555 enum protocol_types protocol); 556 557 NTSTATUS smbXsrv_session_global_init(void); 558 NTSTATUS smbXsrv_session_create(struct smbXsrv_connection *conn, 559 NTTIME now, 560 struct smbXsrv_session **_session); 561 NTSTATUS smbXsrv_session_add_channel(struct smbXsrv_session *session, 562 struct smbXsrv_connection *conn, 563 struct smbXsrv_channel_global0 **_c); 564 NTSTATUS smbXsrv_session_update(struct smbXsrv_session *session); 565 struct smbXsrv_channel_global0; 566 NTSTATUS smbXsrv_session_find_channel(const struct smbXsrv_session *session, 567 const struct smbXsrv_connection *conn, 568 struct smbXsrv_channel_global0 **_c); 569 NTSTATUS smbXsrv_session_find_auth(const struct smbXsrv_session *session, 570 const struct smbXsrv_connection *conn, 571 NTTIME now, 572 struct smbXsrv_session_auth0 **_a); 573 NTSTATUS smbXsrv_session_create_auth(struct smbXsrv_session *session, 574 struct smbXsrv_connection *conn, 575 NTTIME now, 576 uint8_t in_flags, 577 uint8_t in_security_mode, 578 struct smbXsrv_session_auth0 **_a); 579 struct tevent_req *smb2srv_session_shutdown_send(TALLOC_CTX *mem_ctx, 580 struct tevent_context *ev, 581 struct smbXsrv_session *session, 582 struct smbd_smb2_request *current_req); 583 NTSTATUS smb2srv_session_shutdown_recv(struct tevent_req *req); 584 NTSTATUS smbXsrv_session_logoff(struct smbXsrv_session *session); 585 NTSTATUS smbXsrv_session_logoff_all(struct smbXsrv_connection *conn); 586 NTSTATUS smb1srv_session_table_init(struct smbXsrv_connection *conn); 587 NTSTATUS smb1srv_session_lookup(struct smbXsrv_connection *conn, 588 uint16_t vuid, NTTIME now, 589 struct smbXsrv_session **session); 590 NTSTATUS smb2srv_session_table_init(struct smbXsrv_connection *conn); 591 NTSTATUS smb2srv_session_lookup_conn(struct smbXsrv_connection *conn, 592 uint64_t session_id, NTTIME now, 593 struct smbXsrv_session **session); 594 NTSTATUS smb2srv_session_lookup_client(struct smbXsrv_client *client, 595 uint64_t session_id, NTTIME now, 596 struct smbXsrv_session **session); 597 struct smbXsrv_session_global0; 598 NTSTATUS smbXsrv_session_global_traverse( 599 int (*fn)(struct smbXsrv_session_global0 *, void *), 600 void *private_data); 601 struct tevent_req *smb2srv_session_close_previous_send(TALLOC_CTX *mem_ctx, 602 struct tevent_context *ev, 603 struct smbXsrv_connection *conn, 604 struct auth_session_info *session_info, 605 uint64_t previous_session_id, 606 uint64_t current_session_id); 607 NTSTATUS smb2srv_session_close_previous_recv(struct tevent_req *req); 608 609 NTSTATUS smbXsrv_tcon_global_init(void); 610 NTSTATUS smbXsrv_tcon_update(struct smbXsrv_tcon *tcon); 611 NTSTATUS smbXsrv_tcon_disconnect(struct smbXsrv_tcon *tcon, uint64_t vuid); 612 NTSTATUS smb1srv_tcon_table_init(struct smbXsrv_connection *conn); 613 NTSTATUS smb1srv_tcon_create(struct smbXsrv_connection *conn, 614 NTTIME now, 615 struct smbXsrv_tcon **_tcon); 616 NTSTATUS smb1srv_tcon_lookup(struct smbXsrv_connection *conn, 617 uint16_t tree_id, NTTIME now, 618 struct smbXsrv_tcon **tcon); 619 NTSTATUS smb1srv_tcon_disconnect_all(struct smbXsrv_connection *conn); 620 NTSTATUS smb2srv_tcon_table_init(struct smbXsrv_session *session); 621 NTSTATUS smb2srv_tcon_create(struct smbXsrv_session *session, 622 NTTIME now, 623 struct smbXsrv_tcon **_tcon); 624 NTSTATUS smb2srv_tcon_lookup(struct smbXsrv_session *session, 625 uint32_t tree_id, NTTIME now, 626 struct smbXsrv_tcon **tcon); 627 NTSTATUS smb2srv_tcon_disconnect_all(struct smbXsrv_session *session); 628 struct smbXsrv_tcon_global0; 629 NTSTATUS smbXsrv_tcon_global_traverse( 630 int (*fn)(struct smbXsrv_tcon_global0 *, void *), 631 void *private_data); 632 633 NTSTATUS smbXsrv_open_global_init(void); 634 NTSTATUS smbXsrv_open_create(struct smbXsrv_connection *conn, 635 struct auth_session_info *session_info, 636 NTTIME now, 637 struct smbXsrv_open **_open); 638 uint32_t smbXsrv_open_hash(struct smbXsrv_open *_open); 639 NTSTATUS smbXsrv_open_update(struct smbXsrv_open *_open); 640 NTSTATUS smbXsrv_open_close(struct smbXsrv_open *op, NTTIME now); 641 NTSTATUS smb1srv_open_table_init(struct smbXsrv_connection *conn); 642 NTSTATUS smb1srv_open_lookup(struct smbXsrv_connection *conn, 643 uint16_t fnum, NTTIME now, 644 struct smbXsrv_open **_open); 645 NTSTATUS smb2srv_open_table_init(struct smbXsrv_connection *conn); 646 NTSTATUS smb2srv_open_lookup(struct smbXsrv_connection *conn, 647 uint64_t persistent_id, 648 uint64_t volatile_id, 649 NTTIME now, 650 struct smbXsrv_open **_open); 651 NTSTATUS smb2srv_open_lookup_replay_cache(struct smbXsrv_connection *conn, 652 const struct GUID *create_guid, 653 NTTIME now, 654 struct smbXsrv_open **_open); 655 NTSTATUS smb2srv_open_recreate(struct smbXsrv_connection *conn, 656 struct auth_session_info *session_info, 657 uint64_t persistent_id, 658 const struct GUID *create_guid, 659 NTTIME now, 660 struct smbXsrv_open **_open); 661 struct smbXsrv_open_global0; 662 NTSTATUS smbXsrv_open_global_traverse( 663 int (*fn)(struct smbXsrv_open_global0 *, void *), 664 void *private_data); 665 666 NTSTATUS smbXsrv_open_cleanup(uint64_t persistent_id); 667 bool smbXsrv_is_encrypted(uint8_t encryption_flags); 668 bool smbXsrv_is_partially_encrypted(uint8_t encryption_flags); 669 bool smbXsrv_set_crypto_flag(uint8_t *flags, uint8_t flag); 670 bool smbXsrv_is_signed(uint8_t signing_flags); 671 bool smbXsrv_is_partially_signed(uint8_t signing_flags); 672 673 struct smbd_smb2_send_queue { 674 struct smbd_smb2_send_queue *prev, *next; 675 676 DATA_BLOB *sendfile_header; 677 NTSTATUS *sendfile_status; 678 struct iovec *vector; 679 int count; 680 681 TALLOC_CTX *mem_ctx; 682 }; 348 683 349 684 struct smbd_smb2_request { 350 685 struct smbd_smb2_request *prev, *next; 351 686 352 TALLOC_CTX *mem_pool;353 struct smbd_smb2_request **parent;354 355 687 struct smbd_server_connection *sconn; 688 struct smbXsrv_connection *xconn; 689 690 struct smbd_smb2_send_queue queue_entry; 356 691 357 692 /* the session the request operates on, maybe NULL */ 358 struct smb d_smb2_session *session;693 struct smbXsrv_session *session; 359 694 uint64_t last_session_id; 360 695 361 696 /* the tcon the request operates on, maybe NULL */ 362 struct smb d_smb2_tcon *tcon;697 struct smbXsrv_tcon *tcon; 363 698 uint32_t last_tid; 364 699 365 700 int current_idx; 366 701 bool do_signing; 367 bool async; 368 bool cancelled; 702 /* Was the request encrypted? */ 703 bool was_encrypted; 704 /* Should we encrypt? */ 705 bool do_encryption; 706 struct tevent_timer *async_te; 369 707 bool compound_related; 708 709 /* 710 * the encryption key for the whole 711 * compound chain 712 */ 713 DATA_BLOB first_key; 714 /* 715 * the signing key for the last 716 * request/response of a compound chain 717 */ 718 DATA_BLOB last_key; 719 struct smbXsrv_preauth *preauth; 720 721 struct timeval request_time; 722 723 SMBPROFILE_IOBYTES_ASYNC_STATE(profile); 370 724 371 725 /* fake smb1 request. */ … … 379 733 struct tevent_req *subreq; 380 734 735 #define SMBD_SMB2_TF_IOV_OFS 0 736 #define SMBD_SMB2_HDR_IOV_OFS 1 737 #define SMBD_SMB2_BODY_IOV_OFS 2 738 #define SMBD_SMB2_DYN_IOV_OFS 3 739 740 #define SMBD_SMB2_NUM_IOV_PER_REQ 4 741 742 #define SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,ofs) \ 743 (&req->dir.vector[(idx)+(ofs)]) 744 745 #define SMBD_SMB2_IDX_TF_IOV(req,dir,idx) \ 746 SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_TF_IOV_OFS) 747 #define SMBD_SMB2_IDX_HDR_IOV(req,dir,idx) \ 748 SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_HDR_IOV_OFS) 749 #define SMBD_SMB2_IDX_BODY_IOV(req,dir,idx) \ 750 SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_BODY_IOV_OFS) 751 #define SMBD_SMB2_IDX_DYN_IOV(req,dir,idx) \ 752 SMBD_SMB2_IOV_IDX_OFS(req,dir,idx,SMBD_SMB2_DYN_IOV_OFS) 753 754 #define SMBD_SMB2_IN_TF_IOV(req) SMBD_SMB2_IDX_TF_IOV(req,in,req->current_idx) 755 #define SMBD_SMB2_IN_TF_PTR(req) (uint8_t *)(SMBD_SMB2_IN_TF_IOV(req)->iov_base) 756 #define SMBD_SMB2_IN_HDR_IOV(req) SMBD_SMB2_IDX_HDR_IOV(req,in,req->current_idx) 757 #define SMBD_SMB2_IN_HDR_PTR(req) (uint8_t *)(SMBD_SMB2_IN_HDR_IOV(req)->iov_base) 758 #define SMBD_SMB2_IN_BODY_IOV(req) SMBD_SMB2_IDX_BODY_IOV(req,in,req->current_idx) 759 #define SMBD_SMB2_IN_BODY_PTR(req) (uint8_t *)(SMBD_SMB2_IN_BODY_IOV(req)->iov_base) 760 #define SMBD_SMB2_IN_BODY_LEN(req) (SMBD_SMB2_IN_BODY_IOV(req)->iov_len) 761 #define SMBD_SMB2_IN_DYN_IOV(req) SMBD_SMB2_IDX_DYN_IOV(req,in,req->current_idx) 762 #define SMBD_SMB2_IN_DYN_PTR(req) (uint8_t *)(SMBD_SMB2_IN_DYN_IOV(req)->iov_base) 763 #define SMBD_SMB2_IN_DYN_LEN(req) (SMBD_SMB2_IN_DYN_IOV(req)->iov_len) 764 765 #define SMBD_SMB2_OUT_TF_IOV(req) SMBD_SMB2_IDX_TF_IOV(req,out,req->current_idx) 766 #define SMBD_SMB2_OUT_TF_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_TF_IOV(req)->iov_base) 767 #define SMBD_SMB2_OUT_HDR_IOV(req) SMBD_SMB2_IDX_HDR_IOV(req,out,req->current_idx) 768 #define SMBD_SMB2_OUT_HDR_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_HDR_IOV(req)->iov_base) 769 #define SMBD_SMB2_OUT_BODY_IOV(req) SMBD_SMB2_IDX_BODY_IOV(req,out,req->current_idx) 770 #define SMBD_SMB2_OUT_BODY_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_BODY_IOV(req)->iov_base) 771 #define SMBD_SMB2_OUT_BODY_LEN(req) (SMBD_SMB2_OUT_BODY_IOV(req)->iov_len) 772 #define SMBD_SMB2_OUT_DYN_IOV(req) SMBD_SMB2_IDX_DYN_IOV(req,out,req->current_idx) 773 #define SMBD_SMB2_OUT_DYN_PTR(req) (uint8_t *)(SMBD_SMB2_OUT_DYN_IOV(req)->iov_base) 774 #define SMBD_SMB2_OUT_DYN_LEN(req) (SMBD_SMB2_OUT_DYN_IOV(req)->iov_len) 775 776 #define SMBD_SMB2_SHORT_RECEIVEFILE_WRITE_LEN (SMB2_HDR_BODY + 0x30) 777 381 778 struct { 382 /* the NBT header is not allocated */383 uint8_t nbt_hdr[4];384 779 /* 385 * vector[0] NBT 386 * . 387 * vector[1] SMB2 388 * vector[2] fixed body 389 * vector[3] dynamic body 390 * . 391 * . 392 * . 393 * vector[4] SMB2 394 * vector[5] fixed body 395 * vector[6] dynamic body 780 * vector[0] TRANSPORT HEADER (empty) 781 * . 782 * vector[1] SMB2_TRANSFORM (optional) 783 * vector[2] SMB2 784 * vector[3] fixed body 785 * vector[4] dynamic body 786 * . 787 * . 788 * . 789 * vector[5] SMB2_TRANSFORM (optional) 790 * vector[6] SMB2 791 * vector[7] fixed body 792 * vector[8] dynamic body 396 793 * . 397 794 * . … … 400 797 struct iovec *vector; 401 798 int vector_count; 799 struct iovec _vector[1 + SMBD_SMB2_NUM_IOV_PER_REQ]; 402 800 } in; 403 801 struct { … … 405 803 uint8_t nbt_hdr[4]; 406 804 /* 407 * vector[0] NBT 408 * . 409 * vector[1] SMB2 410 * vector[2] fixed body 411 * vector[3] dynamic body 412 * . 413 * . 414 * . 415 * vector[4] SMB2 416 * vector[5] fixed body 417 * vector[6] dynamic body 805 * vector[0] TRANSPORT HEADER 806 * . 807 * vector[1] SMB2_TRANSFORM (optional) 808 * vector[2] SMB2 809 * vector[3] fixed body 810 * vector[4] dynamic body 811 * . 812 * . 813 * . 814 * vector[5] SMB2_TRANSFORM (empty) 815 * vector[6] SMB2 816 * vector[7] fixed body 817 * vector[8] dynamic body 418 818 * . 419 819 * . … … 422 822 struct iovec *vector; 423 823 int vector_count; 824 struct iovec _vector[1 + SMBD_SMB2_NUM_IOV_PER_REQ]; 825 #define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9) 826 uint8_t _hdr[OUTVEC_ALLOC_SIZE]; 827 uint8_t _body[0x58]; 424 828 } out; 425 829 }; 426 830 427 831 struct smbd_server_connection; 428 429 struct smbd_smb2_session { 430 struct smbd_smb2_session *prev, *next; 431 struct smbd_server_connection *sconn; 432 NTSTATUS status; 433 uint64_t vuid; 434 struct auth_ntlmssp_state *auth_ntlmssp_state; 435 struct auth_serversupplied_info *session_info; 436 DATA_BLOB session_key; 437 bool do_signing; 438 439 user_struct *compat_vuser; 440 441 struct { 442 /* an id tree used to allocate tids */ 443 struct idr_context *idtree; 444 445 /* this is the limit of tid values for this connection */ 446 uint32_t limit; 447 448 struct smbd_smb2_tcon *list; 449 } tcons; 832 struct user_struct; 833 834 struct pending_message_list; 835 struct pending_auth_data; 836 837 struct user_struct { 838 struct user_struct *next, *prev; 839 uint64_t vuid; /* Tag for this entry. */ 840 841 char *session_keystr; /* used by utmp and pam session code. 842 TDB key string */ 843 int homes_snum; 844 845 struct auth_session_info *session_info; 846 847 struct smbXsrv_session *session; 450 848 }; 451 849 452 struct smbd_smb2_tcon {453 struct smbd_smb2_tcon *prev, *next;454 struct smbd_smb2_session *session;455 uint32_t tid;456 int snum;457 connection_struct *compat_conn;458 };459 460 struct pending_auth_data;461 462 850 struct smbd_server_connection { 463 int sock;464 struct client_address client_id;465 851 const struct tsocket_address *local_address; 466 852 const struct tsocket_address *remote_address; 853 const char *remote_hostname; 854 struct tevent_context *ev_ctx; 467 855 struct messaging_context *msg_ctx; 468 struct { 469 bool got_session; 470 } nbt; 856 struct sys_notify_context *sys_notify_ctx; 857 struct notify_context *notify_ctx; 471 858 bool using_smb2; 472 859 int trans_num; 473 860 474 /* 475 * Cache for calling poll(2) to avoid allocations in our 476 * central event loop 477 */ 478 struct pollfd *pfds; 479 861 size_t num_users; 862 struct user_struct *users; 863 864 size_t num_connections; 865 struct connection_struct *connections; 866 867 size_t num_files; 480 868 struct files_struct *files; 481 struct bitmap *file_bmap; 869 482 870 int real_max_open_files; 483 int files_used;484 871 struct fsp_singleton_cache fsp_fi_cache; 485 unsigned long file_gen_counter; 486 int first_file; 487 488 /* number of open connections (tcons) */ 489 int num_tcons_open; 872 873 struct pending_message_list *deferred_open_queue; 874 490 875 491 876 /* open directory handles. */ … … 498 883 uint64_t num_requests; 499 884 885 /* Current number of oplocks we have outstanding. */ 500 886 struct { 501 struct fd_event *fde; 502 503 struct { 504 /* 505 * fd for the fcntl lock mutexing access to our sock 506 */ 507 int socket_lock_fd; 508 509 /* 510 * fd for the trusted pipe from 511 * echo handler child 512 */ 513 int trusted_fd; 514 515 /* 516 * fde for the trusted_fd 517 */ 518 struct fd_event *trusted_fde; 519 520 /* 521 * Reference count for the fcntl lock to 522 * allow recursive locks. 523 */ 524 int ref_count; 525 } echo_handler; 526 527 struct { 528 bool encrypted_passwords; 529 bool spnego; 530 struct auth_context *auth_context; 531 bool done; 532 /* 533 * Size of the data we can receive. Set by us. 534 * Can be modified by the max xmit parameter. 535 */ 536 int max_recv; 537 } negprot; 538 539 struct { 540 bool done_sesssetup; 541 /* 542 * Size of data we can send to client. Set 543 * by the client for all protocols above CORE. 544 * Set by us for CORE protocol. 545 */ 546 int max_send; 547 uint16_t last_session_tag; 548 549 /* users from session setup */ 550 char *session_userlist; 551 /* workgroup from session setup. */ 552 char *session_workgroup; 553 /* 554 * this holds info on user ids that are already 555 * validated for this VC 556 */ 557 user_struct *validated_users; 558 uint16_t next_vuid; 559 int num_validated_vuids; 560 } sessions; 561 struct { 562 connection_struct *Connections; 563 /* number of open connections */ 564 struct bitmap *bmap; 565 } tcons; 566 struct smb_signing_state *signing_state; 567 /* List to store partial SPNEGO auth fragments. */ 568 struct pending_auth_data *pd_list; 569 887 int32_t exclusive_open; 888 int32_t level_II_open; 889 struct kernel_oplocks *kernel_ops; 890 } oplocks; 891 892 struct { 570 893 struct notify_mid_map *notify_mid_maps; 571 894 … … 577 900 578 901 /* The event that makes us process our blocking lock queue */ 579 struct t imed_event*brl_timeout;902 struct tevent_timer *brl_timeout; 580 903 581 904 bool blocking_lock_unlock_state; … … 584 907 } smb1; 585 908 struct { 586 struct tevent_context *event_ctx;587 struct tevent_queue *recv_queue;588 struct tevent_queue *send_queue;589 struct tstream_context *stream;590 struct {591 /* an id tree used to allocate vuids */592 /* this holds info on session vuids that are already593 * validated for this VC */594 struct idr_context *idtree;595 596 /* this is the limit of vuid values for this connection */597 uint64_t limit;598 599 struct smbd_smb2_session *list;600 } sessions;601 909 struct { 602 910 /* The event that makes us process our blocking lock queue */ 603 struct t imed_event*brl_timeout;911 struct tevent_timer *brl_timeout; 604 912 bool blocking_lock_unlock_state; 605 913 } locks; 606 struct smbd_smb2_request *requests;607 /*608 * seqnum_low is the lowest sequence number609 * we will accept.610 */611 uint64_t seqnum_low;612 /*613 * seqnum_range is the range of credits we have614 * granted from the sequence windows starting615 * at seqnum_low.616 *617 * This gets incremented when new credits are618 * granted and gets decremented when the619 * lowest sequence number is consumed620 * (when seqnum_low gets incremented).621 */622 uint16_t seqnum_range;623 /*624 * credits_grantedThe number of credits we have currently granted625 * to the client.626 *627 * This gets incremented when new credits are628 * granted and gets decremented when any credit629 * is comsumed.630 *631 * Note: the decrementing is different compared632 * to seqnum_range.633 */634 uint16_t credits_granted;635 /*636 * The maximum number of credits we will ever637 * grant to the client.638 *639 * Typically we will only grant 1/16th of640 * max_credits.641 *642 * This is the "server max credits" parameter.643 */644 uint16_t max_credits;645 /*646 * a bitmap of size max_credits647 */648 struct bitmap *credits_bitmap;649 uint32_t max_trans;650 uint32_t max_read;651 uint32_t max_write;652 914 } smb2; 915 916 /* 917 * Link into libasys for asynchronous operations 918 */ 919 struct asys_context *asys_ctx; 920 struct tevent_fd *asys_fde; 921 922 struct smbXsrv_client *client; 653 923 }; 654 924 655 extern struct smbd_server_connection *smbd_server_conn; 656 657 struct smbd_server_connection *msg_ctx_to_sconn(struct messaging_context *msg_ctx); 925 extern struct smbXsrv_client *global_smbXsrv_client; 658 926 659 927 void smbd_init_globals(void);
Note:
See TracChangeset
for help on using the changeset viewer.