s3: Lift smbd_server_fd() from pass_check()
[samba.git] / source3 / include / proto.h
index ca52984eb867bd00b4a66e03e1f37e60dc10cd70..e2d1c94e7bf74315caa87e67bb01b53f1a0586eb 100644 (file)
@@ -66,6 +66,10 @@ NTSTATUS check_sam_security(const DATA_BLOB *challenge,
                            TALLOC_CTX *mem_ctx,
                            const struct auth_usersupplied_info *user_info,
                            struct auth_serversupplied_info **server_info);
+NTSTATUS check_sam_security_info3(const DATA_BLOB *challenge,
+                                 TALLOC_CTX *mem_ctx,
+                                 const struct auth_usersupplied_info *user_info,
+                                 struct netr_SamInfo3 **pinfo3);
 NTSTATUS auth_sam_init(void);
 
 /* The following definitions come from auth/auth_server.c  */
@@ -79,13 +83,15 @@ NTSTATUS auth_unix_init(void);
 /* The following definitions come from auth/auth_util.c  */
 
 NTSTATUS make_user_info_map(struct auth_usersupplied_info **user_info,
-                           const char *smb_name, 
-                           const char *client_domain, 
+                           const char *smb_name,
+                           const char *client_domain,
                            const char *workstation_name,
-                           DATA_BLOB *lm_pwd, DATA_BLOB *nt_pwd,
-                           DATA_BLOB *lm_interactive_pwd, DATA_BLOB *nt_interactive_pwd,
-                           DATA_BLOB *plaintext, 
-                           bool encrypted);
+                           DATA_BLOB *lm_pwd,
+                           DATA_BLOB *nt_pwd,
+                           const struct samr_Password *lm_interactive_pwd,
+                           const struct samr_Password *nt_interactive_pwd,
+                           const char *plaintext,
+                           enum auth_password_state password_state);
 bool make_user_info_netlogon_network(struct auth_usersupplied_info **user_info,
                                     const char *smb_name, 
                                     const char *client_domain, 
@@ -142,7 +148,7 @@ NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
 NTSTATUS make_server_info_system(TALLOC_CTX *mem_ctx,
                                 struct auth_serversupplied_info **server_info);
 bool copy_current_user(struct current_user *dst, struct current_user *src);
-struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, char *domuser,
+struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
                             fstring save_username, bool create );
 NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, 
                                const char *sent_nt_username,
@@ -160,7 +166,7 @@ bool is_trusted_domain(const char* dom_name);
 
 /* The following definitions come from auth/user_info.c  */
 
-NTSTATUS make_user_info(struct auth_usersupplied_info **user_info,
+NTSTATUS make_user_info(struct auth_usersupplied_info **ret_user_info,
                        const char *smb_name,
                        const char *internal_username,
                        const char *client_domain,
@@ -168,10 +174,10 @@ NTSTATUS make_user_info(struct auth_usersupplied_info **user_info,
                        const char *workstation_name,
                        const DATA_BLOB *lm_pwd,
                        const DATA_BLOB *nt_pwd,
-                       const DATA_BLOB *lm_interactive_pwd,
-                       const DATA_BLOB *nt_interactive_pwd,
-                       const DATA_BLOB *plaintext,
-                       bool encrypted);
+                       const struct samr_Password *lm_interactive_pwd,
+                       const struct samr_Password *nt_interactive_pwd,
+                       const char *plaintext_password,
+                       enum auth_password_state password_state);
 void free_user_info(struct auth_usersupplied_info **user_info);
 
 /* The following definitions come from auth/auth_winbind.c  */
@@ -215,18 +221,22 @@ NTSTATUS auth_wbc_init(void);
 
 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
 bool smb_pam_close_session(char *user, char *tty, char *rhost);
-NTSTATUS smb_pam_accountcheck(const char * user);
-NTSTATUS smb_pam_passcheck(const char * user, const char * password);
-bool smb_pam_passchange(const char * user, const char * oldpassword, const char * newpassword);
-NTSTATUS smb_pam_accountcheck(const char * user);
+NTSTATUS smb_pam_accountcheck(const char *user, const char *rhost);
+NTSTATUS smb_pam_passcheck(const char * user, const char * rhost,
+                          const char * password);
+bool smb_pam_passchange(const char *user, const char *rhost,
+                       const char *oldpassword, const char *newpassword);
 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
 
 /* The following definitions come from auth/pass_check.c  */
 
 void dfs_unlogin(void);
-NTSTATUS pass_check(const struct passwd *pass, const char *user, const char *password, 
-                   int pwlen, bool (*fn) (const char *, const char *), bool run_cracker);
+NTSTATUS pass_check(const struct passwd *pass,
+                   const char *user,
+                   const char *rhost,
+                   const char *password,
+                   bool run_cracker);
 
 /* The following definitions come from auth/token_util.c  */
 
@@ -345,7 +355,6 @@ bool allow_access(const char **deny_list,
                const char **allow_list,
                const char *cname,
                const char *caddr);
-bool check_access(int sock, const char **allow_list, const char **deny_list);
 
 /* The following definitions come from passdb/account_pol.c  */
 
@@ -493,44 +502,6 @@ int connections_forall_read(int (*fn)(const struct connections_key *key,
                            void *private_data);
 bool connections_init(bool rw);
 
-/* The following definitions come from lib/dbwrap_util.c  */
-
-int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr);
-int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v);
-bool dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
-                        uint32_t *val);
-int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v);
-NTSTATUS dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
-                                    uint32_t *oldval, uint32_t change_val);
-NTSTATUS dbwrap_trans_change_uint32_atomic(struct db_context *db,
-                                          const char *keystr,
-                                          uint32_t *oldval,
-                                          uint32_t change_val);
-NTSTATUS dbwrap_change_int32_atomic(struct db_context *db, const char *keystr,
-                                   int32_t *oldval, int32_t change_val);
-NTSTATUS dbwrap_trans_change_int32_atomic(struct db_context *db,
-                                         const char *keystr,
-                                         int32_t *oldval,
-                                         int32_t change_val);
-NTSTATUS dbwrap_trans_store(struct db_context *db, TDB_DATA key, TDB_DATA dbuf,
-                           int flag);
-NTSTATUS dbwrap_trans_delete(struct db_context *db, TDB_DATA key);
-NTSTATUS dbwrap_trans_store_int32(struct db_context *db, const char *keystr,
-                                 int32_t v);
-NTSTATUS dbwrap_trans_store_uint32(struct db_context *db, const char *keystr,
-                                  uint32_t v);
-NTSTATUS dbwrap_trans_store_bystring(struct db_context *db, const char *key,
-                                    TDB_DATA data, int flags);
-NTSTATUS dbwrap_trans_delete_bystring(struct db_context *db, const char *key);
-NTSTATUS dbwrap_trans_do(struct db_context *db,
-                        NTSTATUS (*action)(struct db_context *, void *),
-                        void *private_data);
-NTSTATUS dbwrap_delete_bystring_upper(struct db_context *db, const char *key);
-NTSTATUS dbwrap_store_bystring_upper(struct db_context *db, const char *key,
-                                    TDB_DATA data, int flags);
-TDB_DATA dbwrap_fetch_bystring_upper(struct db_context *db, TALLOC_CTX *mem_ctx,
-                                    const char *key);
-
 /* The following definitions come from lib/debug.c  */
 
 void gfree_debugsyms(void);
@@ -964,6 +935,13 @@ int sys_set_vfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qt
 int sys_get_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
 int sys_set_xfs_quota(const char *path, const char *bdev, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp);
 
+int sys_get_nfs_quota(const char *path, const char *bdev,
+                     enum SMB_QUOTA_TYPE qtype,
+                     unid_t id, SMB_DISK_QUOTA *dp);
+int sys_set_nfs_quota(const char *path, const char *bdev,
+                     enum SMB_QUOTA_TYPE qtype,
+                     unid_t id, SMB_DISK_QUOTA *dp);
+
 /* The following definitions come from lib/system.c  */
 
 void *sys_memalign( size_t align, size_t size );
@@ -1442,8 +1420,6 @@ bool send_keepalive(int client);
 NTSTATUS read_smb_length_return_keepalive(int fd, char *inbuf,
                                          unsigned int timeout,
                                          size_t *len);
-NTSTATUS read_smb_length(int fd, char *inbuf, unsigned int timeout,
-                        size_t *len);
 NTSTATUS receive_smb_raw(int fd,
                        char *buffer,
                        size_t buflen,
@@ -1872,7 +1848,6 @@ bool cli_state_seqnum_persistent(struct cli_state *cli,
 bool cli_state_seqnum_remove(struct cli_state *cli,
                             uint16_t mid);
 bool cli_receive_smb(struct cli_state *cli);
-ssize_t cli_receive_smb_data(struct cli_state *cli, char *buffer, size_t len);
 bool cli_receive_smb_readX_header(struct cli_state *cli);
 bool cli_send_smb(struct cli_state *cli);
 bool cli_send_smb_direct_writeX(struct cli_state *cli,
@@ -2067,6 +2042,8 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
                      uint16_t *pfid);
 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
                            size_t str_len, size_t *pconverted_size);
+uint8_t *smb_bytes_push_bytes(uint8_t *buf, uint8_t prefix,
+                             const uint8_t *bytes, size_t num_bytes);
 struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
                                   struct event_context *ev,
                                   struct cli_state *cli, const char *fname,
@@ -2331,12 +2308,22 @@ bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_
 
 /* The following definitions come from libsmb/clilist.c  */
 
-int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
-                void (*fn)(const char *, struct file_info *, const char *,
-                           void *), void *state);
-int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
-                void (*fn)(const char *, struct file_info *, const char *,
-                           void *), void *state);
+NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
+                     void (*fn)(const char *, struct file_info *,
+                                const char *, void *), void *state);
+NTSTATUS cli_list_trans(struct cli_state *cli, const char *mask,
+                       uint16_t attribute, int info_level,
+                       void (*fn)(const char *mnt, struct file_info *finfo,
+                                  const char *mask, void *private_data),
+                       void *private_data);
+struct tevent_req *cli_list_send(TALLOC_CTX *mem_ctx,
+                                struct tevent_context *ev,
+                                struct cli_state *cli,
+                                const char *mask,
+                                uint16_t attribute,
+                                uint16_t info_level);
+NTSTATUS cli_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+                      struct file_info **finfo, size_t *num_finfo);
 NTSTATUS cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
                  void (*fn)(const char *, struct file_info *, const char *,
                             void *), void *state);
@@ -2480,6 +2467,13 @@ NTSTATUS cli_qpathinfo(TALLOC_CTX *mem_ctx, struct cli_state *cli,
                       uint32_t max_rdata,
                       uint8_t **rdata, uint32_t *num_rdata);
 
+struct tevent_req *cli_flush_send(TALLOC_CTX *mem_ctx,
+                                 struct event_context *ev,
+                                 struct cli_state *cli,
+                                 uint16_t fnum);
+NTSTATUS cli_flush_recv(struct tevent_req *req);
+NTSTATUS cli_flush(TALLOC_CTX *mem_ctx, struct cli_state *cli, uint16_t fnum);
+
 /* The following definitions come from libsmb/clirap2.c  */
 struct rap_group_info_1;
 struct rap_user_info_1;
@@ -3208,363 +3202,6 @@ ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, c
 ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files_struct *fsp, char *list, size_t size);
 NTSTATUS vfs_default_init(void);
 
-/* The following definitions come from nmbd/asyncdns.c  */
-
-int asyncdns_fd(void);
-void kill_async_dns_child(void);
-void start_async_dns(void);
-void run_dns_queue(void);
-bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
-bool queue_dns_query(struct packet_struct *p,struct nmb_name *question);
-void kill_async_dns_child(void);
-
-/* The following definitions come from nmbd/nmbd.c  */
-
-struct event_context *nmbd_event_context(void);
-struct messaging_context *nmbd_messaging_context(void);
-
-/* The following definitions come from nmbd/nmbd_become_dmb.c  */
-
-void add_domain_names(time_t t);
-
-/* The following definitions come from nmbd/nmbd_become_lmb.c  */
-
-void insert_permanent_name_into_unicast( struct subnet_record *subrec, 
-                                                struct nmb_name *nmbname, uint16 nb_type );
-void unbecome_local_master_browser(struct subnet_record *subrec, struct work_record *work,
-                                   bool force_new_election);
-void become_local_master_browser(struct subnet_record *subrec, struct work_record *work);
-void set_workgroup_local_master_browser_name( struct work_record *work, const char *newname);
-
-/* The following definitions come from nmbd/nmbd_browserdb.c  */
-
-void update_browser_death_time( struct browse_cache_record *browc );
-struct browse_cache_record *create_browser_in_lmb_cache( const char *work_name, 
-                                                         const char *browser_name, 
-                                                         struct in_addr ip );
-struct browse_cache_record *find_browser_in_lmb_cache( const char *browser_name );
-void expire_lmb_browsers( time_t t );
-
-/* The following definitions come from nmbd/nmbd_browsesync.c  */
-
-void dmb_expire_and_sync_browser_lists(time_t t);
-void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec,
-                                                   struct work_record *work);
-void collect_all_workgroup_names_from_wins_server(time_t t);
-void sync_all_dmbs(time_t t);
-
-/* The following definitions come from nmbd/nmbd_elections.c  */
-
-void check_master_browser_exists(time_t t);
-void run_elections(time_t t);
-void process_election(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-bool check_elections(void);
-void nmbd_message_election(struct messaging_context *msg,
-                          void *private_data,
-                          uint32_t msg_type,
-                          struct server_id server_id,
-                          DATA_BLOB *data);
-
-/* The following definitions come from nmbd/nmbd_incomingdgrams.c  */
-
-void tell_become_backup(void);
-void process_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-void process_workgroup_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-void process_local_master_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-void process_master_browser_announce(struct subnet_record *subrec, 
-                                     struct packet_struct *p,char *buf);
-void process_lm_host_announce(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len);
-void process_get_backup_list_request(struct subnet_record *subrec,
-                                     struct packet_struct *p,char *buf);
-void process_reset_browser(struct subnet_record *subrec,
-                                  struct packet_struct *p,char *buf);
-void process_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf);
-void process_lm_announce_request(struct subnet_record *subrec, struct packet_struct *p, char *buf, int len);
-
-/* The following definitions come from nmbd/nmbd_incomingrequests.c  */
-
-void process_name_release_request(struct subnet_record *subrec, 
-                                  struct packet_struct *p);
-void process_name_refresh_request(struct subnet_record *subrec,
-                                  struct packet_struct *p);
-void process_name_registration_request(struct subnet_record *subrec, 
-                                       struct packet_struct *p);
-void process_node_status_request(struct subnet_record *subrec, struct packet_struct *p);
-void process_name_query_request(struct subnet_record *subrec, struct packet_struct *p);
-
-/* The following definitions come from nmbd/nmbd_lmhosts.c  */
-
-void load_lmhosts_file(const char *fname);
-bool find_name_in_lmhosts(struct nmb_name *nmbname, struct name_record **namerecp);
-
-/* The following definitions come from nmbd/nmbd_logonnames.c  */
-
-void add_logon_names(void);
-
-/* The following definitions come from nmbd/nmbd_mynames.c  */
-
-void register_my_workgroup_one_subnet(struct subnet_record *subrec);
-bool register_my_workgroup_and_names(void);
-void release_wins_names(void);
-void refresh_my_names(time_t t);
-
-/* The following definitions come from nmbd/nmbd_namelistdb.c  */
-
-void set_samba_nb_type(void);
-void remove_name_from_namelist(struct subnet_record *subrec, 
-                               struct name_record *namerec );
-struct name_record *find_name_on_subnet(struct subnet_record *subrec,
-                               const struct nmb_name *nmbname,
-                               bool self_only);
-struct name_record *find_name_for_remote_broadcast_subnet(struct nmb_name *nmbname,
-                                               bool self_only);
-void update_name_ttl( struct name_record *namerec, int ttl );
-bool add_name_to_subnet( struct subnet_record *subrec,
-                       const char *name,
-                       int type,
-                       uint16 nb_flags,
-                       int ttl,
-                       enum name_source source,
-                       int num_ips,
-                       struct in_addr *iplist);
-void standard_success_register(struct subnet_record *subrec, 
-                             struct userdata_struct *userdata,
-                             struct nmb_name *nmbname, uint16 nb_flags, int ttl,
-                             struct in_addr registered_ip);
-void standard_fail_register( struct subnet_record   *subrec,
-                             struct nmb_name        *nmbname );
-bool find_ip_in_name_record( struct name_record *namerec, struct in_addr ip );
-void add_ip_to_name_record( struct name_record *namerec, struct in_addr new_ip );
-void remove_ip_from_name_record( struct name_record *namerec,
-                                 struct in_addr      remove_ip );
-void standard_success_release( struct subnet_record   *subrec,
-                               struct userdata_struct *userdata,
-                               struct nmb_name        *nmbname,
-                               struct in_addr          released_ip );
-void expire_names(time_t t);
-void add_samba_names_to_subnet( struct subnet_record *subrec );
-void dump_name_record( struct name_record *namerec, XFILE *fp);
-void dump_all_namelists(void);
-
-/* The following definitions come from nmbd/nmbd_namequery.c  */
-
-bool query_name(struct subnet_record *subrec, const char *name, int type,
-                   query_name_success_function success_fn,
-                   query_name_fail_function fail_fn, 
-                   struct userdata_struct *userdata);
-bool query_name_from_wins_server(struct in_addr ip_to, 
-                   const char *name, int type,
-                   query_name_success_function success_fn,
-                   query_name_fail_function fail_fn, 
-                   struct userdata_struct *userdata);
-
-/* The following definitions come from nmbd/nmbd_nameregister.c  */
-
-void register_name(struct subnet_record *subrec,
-                   const char *name, int type, uint16 nb_flags,
-                   register_name_success_function success_fn,
-                   register_name_fail_function fail_fn,
-                   struct userdata_struct *userdata);
-void wins_refresh_name(struct name_record *namerec);
-
-/* The following definitions come from nmbd/nmbd_namerelease.c  */
-
-void release_name(struct subnet_record *subrec, struct name_record *namerec,
-                 release_name_success_function success_fn,
-                 release_name_fail_function fail_fn,
-                 struct userdata_struct *userdata);
-
-/* The following definitions come from nmbd/nmbd_nodestatus.c  */
-
-bool node_status(struct subnet_record *subrec, struct nmb_name *nmbname,
-                 struct in_addr send_ip, node_status_success_function success_fn, 
-                 node_status_fail_function fail_fn, struct userdata_struct *userdata);
-
-/* The following definitions come from nmbd/nmbd_packets.c  */
-
-uint16 get_nb_flags(char *buf);
-void set_nb_flags(char *buf, uint16 nb_flags);
-struct response_record *queue_register_name( struct subnet_record *subrec,
-                          response_function resp_fn,
-                          timeout_response_function timeout_fn,
-                          register_name_success_function success_fn,
-                          register_name_fail_function fail_fn,
-                          struct userdata_struct *userdata,
-                          struct nmb_name *nmbname,
-                          uint16 nb_flags);
-void queue_wins_refresh(struct nmb_name *nmbname,
-                       response_function resp_fn,
-                       timeout_response_function timeout_fn,
-                       uint16 nb_flags,
-                       struct in_addr refresh_ip,
-                       const char *tag);
-struct response_record *queue_register_multihomed_name( struct subnet_record *subrec,
-                                                       response_function resp_fn,
-                                                       timeout_response_function timeout_fn,
-                                                       register_name_success_function success_fn,
-                                                       register_name_fail_function fail_fn,
-                                                       struct userdata_struct *userdata,
-                                                       struct nmb_name *nmbname,
-                                                       uint16 nb_flags,
-                                                       struct in_addr register_ip,
-                                                       struct in_addr wins_ip);
-struct response_record *queue_release_name( struct subnet_record *subrec,
-                                           response_function resp_fn,
-                                           timeout_response_function timeout_fn,
-                                           release_name_success_function success_fn,
-                                           release_name_fail_function fail_fn,
-                                           struct userdata_struct *userdata,
-                                           struct nmb_name *nmbname,
-                                           uint16 nb_flags,
-                                           struct in_addr release_ip,
-                                           struct in_addr dest_ip);
-struct response_record *queue_query_name( struct subnet_record *subrec,
-                          response_function resp_fn,
-                          timeout_response_function timeout_fn,
-                          query_name_success_function success_fn,
-                          query_name_fail_function fail_fn,
-                          struct userdata_struct *userdata,
-                          struct nmb_name *nmbname);
-struct response_record *queue_query_name_from_wins_server( struct in_addr to_ip,
-                          response_function resp_fn,
-                          timeout_response_function timeout_fn,
-                          query_name_success_function success_fn,
-                          query_name_fail_function fail_fn,
-                          struct userdata_struct *userdata,
-                          struct nmb_name *nmbname);
-struct response_record *queue_node_status( struct subnet_record *subrec,
-                          response_function resp_fn,
-                          timeout_response_function timeout_fn,
-                          node_status_success_function success_fn,
-                          node_status_fail_function fail_fn,
-                          struct userdata_struct *userdata,
-                          struct nmb_name *nmbname,
-                          struct in_addr send_ip);
-void reply_netbios_packet(struct packet_struct *orig_packet,
-                          int rcode, enum netbios_reply_type_code rcv_code, int opcode,
-                          int ttl, char *data,int len);
-void queue_packet(struct packet_struct *packet);
-void run_packet_queue(void);
-void retransmit_or_expire_response_records(time_t t);
-bool listen_for_packets(bool run_election);
-bool send_mailslot(bool unique, const char *mailslot,char *buf, size_t len,
-                   const char *srcname, int src_type,
-                   const char *dstname, int dest_type,
-                   struct in_addr dest_ip,struct in_addr src_ip,
-                  int dest_port);
-
-/* The following definitions come from nmbd/nmbd_processlogon.c  */
-
-bool initialize_nmbd_proxy_logon(void);
-
-void process_logon_packet(struct packet_struct *p, char *buf,int len, 
-                          const char *mailslot);
-
-/* The following definitions come from nmbd/nmbd_responserecordsdb.c  */
-
-void remove_response_record(struct subnet_record *subrec,
-                               struct response_record *rrec);
-struct response_record *make_response_record( struct subnet_record *subrec,
-                                             struct packet_struct *p,
-                                             response_function resp_fn,
-                                             timeout_response_function timeout_fn,
-                                             success_function success_fn,
-                                             fail_function fail_fn,
-                                             struct userdata_struct *userdata);
-struct response_record *find_response_record(struct subnet_record **ppsubrec,
-                               uint16 id);
-bool is_refresh_already_queued(struct subnet_record *subrec, struct name_record *namerec);
-
-/* The following definitions come from nmbd/nmbd_sendannounce.c  */
-
-void send_browser_reset(int reset_type, const char *to_name, int to_type, struct in_addr to_ip);
-void broadcast_announce_request(struct subnet_record *subrec, struct work_record *work);
-void announce_my_server_names(time_t t);
-void announce_my_lm_server_names(time_t t);
-void reset_announce_timer(void);
-void announce_myself_to_domain_master_browser(time_t t);
-void announce_my_servers_removed(void);
-void announce_remote(time_t t);
-void browse_sync_remote(time_t t);
-
-/* The following definitions come from nmbd/nmbd_serverlistdb.c  */
-
-void remove_all_servers(struct work_record *work);
-struct server_record *find_server_in_workgroup(struct work_record *work, const char *name);
-void remove_server_from_workgroup(struct work_record *work, struct server_record *servrec);
-struct server_record *create_server_on_workgroup(struct work_record *work,
-                                                 const char *name,int servertype, 
-                                                 int ttl, const char *comment);
-void update_server_ttl(struct server_record *servrec, int ttl);
-void expire_servers(struct work_record *work, time_t t);
-void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
-               const char *local_master_browser_name, const char *description);
-void write_browse_list(time_t t, bool force_write);
-
-/* The following definitions come from nmbd/nmbd_subnetdb.c  */
-
-void close_subnet(struct subnet_record *subrec);
-struct subnet_record *make_normal_subnet(const struct interface *iface);
-bool create_subnets(void);
-bool we_are_a_wins_client(void);
-struct subnet_record *get_next_subnet_maybe_unicast(struct subnet_record *subrec);
-struct subnet_record *get_next_subnet_maybe_unicast_or_wins_server(struct subnet_record *subrec);
-
-/* The following definitions come from nmbd/nmbd_synclists.c  */
-
-void sync_browse_lists(struct work_record *work,
-                      char *name, int nm_type, 
-                      struct in_addr ip, bool local, bool servers);
-void sync_check_completion(void);
-
-/* The following definitions come from nmbd/nmbd_winsproxy.c  */
-
-void make_wins_proxy_name_query_request( struct subnet_record *subrec, 
-                                         struct packet_struct *incoming_packet,
-                                         struct nmb_name *question_name);
-
-/* The following definitions come from nmbd/nmbd_winsserver.c  */
-
-struct name_record *find_name_on_wins_subnet(const struct nmb_name *nmbname, bool self_only);
-bool wins_store_changed_namerec(const struct name_record *namerec);
-bool add_name_to_wins_subnet(const struct name_record *namerec);
-bool remove_name_from_wins_namelist(struct name_record *namerec);
-void dump_wins_subnet_namelist(XFILE *fp);
-bool packet_is_for_wins_server(struct packet_struct *packet);
-bool initialise_wins(void);
-void wins_process_name_refresh_request( struct subnet_record *subrec,
-                                        struct packet_struct *p );
-void wins_process_name_registration_request(struct subnet_record *subrec,
-                                            struct packet_struct *p);
-void wins_process_multihomed_name_registration_request( struct subnet_record *subrec,
-                                                        struct packet_struct *p);
-void fetch_all_active_wins_1b_names(void);
-void send_wins_name_query_response(int rcode, struct packet_struct *p, 
-                                          struct name_record *namerec);
-void wins_process_name_query_request(struct subnet_record *subrec, 
-                                     struct packet_struct *p);
-void wins_process_name_release_request(struct subnet_record *subrec,
-                                       struct packet_struct *p);
-void initiate_wins_processing(time_t t);
-void wins_write_name_record(struct name_record *namerec, XFILE *fp);
-void wins_write_database(time_t t, bool background);
-void nmbd_wins_new_entry(struct messaging_context *msg,
-                                       void *private_data,
-                                       uint32_t msg_type,
-                                       struct server_id server_id,
-                                       DATA_BLOB *data);
-
-/* The following definitions come from nmbd/nmbd_workgroupdb.c  */
-
-struct work_record *find_workgroup_on_subnet(struct subnet_record *subrec, 
-                                             const char *name);
-struct work_record *create_workgroup_on_subnet(struct subnet_record *subrec,
-                                               const char *name, int ttl);
-void update_workgroup_ttl(struct work_record *work, int ttl);
-void initiate_myworkgroup_startup(struct subnet_record *subrec, struct work_record *work);
-void dump_workgroups(bool force_write);
-void expire_workgroups_and_servers(time_t t);
-
 /* The following definitions come from param/loadparm.c  */
 
 char *lp_smb_ports(void);
@@ -3653,7 +3290,7 @@ bool lp_winbind_normalize_names(void);
 bool lp_winbind_rpc_only(void);
 bool lp_create_krb5_conf(void);
 const char *lp_idmap_backend(void);
-char *lp_idmap_alloc_backend(void);
+bool lp_idmap_read_only(void);
 int lp_idmap_cache_time(void);
 int lp_idmap_negative_cache_time(void);
 int lp_keepalive(void);
@@ -3703,7 +3340,6 @@ bool _lp_writeraw(void);
 bool lp_null_passwords(void);
 bool lp_obey_pam_restrictions(void);
 bool lp_encrypted_passwords(void);
-bool lp_update_encrypted(void);
 int lp_client_schannel(void);
 int lp_server_schannel(void);
 bool lp_syslog_only(void);
@@ -3995,13 +3631,6 @@ int load_usershare_shares(void);
 void gfree_loadparm(void);
 void lp_set_in_client(bool b);
 bool lp_is_in_client(void);
-bool lp_load_ex(const char *pszFname,
-               bool global_only,
-               bool save_defaults,
-               bool add_ipc,
-               bool initialize_globals,
-               bool allow_include_registry,
-               bool allow_registry_shares);
 bool lp_load(const char *pszFname,
             bool global_only,
             bool save_defaults,
@@ -4396,7 +4025,8 @@ bool lookup_wellknown_name(TALLOC_CTX *mem_ctx, const char *name,
 
 /* The following definitions come from printing/load.c  */
 
-void load_printers(void);
+void load_printers(struct tevent_context *ev,
+                  struct messaging_context *msg_ctx);
 
 /* The following definitions come from printing/lpq_parse.c  */
 
@@ -4432,21 +4062,43 @@ void notify_job_total_pages(struct tevent_context *ev,
                            struct messaging_context *msg_ctx,
                            const char *sharename, uint32 jobid,
                            uint32 pages);
-void notify_job_username(const char *sharename, uint32 jobid, char *name);
-void notify_job_name(const char *sharename, uint32 jobid, char *name);
-void notify_job_submitted(const char *sharename, uint32 jobid,
+void notify_job_username(struct tevent_context *ev,
+                        struct messaging_context *msg_ctx,
+                        const char *sharename, uint32 jobid, char *name);
+void notify_job_name(struct tevent_context *ev,
+                    struct messaging_context *msg_ctx,
+                    const char *sharename, uint32 jobid, char *name);
+void notify_job_submitted(struct tevent_context *ev,
+                         struct messaging_context *msg_ctx,
+                         const char *sharename, uint32 jobid,
                          time_t submitted);
-void notify_printer_driver(int snum, const char *driver_name);
-void notify_printer_comment(int snum, const char *comment);
-void notify_printer_sharename(int snum, const char *share_name);
-void notify_printer_printername(int snum, const char *printername);
-void notify_printer_port(int snum, const char *port_name);
-void notify_printer_location(int snum, const char *location);
-void notify_printer_byname( const char *printername, uint32 change, const char *value );
+void notify_printer_driver(struct tevent_context *ev,
+                          struct messaging_context *msg_ctx,
+                          int snum, const char *driver_name);
+void notify_printer_comment(struct tevent_context *ev,
+                           struct messaging_context *msg_ctx,
+                           int snum, const char *comment);
+void notify_printer_sharename(struct tevent_context *ev,
+                             struct messaging_context *msg_ctx,
+                             int snum, const char *share_name);
+void notify_printer_printername(struct tevent_context *ev,
+                               struct messaging_context *msg_ctx,
+                               int snum, const char *printername);
+void notify_printer_port(struct tevent_context *ev,
+                        struct messaging_context *msg_ctx,
+                        int snum, const char *port_name);
+void notify_printer_location(struct tevent_context *ev,
+                            struct messaging_context *msg_ctx,
+                            int snum, const char *location);
+void notify_printer_byname(struct tevent_context *ev,
+                          struct messaging_context *msg_ctx,
+                          const char *printername, uint32 change,
+                          const char *value);
 
 /* The following definitions come from printing/pcap.c  */
 
-void pcap_cache_reload(void);
+void pcap_cache_reload(struct tevent_context *ev,
+                      struct messaging_context *msg_ctx);
 bool pcap_printername_ok(const char *printername);
 
 /* The following definitions come from printing/printing.c  */
@@ -4510,12 +4162,13 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
                               struct rpc_pipe_client **presult);
 struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
                                              const struct ndr_syntax_id *syntax,
-                                             const char *client_address,
+                                             struct client_address *client_id,
                                              struct auth_serversupplied_info *server_info,
                                              struct messaging_context *msg_ctx);
 NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx,
                                const struct ndr_syntax_id *abstract_syntax,
                                struct auth_serversupplied_info *serversupplied_info,
+                               struct client_address *client_id,
                                struct messaging_context *msg_ctx,
                                struct rpc_pipe_client **presult);
 NTSTATUS rpc_connect_spoolss_pipe(connection_struct *conn,
@@ -4587,10 +4240,6 @@ NTSTATUS cli_rpc_pipe_open_spnego_krb5(struct cli_state *cli,
 NTSTATUS cli_get_session_key(TALLOC_CTX *mem_ctx,
                             struct rpc_pipe_client *cli,
                             DATA_BLOB *session_key);
-NTSTATUS rpc_pipe_open_local(TALLOC_CTX *mem_ctx,
-                            struct rpc_cli_smbd_conn *conn,
-                            const struct ndr_syntax_id *syntax,
-                            struct rpc_pipe_client **presult);
 
 /* The following definitions come from rpc_client/rpc_transport_np.c  */
 
@@ -4642,27 +4291,6 @@ struct cli_state *rpc_pipe_smbd_smb_conn(struct rpc_pipe_client *p);
 NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
                                 struct rpc_cli_transport **presult);
 
-/* The following definitions come from rpc_client/init_lsa.c  */
-
-void init_lsa_String(struct lsa_String *name, const char *s);
-void init_lsa_StringLarge(struct lsa_StringLarge *name, const char *s);
-void init_lsa_AsciiString(struct lsa_AsciiString *name, const char *s);
-void init_lsa_AsciiStringLarge(struct lsa_AsciiStringLarge *name, const char *s);
-
-/* The following definitions come from rpc_client/ndr.c  */
-
-struct tevent_req *cli_do_rpc_ndr_send(TALLOC_CTX *mem_ctx,
-                                      struct tevent_context *ev,
-                                      struct rpc_pipe_client *cli,
-                                      const struct ndr_interface_table *table,
-                                      uint32_t opnum,
-                                      void *r);
-NTSTATUS cli_do_rpc_ndr_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
-NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
-                       TALLOC_CTX *mem_ctx,
-                       const struct ndr_interface_table *table,
-                       uint32 opnum, void *r);
-
 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
 
 /* The following definitions come from rpc_server/rpc_handles.c  */
@@ -4719,10 +4347,6 @@ NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
                                    const struct ndr_syntax_id *interface,
                                    const struct api_struct *cmds, int size);
 bool is_known_pipename(const char *cli_filename, struct ndr_syntax_id *syntax);
-bool api_pipe_bind_req(struct pipes_struct *p, struct ncacn_packet *pkt);
-bool api_pipe_alter_context(struct pipes_struct *p, struct ncacn_packet *pkt);
-void free_pipe_rpc_context( PIPE_RPC_FNS *list );
-bool api_pipe_request(struct pipes_struct *p, struct ncacn_packet *pkt);
 
 /* The following definitions come from rpc_server/srv_pipe_hnd.c  */
 
@@ -4735,6 +4359,7 @@ struct tsocket_address;
 NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
                 const struct tsocket_address *local_address,
                 const struct tsocket_address *remote_address,
+                struct client_address *client_id,
                 struct auth_serversupplied_info *server_info,
                 struct messaging_context *msg_ctx,
                 struct fake_file_handle **phandle);
@@ -4756,7 +4381,7 @@ void do_drv_upgrade_printer(struct messaging_context *msg,
                            uint32_t msg_type,
                            struct server_id server_id,
                            DATA_BLOB *data);
-void update_monitored_printq_cache( void );
+void update_monitored_printq_cache(struct messaging_context *msg_ctx);
 void reset_all_printerdata(struct messaging_context *msg,
                           void *private_data,
                           uint32_t msg_type,
@@ -5561,7 +5186,7 @@ struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fna
 void smbd_setup_sig_term_handler(void);
 void smbd_setup_sig_hup_handler(struct tevent_context *ev,
                                struct messaging_context *msg_ctx);
-bool srv_send_smb(int fd, char *buffer,
+bool srv_send_smb(struct smbd_server_connection *sconn, char *buffer,
                  bool no_signing, uint32_t seqnum,
                  bool do_encrypt,
                  struct smb_perfcount_data *pcd);
@@ -5597,8 +5222,7 @@ void construct_reply_common_req(struct smb_request *req, char *outbuf);
 size_t req_wct_ofs(struct smb_request *req);
 void chain_reply(struct smb_request *req);
 bool req_is_in_chain(struct smb_request *req);
-void check_reload(time_t t);
-void smbd_process(void);
+void smbd_process(struct smbd_server_connection *sconn);
 
 /* The following definitions come from smbd/quotas.c  */
 
@@ -5766,12 +5390,12 @@ void server_messaging_context_free(void);
 /* The following definitions come from smbd/server.c  */
 
 int smbd_server_fd(void);
-int get_client_fd(void);
 struct event_context *smbd_event_context(void);
 struct messaging_context *smbd_messaging_context(void);
 struct memcache *smbd_memcache(void);
 void reload_printers(struct messaging_context *msg_ctx);
-bool reload_services(struct messaging_context *msg_ctx, bool test);
+bool reload_services(struct messaging_context *msg_ctx, int smb_sock,
+                    bool test);
 void exit_server(const char *const explanation);
 void exit_server_cleanly(const char *const explanation);
 void exit_server_fault(void);
@@ -5797,7 +5421,7 @@ void close_cnum(connection_struct *conn, uint16 vuid);
 /* The following definitions come from smbd/session.c  */
 
 bool session_init(void);
-bool session_claim(struct server_id pid, user_struct *vuser);
+bool session_claim(struct smbd_server_connection *sconn, user_struct *vuser);
 void session_yield(user_struct *vuser);
 int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list);
 
@@ -5982,61 +5606,6 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp);
 char *stdin_new_passwd( void);
 char *get_pass( const char *prompt, bool stdin_get);
 
-/* The following definitions come from winbindd/idmap.c  */
-
-bool idmap_is_offline(void);
-bool idmap_is_online(void);
-NTSTATUS smb_register_idmap(int version, const char *name,
-                           struct idmap_methods *methods);
-NTSTATUS smb_register_idmap_alloc(int version, const char *name,
-                                 struct idmap_alloc_methods *methods);
-void idmap_close(void);
-NTSTATUS idmap_init_cache(void);
-NTSTATUS idmap_allocate_uid(struct unixid *id);
-NTSTATUS idmap_allocate_gid(struct unixid *id);
-NTSTATUS idmap_set_uid_hwm(struct unixid *id);
-NTSTATUS idmap_set_gid_hwm(struct unixid *id);
-NTSTATUS idmap_backends_unixid_to_sid(const char *domname,
-                                     struct id_map *id);
-NTSTATUS idmap_backends_sid_to_unixid(const char *domname,
-                                     struct id_map *id);
-NTSTATUS idmap_new_mapping(const struct dom_sid *psid, enum id_type type,
-                          struct unixid *pxid);
-NTSTATUS idmap_set_mapping(const struct id_map *map);
-NTSTATUS idmap_remove_mapping(const struct id_map *map);
-
-/* The following definitions come from winbindd/idmap_cache.c  */
-
-bool idmap_cache_find_sid2uid(const struct dom_sid *sid, uid_t *puid,
-                             bool *expired);
-bool idmap_cache_find_uid2sid(uid_t uid, struct dom_sid *sid, bool *expired);
-void idmap_cache_set_sid2uid(const struct dom_sid *sid, uid_t uid);
-bool idmap_cache_find_sid2gid(const struct dom_sid *sid, gid_t *pgid,
-                             bool *expired);
-bool idmap_cache_find_gid2sid(gid_t gid, struct dom_sid *sid, bool *expired);
-void idmap_cache_set_sid2gid(const struct dom_sid *sid, gid_t gid);
-
-
-/* The following definitions come from winbindd/idmap_nss.c  */
-
-NTSTATUS idmap_nss_init(void);
-
-/* The following definitions come from winbindd/idmap_passdb.c  */
-
-NTSTATUS idmap_passdb_init(void);
-
-/* The following definitions come from winbindd/idmap_tdb.c  */
-
-NTSTATUS idmap_alloc_tdb_init(void);
-NTSTATUS idmap_tdb_init(void);
-
-/* The following definitions come from winbindd/idmap_util.c  */
-
-NTSTATUS idmap_uid_to_sid(const char *domname, struct dom_sid *sid, uid_t uid);
-NTSTATUS idmap_gid_to_sid(const char *domname, struct dom_sid *sid, gid_t gid);
-NTSTATUS idmap_sid_to_uid(const char *dom_name, struct dom_sid *sid, uid_t *uid);
-NTSTATUS idmap_sid_to_gid(const char *domname, struct dom_sid *sid, gid_t *gid);
-
 /* The following definitions come from winbindd/nss_info.c  */