s3:smbd: add a nfs backend for sysquotas.
[amitay/samba.git] / source3 / include / proto.h
index 3b7b6d58a5320da6c0fae5f18b364275f3e10213..67718a954a424cef47e37e95383ddbdbf1ea152b 100644 (file)
@@ -57,8 +57,6 @@ NTSTATUS auth_netlogond_init(void);
 NTSTATUS auth_ntlmssp_steal_server_info(TALLOC_CTX *mem_ctx,
                                struct auth_ntlmssp_state *auth_ntlmssp_state,
                                struct auth_serversupplied_info **server_info);
-void auth_ntlmssp_want_sign(struct auth_ntlmssp_state *auth_ntlmssp_state);
-void auth_ntlmssp_want_seal(struct auth_ntlmssp_state *auth_ntlmssp_state);
 NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state);
 
 
@@ -68,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  */
@@ -81,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, 
@@ -144,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,
@@ -162,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,
@@ -170,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  */
@@ -182,6 +186,10 @@ NTSTATUS auth_winbind_init(void);
 
 /* The following definitions come from auth/server_info.c  */
 
+struct netr_SamInfo2;
+struct netr_SamInfo3;
+struct netr_SamInfo6;
+
 struct auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx);
 NTSTATUS serverinfo_to_SamInfo2(struct auth_serversupplied_info *server_info,
                                uint8_t *pipe_session_key,
@@ -213,10 +221,9 @@ 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_accountcheck(const char *user, const char *rhost);
 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);
 bool smb_pam_claim_session(char *user, char *tty, char *rhost);
 bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
 
@@ -224,7 +231,7 @@ bool smb_pam_close_session(char *in_user, char *tty, char *rhost);
 
 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);
+                   bool run_cracker);
 
 /* The following definitions come from auth/token_util.c  */
 
@@ -343,7 +350,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  */
 
@@ -657,10 +663,6 @@ pid_t pidfile_pid(const char *name);
 void pidfile_create(const char *program_name);
 void pidfile_unlink(void);
 
-/* The following definitions come from lib/popt_common.c  */
-
-void popt_common_set_auth_info(struct user_auth_info *auth_info);
-
 /* The following definitions come from lib/privileges.c  */
 
 bool get_privileges_for_sids(SE_PRIV *privileges, struct dom_sid *slist, int scount);
@@ -966,6 +968,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 );
@@ -1094,6 +1103,7 @@ void round_timespec(enum timestamp_set_resolution res, struct timespec *ts);
 void put_long_date_timespec(enum timestamp_set_resolution res, char *p, struct timespec ts);
 void put_long_date(char *p, time_t t);
 void dos_filetime_timespec(struct timespec *tsp);
+time_t make_unix_date(const void *date_ptr, int zone_offset);
 time_t make_unix_date2(const void *date_ptr, int zone_offset);
 time_t make_unix_date3(const void *date_ptr, int zone_offset);
 time_t srv_make_unix_date(const void *date_ptr);
@@ -1110,12 +1120,6 @@ int timespec_compare(const struct timespec *ts1, const struct timespec *ts2);
 void round_timespec_to_sec(struct timespec *ts);
 void round_timespec_to_usec(struct timespec *ts);
 struct timespec interpret_long_date(const char *p);
-void cli_put_dos_date(struct cli_state *cli, char *buf, int offset, time_t unixdate);
-void cli_put_dos_date2(struct cli_state *cli, char *buf, int offset, time_t unixdate);
-void cli_put_dos_date3(struct cli_state *cli, char *buf, int offset, time_t unixdate);
-time_t cli_make_unix_date(struct cli_state *cli, const void *date_ptr);
-time_t cli_make_unix_date2(struct cli_state *cli, const void *date_ptr);
-time_t cli_make_unix_date3(struct cli_state *cli, const void *date_ptr);
 void TimeInit(void);
 void get_process_uptime(struct timeval *ret_time);
 void get_startup_time(struct timeval *ret_time);
@@ -1339,7 +1343,7 @@ bool pull_reg_multi_sz(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, const char **
 
 void se_map_generic(uint32 *access_mask, const struct generic_mapping *mapping);
 void security_acl_map_generic(struct security_acl *sa, const struct generic_mapping *mapping);
-void se_map_standard(uint32 *access_mask, struct standard_mapping *mapping);
+void se_map_standard(uint32 *access_mask, const struct standard_mapping *mapping);
 NTSTATUS se_access_check(const struct security_descriptor *sd, const NT_USER_TOKEN *token,
                     uint32 acc_desired, uint32 *acc_granted);
 
@@ -1449,8 +1453,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,
@@ -1729,247 +1731,6 @@ void wins_srv_tags_free(char **list);
 struct in_addr wins_srv_ip_tag(const char *tag, struct in_addr src_ip);
 unsigned wins_srv_count_tag(const char *tag);
 
-/* The following definitions come from libads/ads_struct.c  */
-
-char *ads_build_path(const char *realm, const char *sep, const char *field, int reverse);
-char *ads_build_dn(const char *realm);
-char *ads_build_domain(const char *dn);
-ADS_STRUCT *ads_init(const char *realm, 
-                    const char *workgroup,
-                    const char *ldap_server);
-bool ads_set_sasl_wrap_flags(ADS_STRUCT *ads, int flags);
-void ads_destroy(ADS_STRUCT **ads);
-
-const char *ads_get_ldap_server_name(ADS_STRUCT *ads);
-
-/* The following definitions come from libads/authdata.c  */
-
-NTSTATUS kerberos_return_pac(TALLOC_CTX *mem_ctx,
-                            const char *name,
-                            const char *pass,
-                            time_t time_offset,
-                            time_t *expire_time,
-                            time_t *renew_till_time,
-                            const char *cache_name,
-                            bool request_pac,
-                            bool add_netbios_addr,
-                            time_t renewable_time,
-                            const char *impersonate_princ_s,
-                            struct PAC_LOGON_INFO **logon_info);
-
-/* The following definitions come from libads/disp_sec.c  */
-
-void ads_disp_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct security_descriptor *sd);
-
-/* The following definitions come from libads/kerberos.c  */
-
-int kerberos_kinit_password_ext(const char *principal,
-                               const char *password,
-                               int time_offset,
-                               time_t *expire_time,
-                               time_t *renew_till_time,
-                               const char *cache_name,
-                               bool request_pac,
-                               bool add_netbios_addr,
-                               time_t renewable_time,
-                               NTSTATUS *ntstatus);
-int ads_kinit_password(ADS_STRUCT *ads);
-int ads_kdestroy(const char *cc_name);
-char* kerberos_standard_des_salt( void );
-bool kerberos_secrets_store_des_salt( const char* salt );
-char* kerberos_secrets_fetch_des_salt( void );
-char *kerberos_get_default_realm_from_ccache( void );
-char *kerberos_get_realm_from_hostname(const char *hostname);
-
-bool kerberos_secrets_store_salting_principal(const char *service,
-                                             int enctype,
-                                             const char *principal);
-int kerberos_kinit_password(const char *principal,
-                           const char *password,
-                           int time_offset,
-                           const char *cache_name);
-bool create_local_private_krb5_conf_for_domain(const char *realm,
-                                               const char *domain,
-                                               const char *sitename,
-                                               struct sockaddr_storage *pss,
-                                               const char *kdc_name);
-
-/* The following definitions come from libads/kerberos_keytab.c  */
-
-int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc);
-int ads_keytab_flush(ADS_STRUCT *ads);
-int ads_keytab_create_default(ADS_STRUCT *ads);
-int ads_keytab_list(const char *keytab_name);
-
-/* The following definitions come from libads/kerberos_verify.c  */
-
-NTSTATUS ads_verify_ticket(TALLOC_CTX *mem_ctx,
-                          const char *realm,
-                          time_t time_offset,
-                          const DATA_BLOB *ticket,
-                          char **principal,
-                          struct PAC_LOGON_INFO **logon_info,
-                          DATA_BLOB *ap_rep,
-                          DATA_BLOB *session_key,
-                          bool use_replay_cache);
-
-/* The following definitions come from libads/krb5_errs.c  */
-
-
-/* The following definitions come from libads/krb5_setpw.c  */
-
-ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ, 
-                                const char *newpw, int time_offset);
-ADS_STATUS kerberos_set_password(const char *kpasswd_server, 
-                                const char *auth_principal, const char *auth_password,
-                                const char *target_principal, const char *new_password,
-                                int time_offset);
-ADS_STATUS ads_set_machine_password(ADS_STRUCT *ads,
-                                   const char *machine_account,
-                                   const char *password);
-
-/* The following definitions come from libads/ldap.c  */
-
-bool ads_sitename_match(ADS_STRUCT *ads);
-bool ads_closest_dc(ADS_STRUCT *ads);
-ADS_STATUS ads_connect(ADS_STRUCT *ads);
-ADS_STATUS ads_connect_user_creds(ADS_STRUCT *ads);
-ADS_STATUS ads_connect_gc(ADS_STRUCT *ads);
-void ads_disconnect(ADS_STRUCT *ads);
-ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
-                               int scope, const char *expr, const char **attrs,
-                               bool (*fn)(ADS_STRUCT *, char *, void **, void *), 
-                               void *data_area);
-char *ads_parent_dn(const char *dn);
-ADS_MODLIST ads_init_mods(TALLOC_CTX *ctx);
-ADS_STATUS ads_mod_str(TALLOC_CTX *ctx, ADS_MODLIST *mods, 
-                      const char *name, const char *val);
-ADS_STATUS ads_mod_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
-                          const char *name, const char **vals);
-ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods);
-ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods);
-ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn);
-char *ads_ou_string(ADS_STRUCT *ads, const char *org_unit);
-char *ads_default_ou_string(ADS_STRUCT *ads, const char *wknguid);
-ADS_STATUS ads_add_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
-                               const char *name, const char **vals);
-uint32 ads_get_kvno(ADS_STRUCT *ads, const char *account_name);
-uint32_t ads_get_machine_kvno(ADS_STRUCT *ads, const char *machine_name);
-ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machine_name);
-ADS_STATUS ads_add_service_principal_name(ADS_STRUCT *ads, const char *machine_name, 
-                                          const char *my_fqdn, const char *spn);
-ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads, const char *machine_name, 
-                                   const char *org_unit);
-ADS_STATUS ads_move_machine_acct(ADS_STRUCT *ads, const char *machine_name, 
-                                 const char *org_unit, bool *moved);
-int ads_count_replies(ADS_STRUCT *ads, void *res);
-ADS_STATUS ads_USN(ADS_STRUCT *ads, uint32 *usn);
-ADS_STATUS ads_current_time(ADS_STRUCT *ads);
-ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32 *val);
-ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, struct dom_sid *sid);
-ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_name);
-ADS_STATUS ads_site_dn_for_machine(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char *computer_name, const char **site_dn);
-ADS_STATUS ads_upn_suffixes(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char ***suffixes, size_t *num_suffixes);
-ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
-                               TALLOC_CTX *mem_ctx,
-                               char ***ous,
-                               size_t *num_ous);
-ADS_STATUS ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
-                                       const char *extended_dn,
-                                       enum ads_extended_dn_flags flags,
-                                       struct dom_sid *sid);
-char* ads_get_dnshostname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
-char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
-char* ads_get_samaccountname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
-ADS_STATUS ads_join_realm(ADS_STRUCT *ads, const char *machine_name,
-                       uint32 account_type, const char *org_unit);
-ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname);
-ADS_STATUS ads_find_samaccount(ADS_STRUCT *ads,
-                              TALLOC_CTX *mem_ctx,
-                              const char *samaccountname,
-                              uint32 *uac_ret,
-                              const char **dn_ret);
-ADS_STATUS ads_config_path(ADS_STRUCT *ads, 
-                          TALLOC_CTX *mem_ctx, 
-                          char **config_path);
-const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads, 
-                                               const char *config_path, 
-                                               TALLOC_CTX *mem_ctx, 
-                                               const struct GUID *rights_guid);
-ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
-                          ADS_STRUCT *ads,
-                          const char **account_ou);
-
-/* The following definitions come from libads/ldap_printer.c  */
-
-ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn,
-                                TALLOC_CTX *ctx, const ADS_MODLIST *mods);
-ADS_STATUS ads_add_printer_entry(ADS_STRUCT *ads, char *prt_dn,
-                                       TALLOC_CTX *ctx, ADS_MODLIST *mods);
-WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli, 
-                                         TALLOC_CTX *mem_ctx,
-                                         ADS_MODLIST *mods,
-                                         const char *printer);
-bool get_local_printer_publishing_data(TALLOC_CTX *mem_ctx,
-                                      ADS_MODLIST *mods,
-                                      NT_PRINTER_DATA *data);
-
-/* The following definitions come from libads/ldap_user.c  */
-
-ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user, 
-                            const char *container, const char *fullname);
-ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group, 
-                             const char *container, const char *comment);
-
-/* The following definitions come from libads/ldap_utils.c  */
-
-ADS_STATUS ads_ranged_search(ADS_STRUCT *ads, 
-                            TALLOC_CTX *mem_ctx,
-                            int scope,
-                            const char *base,
-                            const char *filter,
-                            void *args,
-                            const char *range_attr,
-                            char ***strings,
-                            size_t *num_strings);
-ADS_STATUS ads_ranged_search_internal(ADS_STRUCT *ads, 
-                                     TALLOC_CTX *mem_ctx,
-                                     int scope,
-                                     const char *base,
-                                     const char *filter,
-                                     const char **attrs,
-                                     void *args,
-                                     const char *range_attr,
-                                     char ***strings,
-                                     size_t *num_strings,
-                                     uint32 *first_usn,
-                                     int *num_retries,
-                                     bool *more_values);
-
-/* The following definitions come from libads/ndr.c  */
-
-void ndr_print_ads_auth_flags(struct ndr_print *ndr, const char *name, uint32_t r);
-void ndr_print_ads_struct(struct ndr_print *ndr, const char *name, const struct ads_struct *r);
-
-/* The following definitions come from libads/sasl.c  */
-
-ADS_STATUS ads_sasl_bind(ADS_STRUCT *ads);
-
-/* The following definitions come from libads/sasl_wrapping.c  */
-
-ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads,
-                                  const struct ads_saslwrap_ops *ops,
-                                  void *private_data);
-ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads,
-                                  const struct ads_saslwrap_ops *ops,
-                                  void *private_data);
-
-/* The following definitions come from libads/util.c  */
-
-ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_principal);
-ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
-                                      char **returned_principal);
-
 /* The following definitions come from librpc/ndr/util.c  */
 
 enum ndr_err_code ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r);
@@ -2120,7 +1881,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,
@@ -2315,6 +2075,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,
@@ -2579,12 +2341,25 @@ 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 *, file_info *, const char *, void *), void *state);
-int cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
-                void (*fn)(const char *, file_info *, const char *, void *), void *state);
-int cli_list(struct cli_state *cli,const char *Mask,uint16 attribute,
-            void (*fn)(const char *, 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);
 
 /* The following definitions come from libsmb/climessage.c  */
 
@@ -2725,6 +2500,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;
@@ -2895,13 +2677,13 @@ size_t clistr_pull_fn(const char *function,
 size_t clistr_pull_talloc_fn(const char *function,
                                unsigned int line,
                                TALLOC_CTX *ctx,
-                               const char *inbuf,
+                               const char *base,
+                               uint16_t flags2,
                                char **pp_dest,
                                const void *src,
                                int src_len,
                                int flags);
 size_t clistr_align_out(struct cli_state *cli, const void *p, int flags);
-size_t clistr_align_in(struct cli_state *cli, const void *p, int flags);
 
 /* The following definitions come from libsmb/clitrans.c  */
 
@@ -2931,6 +2713,7 @@ struct tevent_req *cli_trans_send(
        uint8_t *param, uint32_t num_param, uint32_t max_param,
        uint8_t *data, uint32_t num_data, uint32_t max_data);
 NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+                       uint16_t *recv_flags2,
                        uint16_t **setup, uint8_t min_setup,
                        uint8_t *num_setup,
                        uint8_t **param, uint32_t min_param,
@@ -2944,6 +2727,7 @@ NTSTATUS cli_trans(TALLOC_CTX *mem_ctx, struct cli_state *cli,
                   uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
                   uint8_t *param, uint32_t num_param, uint32_t max_param,
                   uint8_t *data, uint32_t num_data, uint32_t max_data,
+                  uint16_t *recv_flags2,
                   uint16_t **rsetup, uint8_t min_rsetup, uint8_t *num_rsetup,
                   uint8_t **rparam, uint32_t min_rparam, uint32_t *num_rparam,
                   uint8_t **rdata, uint32_t min_rdata, uint32_t *num_rdata);
@@ -2975,6 +2759,8 @@ NTSTATUS dcerpc_pull_auth_trailer(struct ncacn_packet *pkt,
 
 /* The following definitions come from libsmb/dsgetdcname.c  */
 
+struct netr_DsRGetDCNameInfo;
+
 void debug_dsdcinfo_flags(int lvl, uint32_t flags);
 NTSTATUS dsgetdcname(TALLOC_CTX *mem_ctx,
                     struct messaging_context *msg_ctx,
@@ -3894,7 +3680,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);
@@ -3944,7 +3730,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);
@@ -4236,13 +4021,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,
@@ -4605,53 +4383,6 @@ NTSTATUS pdb_wbc_sam_init(void);
 bool init_sam_from_buffer_v2(struct samu *sampass, uint8_t *buf, uint32_t buflen);
 NTSTATUS pdb_tdbsam_init(void);
 
-/* The following definitions come from passdb/secrets.c  */
-
-bool secrets_init(void);
-struct db_context *secrets_db_ctx(void);
-void secrets_shutdown(void);
-void *secrets_fetch(const char *key, size_t *size);
-bool secrets_store(const char *key, const void *data, size_t size);
-bool secrets_delete(const char *key);
-bool secrets_store_domain_sid(const char *domain, const struct dom_sid  *sid);
-bool secrets_fetch_domain_sid(const char *domain, struct dom_sid  *sid);
-bool secrets_store_domain_guid(const char *domain, struct GUID *guid);
-bool secrets_fetch_domain_guid(const char *domain, struct GUID *guid);
-void *secrets_get_trust_account_lock(TALLOC_CTX *mem_ctx, const char *domain);
-enum netr_SchannelType get_default_sec_channel(void);
-bool secrets_fetch_trust_account_password_legacy(const char *domain,
-                                                uint8 ret_pwd[16],
-                                                time_t *pass_last_set_time,
-                                                enum netr_SchannelType *channel);
-bool secrets_fetch_trust_account_password(const char *domain, uint8 ret_pwd[16],
-                                         time_t *pass_last_set_time,
-                                         enum netr_SchannelType *channel);
-bool secrets_fetch_trusted_domain_password(const char *domain, char** pwd,
-                                           struct dom_sid  *sid, time_t *pass_last_set_time);
-bool secrets_store_trusted_domain_password(const char* domain, const char* pwd,
-                                           const struct dom_sid  *sid);
-bool secrets_delete_machine_password(const char *domain);
-bool secrets_delete_machine_password_ex(const char *domain);
-bool secrets_delete_domain_sid(const char *domain);
-bool secrets_store_machine_password(const char *pass, const char *domain, enum netr_SchannelType sec_channel);
-char *secrets_fetch_prev_machine_password(const char *domain);
-char *secrets_fetch_machine_password(const char *domain,
-                                    time_t *pass_last_set_time,
-                                    enum netr_SchannelType *channel);
-bool trusted_domain_password_delete(const char *domain);
-bool secrets_store_ldap_pw(const char* dn, char* pw);
-bool fetch_ldap_pw(char **dn, char** pw);
-NTSTATUS secrets_trusted_domains(TALLOC_CTX *mem_ctx, uint32 *num_domains,
-                                struct trustdom_info ***domains);
-bool secrets_store_afs_keyfile(const char *cell, const struct afs_keyfile *keyfile);
-bool secrets_fetch_afs_key(const char *cell, struct afs_key *result);
-void secrets_fetch_ipc_userpass(char **username, char **domain, char **password);
-bool secrets_store_generic(const char *owner, const char *key, const char *secret);
-char *secrets_fetch_generic(const char *owner, const char *key);
-bool secrets_delete_generic(const char *owner, const char *key);
-bool secrets_store_local_schannel_key(uint8_t schannel_key[16]);
-bool secrets_fetch_local_schannel_key(uint8_t schannel_key[16]);
-
 /* The following definitions come from passdb/util_builtin.c  */
 
 bool lookup_builtin_rid(TALLOC_CTX *mem_ctx, uint32 rid, const char **name);
@@ -4684,7 +4415,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  */
 
@@ -4698,126 +4430,76 @@ uint32_t print_parse_jobid(const char *fname);
 int print_queue_snum(const char *qname);
 void print_notify_send_messages(struct messaging_context *msg_ctx,
                                unsigned int timeout);
-void notify_printer_status_byname(const char *sharename, uint32 status);
-void notify_printer_status(int snum, uint32 status);
-void notify_job_status_byname(const char *sharename, uint32 jobid, uint32 status,
+void notify_printer_status_byname(struct tevent_context *ev,
+                                 struct messaging_context *msg_ctx,
+                                 const char *sharename, uint32 status);
+void notify_printer_status(struct tevent_context *ev,
+                          struct messaging_context *msg_ctx,
+                          int snum, uint32 status);
+void notify_job_status_byname(struct tevent_context *ev,
+                             struct messaging_context *msg_ctx,
+                             const char *sharename, uint32 jobid,
+                             uint32 status,
                              uint32 flags);
-void notify_job_status(const char *sharename, uint32 jobid, uint32 status);
-void notify_job_total_bytes(const char *sharename, uint32 jobid,
+void notify_job_status(struct tevent_context *ev,
+                      struct messaging_context *msg_ctx,
+                      const char *sharename, uint32 jobid, uint32 status);
+void notify_job_total_bytes(struct tevent_context *ev,
+                           struct messaging_context *msg_ctx,
+                           const char *sharename, uint32 jobid,
                            uint32 size);
-void notify_job_total_pages(const char *sharename, uint32 jobid,
+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 );
-
-/* The following definitions come from printing/nt_printing.c  */
-
-bool nt_printing_init(struct messaging_context *msg_ctx);
-uint32 update_c_setprinter(bool initialize);
-uint32 get_c_setprinter(void);
-int get_builtin_ntforms(nt_forms_struct **list);
-bool get_a_builtin_ntform_by_string(const char *form_name, nt_forms_struct *form);
-int get_ntforms(nt_forms_struct **list);
-int write_ntforms(nt_forms_struct **list, int number);
-bool add_a_form(nt_forms_struct **list, struct spoolss_AddFormInfo1 *form, int *count);
-bool delete_a_form(nt_forms_struct **list, const char *del_name, int *count, WERROR *ret);
-void update_a_form(nt_forms_struct **list, struct spoolss_AddFormInfo1 *form, int count);
-int pack_devicemode(struct spoolss_DeviceMode *devmode, uint8 *buf, int buflen);
-int unpack_devicemode(TALLOC_CTX *mem_ctx,
-                     const uint8 *buf, int buflen,
-                     struct spoolss_DeviceMode **devmode);
-uint32 del_a_printer(const char *sharename);
-int add_new_printer_key( NT_PRINTER_DATA *data, const char *name );
-int delete_printer_key( NT_PRINTER_DATA *data, const char *name );
-int lookup_printerkey( NT_PRINTER_DATA *data, const char *name );
-int get_printer_subkeys( NT_PRINTER_DATA *data, const char* key, fstring **subkeys );
-WERROR check_published_printers(void);
-WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key );
-WERROR delete_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
-WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value, 
-                           uint32 type, uint8 *data, int real_len );
-struct regval_blob* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
-WERROR mod_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
-WERROR get_a_printer( Printer_entry *print_hnd,
-                       NT_PRINTER_INFO_LEVEL **pp_printer,
-                       uint32 level,
-                       const char *sharename);
-WERROR get_a_printer_search( Printer_entry *print_hnd,
-                       NT_PRINTER_INFO_LEVEL **pp_printer,
-                       uint32 level,
-                       const char *sharename);
-uint32 free_a_printer(NT_PRINTER_INFO_LEVEL **pp_printer, uint32 level);
-bool driver_info_ctr_to_info8(struct spoolss_AddDriverInfoCtr *r,
-                             struct spoolss_DriverInfo8 *_info8);
-WERROR nt_printing_setsec(const char *sharename, struct sec_desc_buf *secdesc_ctr);
-bool nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, struct sec_desc_buf **secdesc_ctr);
-void map_printer_permissions(struct security_descriptor *sd);
-void map_job_permissions(struct security_descriptor *sd);
-bool print_time_access_check(struct auth_serversupplied_info *server_info,
-                            const char *servicename);
-void nt_printer_remove(TALLOC_CTX *mem_ctx,
-                       struct auth_serversupplied_info *server_info,
-                       const char *printer);
+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/printfsp.c  */
-
-NTSTATUS print_fsp_open(struct smb_request *req, connection_struct *conn,
-                       const char *fname,
-                       uint16_t current_vuid, files_struct *fsp);
-void print_fsp_end(files_struct *fsp, enum file_close_type close_type);
-SMB_OFF_T printfile_offset(files_struct *fsp, SMB_OFF_T offset);
-
 /* The following definitions come from printing/printing.c  */
 
 uint16 pjobid_to_rap(const char* sharename, uint32 jobid);
 bool rap_to_pjobid(uint16 rap_jobid, fstring sharename, uint32 *pjobid);
 void rap_jobid_delete(const char* sharename, uint32 jobid);
 bool print_backend_init(struct messaging_context *msg_ctx);
+void start_background_queue(struct tevent_context *ev,
+                           struct messaging_context *msg);
 void printing_end(void);
-int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob );
-uint32 sysjob_to_jobid(int unix_jobid);
-void pjob_delete(const char* sharename, uint32 jobid);
-void start_background_queue(void);
-bool print_notify_register_pid(int snum);
-bool print_notify_deregister_pid(int snum);
-bool print_job_exists(const char* sharename, uint32 jobid);
-int print_job_fd(const char* sharename, uint32 jobid);
-char *print_job_fname(const char* sharename, uint32 jobid);
-struct spoolss_DeviceMode *print_job_devmode(const char* sharename, uint32 jobid);
-bool print_job_set_name(const char *sharename, uint32 jobid, const char *name);
-bool print_job_get_name(TALLOC_CTX *mem_ctx, const char *sharename, uint32_t jobid, char **name);
-bool print_job_delete(struct auth_serversupplied_info *server_info, int snum,
-                     uint32 jobid, WERROR *errcode);
-bool print_job_pause(struct auth_serversupplied_info *server_info, int snum,
-                    uint32 jobid, WERROR *errcode);
-bool print_job_resume(struct auth_serversupplied_info *server_info, int snum,
-                     uint32 jobid, WERROR *errcode);
-ssize_t print_job_write(int snum, uint32 jobid, const char *buf, SMB_OFF_T pos, size_t size);
-int print_queue_length(int snum, print_status_struct *pstatus);
-uint32 print_job_start(struct auth_serversupplied_info *server_info, int snum,
-                      const char *jobname, struct spoolss_DeviceMode *devmode );
-void print_job_endpage(int snum, uint32 jobid);
-bool print_job_end(int snum, uint32 jobid, enum file_close_type close_type);
-int print_queue_status(int snum, 
-                      print_queue_struct **ppqueue,
-                      print_status_struct *status);
-WERROR print_queue_pause(struct auth_serversupplied_info *server_info, int snum);
-WERROR print_queue_resume(struct auth_serversupplied_info *server_info, int snum);
-WERROR print_queue_purge(struct auth_serversupplied_info *server_info, int snum);
 
 /* The following definitions come from printing/printing_db.c  */
 
@@ -4837,7 +4519,6 @@ const struct ndr_interface_table *get_iface_from_syntax(
        const struct ndr_syntax_id *syntax);
 const char *get_pipe_name_from_syntax(TALLOC_CTX *mem_ctx,
                                      const struct ndr_syntax_id *syntax);
-enum dcerpc_AuthType map_pipe_auth_type_to_rpc_auth_type(enum pipe_auth_type auth_type);
 
 struct tevent_req *rpc_api_pipe_req_send(TALLOC_CTX *mem_ctx,
                                         struct event_context *ev,
@@ -4871,10 +4552,14 @@ 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 auth_serversupplied_info *server_info);
-NTSTATUS rpc_pipe_open_internal(TALLOC_CTX *mem_ctx, const struct ndr_syntax_id *abstract_syntax,
+                                             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,
                                  struct rpc_pipe_client **spoolss_pipe);
@@ -4928,18 +4613,23 @@ NTSTATUS cli_rpc_pipe_open_schannel(struct cli_state *cli,
                                    struct rpc_pipe_client **presult);
 NTSTATUS cli_rpc_pipe_open_krb5(struct cli_state *cli,
                                const struct ndr_syntax_id *interface,
+                               enum dcerpc_transport_t transport,
                                enum dcerpc_AuthLevel auth_level,
                                const char *service_princ,
                                const char *username,
                                const char *password,
                                struct rpc_pipe_client **presult);
+NTSTATUS cli_rpc_pipe_open_spnego_krb5(struct cli_state *cli,
+                                       const struct ndr_syntax_id *interface,
+                                       enum dcerpc_transport_t transport,
+                                       enum dcerpc_AuthLevel auth_level,
+                                       const char *server,
+                                       const char *username,
+                                       const char *password,
+                                       struct rpc_pipe_client **presult);
 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  */
 
@@ -5016,14 +4706,14 @@ NTSTATUS cli_do_rpc_ndr(struct rpc_pipe_client *cli,
 
 /* The following definitions come from rpc_server/rpc_handles.c  */
 
-size_t num_pipe_handles(pipes_struct *p);
-bool init_pipe_handles(pipes_struct *p, const struct ndr_syntax_id *syntax);
-bool create_policy_hnd(pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
-bool find_policy_by_hnd(pipes_struct *p, const struct policy_handle *hnd,
+size_t num_pipe_handles(struct pipes_struct *p);
+bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *syntax);
+bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
+bool find_policy_by_hnd(struct pipes_struct *p, const struct policy_handle *hnd,
                        void **data_p);
-bool close_policy_hnd(pipes_struct *p, struct policy_handle *hnd);
-void close_policy_by_pipe(pipes_struct *p);
-bool pipe_access_check(pipes_struct *p);
+bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd);
+void close_policy_by_pipe(struct pipes_struct *p);
+bool pipe_access_check(struct pipes_struct *p);
 
 void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
                            uint32_t access_granted, size_t data_size,
@@ -5060,23 +4750,19 @@ NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface);
 
 /* The following definitions come from rpc_server/srv_pipe.c  */
 
-bool create_next_pdu(pipes_struct *p);
-bool api_pipe_bind_auth3(pipes_struct *p, struct ncacn_packet *pkt);
-bool setup_fault_pdu(pipes_struct *p, NTSTATUS status);
+bool create_next_pdu(struct pipes_struct *p);
+bool api_pipe_bind_auth3(struct pipes_struct *p, struct ncacn_packet *pkt);
+bool setup_fault_pdu(struct pipes_struct *p, NTSTATUS status);
 NTSTATUS rpc_pipe_register_commands(int version, const char *clnt,
                                    const char *srv,
                                    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(pipes_struct *p, struct ncacn_packet *pkt);
-bool api_pipe_alter_context(pipes_struct *p, struct ncacn_packet *pkt);
-void free_pipe_rpc_context( PIPE_RPC_FNS *list );
-bool api_pipe_request(pipes_struct *p, struct ncacn_packet *pkt);
 
 /* The following definitions come from rpc_server/srv_pipe_hnd.c  */
 
-pipes_struct *get_first_internal_pipe(void);
-pipes_struct *get_next_internal_pipe(pipes_struct *p);
+struct pipes_struct *get_first_internal_pipe(void);
+struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p);
 bool check_open_pipes(void);
 
 bool fsp_is_np(struct files_struct *fsp);
@@ -5084,7 +4770,9 @@ 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);
 bool np_read_in_progress(struct fake_file_handle *handle);
 struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
@@ -5104,7 +4792,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,
@@ -5907,8 +5595,9 @@ struct security_descriptor *get_nt_acl_no_snum( TALLOC_CTX *ctx, const char *fna
 /* The following definitions come from smbd/process.c  */
 
 void smbd_setup_sig_term_handler(void);
-void smbd_setup_sig_hup_handler(void);
-bool srv_send_smb(int fd, char *buffer,
+void smbd_setup_sig_hup_handler(struct tevent_context *ev,
+                               struct messaging_context *msg_ctx);
+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);
@@ -5944,8 +5633,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  */
 
@@ -6113,12 +5801,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(void);
-bool reload_services(bool test);
+void reload_printers(struct messaging_context *msg_ctx);
+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);
@@ -6144,7 +5832,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);
 
@@ -6204,7 +5892,8 @@ bool stat_cache_lookup(connection_struct *conn,
                        char **pp_dirpath,
                        char **pp_start,
                        SMB_STRUCT_STAT *pst);
-void send_stat_cache_delete_message(const char *name);
+void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
+                                   const char *name);
 void stat_cache_delete(const char *name);
 unsigned int fast_string_hash(TDB_DATA *key);
 bool reset_stat_cache( void );
@@ -6256,7 +5945,7 @@ bool change_to_guest(void);
 void conn_clear_vuid_cache(connection_struct *conn, uint16_t vuid);
 bool change_to_user(connection_struct *conn, uint16 vuid);
 bool change_to_root_user(void);
-bool become_authenticated_pipe_user(pipes_struct *p);
+bool become_authenticated_pipe_user(struct pipes_struct *p);
 bool unbecome_authenticated_pipe_user(void);
 void become_root(void);
 void unbecome_root(void);
@@ -6334,22 +6023,16 @@ 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  */
 
@@ -6373,7 +6056,6 @@ 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  */
@@ -6382,6 +6064,7 @@ 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);
+bool idmap_unix_id_is_in_range(uint32_t id, struct idmap_domain *dom);
 
 /* The following definitions come from winbindd/nss_info.c  */