s3: Remove smbd_server_conn from file_close_pid
[kai/samba.git] / source3 / include / proto.h
index 70a21021633dbd3bf6f22f3d48b087a90e51ba22..091ce17caa835273e6ff4c415062f3517c09bdda 100644 (file)
 NTSTATUS smb_register_auth(int version, const char *name, auth_init_function init);
 bool load_auth_module(struct auth_context *auth_context, 
                      const char *module, auth_methods **ret) ;
-NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context) ;
-NTSTATUS make_auth_context_fixed(struct auth_context **auth_context, uchar chal[8]) ;
+NTSTATUS make_auth_context_subsystem(TALLOC_CTX *mem_ctx,
+                                    struct auth_context **auth_context);
+NTSTATUS make_auth_context_fixed(TALLOC_CTX *mem_ctx,
+                                struct auth_context **auth_context,
+                                uchar chal[8]) ;
 
 /* The following definitions come from auth/auth_builtin.c  */
 
@@ -127,7 +130,7 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
                                    bool is_guest,
                                    uid_t *uid, gid_t *gid,
                                    char **found_username,
-                                   struct nt_user_token **token);
+                                   struct security_token **token);
 bool user_in_group_sid(const char *username, const struct dom_sid *group_sid);
 bool user_in_group(const char *username, const char *groupname);
 NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
@@ -147,8 +150,9 @@ NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
                                struct auth_serversupplied_info **server_info);
 NTSTATUS make_server_info_system(TALLOC_CTX *mem_ctx,
                                 struct auth_serversupplied_info **server_info);
+const struct auth_serversupplied_info *get_server_info_system(void);
 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,
@@ -221,29 +225,33 @@ 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, 
+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  */
 
-bool nt_token_check_sid ( const struct dom_sid *sid, const NT_USER_TOKEN *token );
-bool nt_token_check_domain_rid( NT_USER_TOKEN *token, uint32 rid );
-NT_USER_TOKEN *get_root_nt_token( void );
+bool nt_token_check_sid ( const struct dom_sid *sid, const struct security_token *token );
+bool nt_token_check_domain_rid( struct security_token *token, uint32 rid );
+struct security_token *get_root_nt_token( void );
 NTSTATUS add_aliases(const struct dom_sid *domain_sid,
-                    struct nt_user_token *token);
+                    struct security_token *token);
 NTSTATUS create_builtin_users(const struct dom_sid *sid);
 NTSTATUS create_builtin_administrators(const struct dom_sid *sid);
-struct nt_user_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
+struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
                                            const struct dom_sid *user_sid,
                                            bool is_guest,
                                            int num_groupsids,
@@ -252,8 +260,8 @@ NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
                                          bool is_guest,
                                          struct netr_SamInfo3 *info3,
                                          struct extra_auth_info *extra,
-                                         struct nt_user_token **ntok);
-void debug_nt_user_token(int dbg_class, int dbg_lev, NT_USER_TOKEN *token);
+                                         struct security_token **ntok);
+void debug_nt_user_token(int dbg_class, int dbg_lev, struct security_token *token);
 void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
                           int n_groups, gid_t *groups);
 
@@ -351,7 +359,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  */
 
@@ -499,44 +506,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);
@@ -667,44 +636,24 @@ void pidfile_unlink(void);
 
 /* The following definitions come from lib/privileges.c  */
 
-bool get_privileges_for_sids(SE_PRIV *privileges, struct dom_sid *slist, int scount);
+bool get_privileges_for_sids(uint64_t *privileges, struct dom_sid *slist, int scount);
+NTSTATUS get_privileges_for_sid_as_set(TALLOC_CTX *mem_ctx, PRIVILEGE_SET **privileges, struct dom_sid *sid);
 NTSTATUS privilege_enumerate_accounts(struct dom_sid **sids, int *num_sids);
-NTSTATUS privilege_enum_sids(const SE_PRIV *mask, TALLOC_CTX *mem_ctx,
+NTSTATUS privilege_enum_sids(enum sec_privilege privilege, TALLOC_CTX *mem_ctx,
                             struct dom_sid **sids, int *num_sids);
-bool grant_privilege(const struct dom_sid *sid, const SE_PRIV *priv_mask);
-bool grant_privilege_by_name(struct dom_sid *sid, const char *name);
-bool revoke_privilege(const struct dom_sid *sid, const SE_PRIV *priv_mask);
-bool revoke_all_privileges( struct dom_sid *sid );
-bool revoke_privilege_by_name(struct dom_sid *sid, const char *name);
+bool grant_privilege_set(const struct dom_sid *sid, struct lsa_PrivilegeSet *set);
+bool grant_privilege_by_name( const struct dom_sid *sid, const char *name);
+bool revoke_all_privileges( const struct dom_sid *sid );
+bool revoke_privilege_set(const struct dom_sid *sid, struct lsa_PrivilegeSet *set);
+bool revoke_privilege_by_name(const struct dom_sid *sid, const char *name);
 NTSTATUS privilege_create_account(const struct dom_sid *sid );
 NTSTATUS privilege_delete_account(const struct dom_sid *sid);
 NTSTATUS privilege_set_init(PRIVILEGE_SET *priv_set);
 NTSTATUS privilege_set_init_by_ctx(TALLOC_CTX *mem_ctx, PRIVILEGE_SET *priv_set);
 void privilege_set_free(PRIVILEGE_SET *priv_set);
-NTSTATUS dup_luid_attr(TALLOC_CTX *mem_ctx, struct lsa_LUIDAttribute **new_la, struct lsa_LUIDAttribute *old_la, int count);
 bool is_privileged_sid( const struct dom_sid *sid );
 bool grant_all_privileges( const struct dom_sid *sid );
 
-/* The following definitions come from lib/privileges_basic.c  */
-
-bool se_priv_copy( SE_PRIV *dst, const SE_PRIV *src );
-bool se_priv_put_all_privileges(SE_PRIV *mask);
-void se_priv_add( SE_PRIV *mask, const SE_PRIV *addpriv );
-void se_priv_remove( SE_PRIV *mask, const SE_PRIV *removepriv );
-bool se_priv_equal( const SE_PRIV *mask1, const SE_PRIV *mask2 );
-bool se_priv_from_name( const char *name, SE_PRIV *mask );
-void dump_se_priv( int dbg_cl, int dbg_lvl, const SE_PRIV *mask );
-bool is_privilege_assigned(const SE_PRIV *privileges,
-                          const SE_PRIV *check);
-const char* get_privilege_dispname( const char *name );
-bool user_has_privileges(const NT_USER_TOKEN *token, const SE_PRIV *privilege);
-bool user_has_any_privilege(NT_USER_TOKEN *token, const SE_PRIV *privilege);
-int count_all_privileges( void );
-struct lsa_LUIDAttribute get_privilege_luid( SE_PRIV *mask );
-const char *luid_to_privilege_name(const struct lsa_LUID *set);
-bool se_priv_to_privilege_set( PRIVILEGE_SET *set, SE_PRIV *mask );
-bool privilege_set_to_se_priv( SE_PRIV *mask, struct lsa_PrivilegeSet *privset );
-
 /* The following definitions come from lib/readline.c  */
 
 void smb_readline_done(void);
@@ -790,47 +739,10 @@ struct security_descriptor *get_share_security( TALLOC_CTX *ctx, const char *ser
                              size_t *psize);
 bool set_share_security(const char *share_name, struct security_descriptor *psd);
 bool delete_share_security(const char *servicename);
-bool share_access_check(const NT_USER_TOKEN *token, const char *sharename,
+bool share_access_check(const struct security_token *token, const char *sharename,
                        uint32 desired_access);
 bool parse_usershare_acl(TALLOC_CTX *ctx, const char *acl_str, struct security_descriptor **ppsd);
 
-/* The following definitions come from lib/smbldap.c  */
-
-int smb_ldap_start_tls(LDAP *ldap_struct, int version);
-int smb_ldap_setup_full_conn(LDAP **ldap_struct, const char *uri);
-int smbldap_search(struct smbldap_state *ldap_state, 
-                  const char *base, int scope, const char *filter, 
-                  const char *attrs[], int attrsonly, 
-                  LDAPMessage **res);
-int smbldap_search_paged(struct smbldap_state *ldap_state, 
-                        const char *base, int scope, const char *filter, 
-                        const char **attrs, int attrsonly, int pagesize,
-                        LDAPMessage **res, void **cookie);
-int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
-int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs[]);
-int smbldap_delete(struct smbldap_state *ldap_state, const char *dn);
-int smbldap_extended_operation(struct smbldap_state *ldap_state, 
-                              LDAP_CONST char *reqoid, struct berval *reqdata, 
-                              LDAPControl **serverctrls, LDAPControl **clientctrls, 
-                              char **retoidp, struct berval **retdatap);
-int smbldap_search_suffix (struct smbldap_state *ldap_state,
-                          const char *filter, const char **search_attr,
-                          LDAPMessage ** result);
-void smbldap_free_struct(struct smbldap_state **ldap_state) ;
-NTSTATUS smbldap_init(TALLOC_CTX *mem_ctx, struct event_context *event_ctx,
-                     const char *location,
-                     struct smbldap_state **smbldap_state);
-bool smbldap_has_control(LDAP *ld, const char *control);
-bool smbldap_has_extension(LDAP *ld, const char *extension);
-bool smbldap_has_naming_context(LDAP *ld, const char *naming_context);
-bool smbldap_set_creds(struct smbldap_state *ldap_state, bool anon, const char *dn, const char *secret);
-
-/* The following definitions come from lib/smbldap_util.c  */
-
-NTSTATUS smbldap_search_domain_info(struct smbldap_state *ldap_state,
-                                    LDAPMessage ** result, const char *domain_name,
-                                    bool try_add);
-
 /* The following definitions come from lib/smbrun.c  */
 
 int smbrun_no_sanitize(const char *cmd, int *outfd);
@@ -851,6 +763,8 @@ const char *get_remote_machine_name(void);
 void sub_set_smb_name(const char *name);
 void set_current_user_info(const char *smb_name, const char *unix_name,
                           const char *domain);
+void sub_set_socket_ids(const char *peeraddr, const char *peername,
+                       const char *sockaddr);
 const char *get_current_username(void);
 void standard_sub_basic(const char *smb_name, const char *domain_name,
                        char *str, size_t len);
@@ -970,6 +884,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 );
@@ -1198,7 +1119,6 @@ char *unix_clean_name(TALLOC_CTX *ctx, const char *s);
 char *clean_name(TALLOC_CTX *ctx, const char *s);
 ssize_t write_data_at_offset(int fd, const char *buffer, size_t N, SMB_OFF_T pos);
 int set_blocking(int fd, bool set);
-void smb_msleep(unsigned int t);
 NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                           struct event_context *ev_ctx,
                           struct server_id id,
@@ -1275,7 +1195,6 @@ char *procid_str(TALLOC_CTX *mem_ctx, const struct server_id *pid);
 char *procid_str_static(const struct server_id *pid);
 bool procid_valid(const struct server_id *pid);
 bool procid_is_local(const struct server_id *pid);
-int this_is_smp(void);
 bool trans_oob(uint32_t bufsize, uint32_t offset, uint32_t length);
 bool is_offset_safe(const char *buf_base, size_t buf_len, char *ptr, size_t off);
 char *get_safe_ptr(const char *buf_base, size_t buf_len, char *ptr, size_t off);
@@ -1311,12 +1230,12 @@ void smb_nscd_flush_group_cache(void);
 
 /* The following definitions come from lib/util_nttoken.c  */
 
-NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken);
+struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *ptoken);
 NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
-                       const struct nt_user_token *token_1,
-                       const struct nt_user_token *token_2,
-                       struct nt_user_token **token_out);
-bool token_sid_in_ace(const NT_USER_TOKEN *token, const struct security_ace *ace);
+                       const struct security_token *token_1,
+                       const struct security_token *token_2,
+                       struct security_token **token_out);
+bool token_sid_in_ace(const struct security_token *token, const struct security_ace *ace);
 
 /* The following definitions come from lib/util_pw.c  */
 
@@ -1339,7 +1258,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, const struct standard_mapping *mapping);
-NTSTATUS se_access_check(const struct security_descriptor *sd, const NT_USER_TOKEN *token,
+NTSTATUS se_access_check(const struct security_descriptor *sd, const struct security_token *token,
                     uint32 acc_desired, uint32 *acc_granted);
 
 /* The following definitions come from lib/util_sec.c  */
@@ -1364,7 +1283,7 @@ bool is_setuid_root(void) ;
 /* The following definitions come from lib/util_sid.c  */
 
 const char *sid_type_lookup(uint32 sid_type) ;
-NT_USER_TOKEN *get_system_token(void) ;
+const struct security_token *get_system_token(void) ;
 char *sid_to_fstring(fstring sidstr_out, const struct dom_sid *sid);
 char *sid_string_talloc(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
 char *sid_string_dbg(const struct dom_sid *sid);
@@ -1378,26 +1297,21 @@ bool sid_peek_check_rid(const struct dom_sid *exp_dom_sid, const struct dom_sid
 void sid_copy(struct dom_sid *dst, const struct dom_sid *src);
 bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid);
 bool sid_parse(const char *inbuf, size_t len, struct dom_sid *sid);
-int sid_compare(const struct dom_sid *sid1, const struct dom_sid *sid2);
-int sid_compare_domain(const struct dom_sid *sid1, const struct dom_sid *sid2);
-bool sid_equal(const struct dom_sid *sid1, const struct dom_sid *sid2);
 bool non_mappable_sid(struct dom_sid *sid);
-char *sid_binstring(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
 char *sid_binstring_hex(const struct dom_sid *sid);
-struct dom_sid *sid_dup_talloc(TALLOC_CTX *ctx, const struct dom_sid *src);
 NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
-                         struct dom_sid **sids, size_t *num);
+                         struct dom_sid **sids, uint32_t *num);
 NTSTATUS add_sid_to_array_unique(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
-                                struct dom_sid **sids, size_t *num_sids);
+                                struct dom_sid **sids, uint32_t *num_sids);
 void del_sid_from_array(const struct dom_sid *sid, struct dom_sid **sids, size_t *num);
 bool add_rid_to_array_unique(TALLOC_CTX *mem_ctx,
                                    uint32 rid, uint32 **pp_rids, size_t *p_num);
 bool is_null_sid(const struct dom_sid *sid);
-bool is_sid_in_token(const NT_USER_TOKEN *token, const struct dom_sid *sid);
+bool is_sid_in_token(const struct security_token *token, const struct dom_sid *sid);
 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
                              const struct netr_SamInfo3 *info3,
                              struct dom_sid **user_sids,
-                             size_t *num_user_sids,
+                             uint32_t *num_user_sids,
                              bool include_user_group_rid,
                              bool skip_ressource_groups);
 
@@ -1448,8 +1362,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,
@@ -1673,12 +1585,6 @@ int tolower_ascii(int c);
 int isupper_ascii(int c);
 int islower_ascii(int c);
 
-/* The following definitions come from lib/util_uuid.c  */
-
-void smb_uuid_pack(const struct GUID uu, UUID_FLAT *ptr);
-void smb_uuid_unpack(const UUID_FLAT in, struct GUID *uu);
-char *guid_binstring(TALLOC_CTX *mem_ctx, const struct GUID *guid);
-
 /* The following definitions come from lib/version.c  */
 
 const char *samba_version_string(void);
@@ -2072,6 +1978,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,
@@ -2336,12 +2244,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);
@@ -2485,6 +2403,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;
@@ -2635,6 +2560,16 @@ bool spnego_parse_auth_response(TALLOC_CTX *ctx,
                                const char *mechOID,
                                DATA_BLOB *auth);
 
+bool spnego_parse_auth_and_mic(TALLOC_CTX *ctx, DATA_BLOB blob,
+                               DATA_BLOB *auth, DATA_BLOB *signature);
+DATA_BLOB spnego_gen_auth_response_and_mic(TALLOC_CTX *ctx,
+                                          NTSTATUS nt_status,
+                                          const char *mechOID,
+                                          DATA_BLOB *reply,
+                                          DATA_BLOB *mechlistMIC);
+bool spnego_mech_list_blob(TALLOC_CTX *mem_ctx,
+                          char **oid_list, DATA_BLOB *data);
+
 /* The following definitions come from libsmb/clistr.c  */
 
 size_t clistr_push_fn(const char *function,
@@ -2871,8 +2806,8 @@ bool match_mailslot_name(struct packet_struct *p, const char *mailslot_name);
 int matching_len_bits(unsigned char *p1, unsigned char *p2, size_t len);
 void sort_query_replies(char *data, int n, struct in_addr ip);
 char *name_mangle(TALLOC_CTX *mem_ctx, char *In, char name_type);
-int name_extract(char *buf,int ofs, fstring name);
-int name_len(char *s1);
+int name_extract(unsigned char *buf,size_t buf_len, unsigned int ofs, fstring name);
+int name_len(unsigned char *s1, size_t buf_len);
 
 /* The following definitions come from libsmb/nterr.c  */
 
@@ -3213,363 +3148,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);
@@ -3925,6 +3503,7 @@ int lp_smb_encrypt(int );
 char lp_magicchar(const struct share_params *p );
 int lp_winbind_cache_time(void);
 int lp_winbind_reconnect_delay(void);
+int lp_winbind_max_clients(void);
 const char **lp_winbind_nss_info(void);
 int lp_algorithmic_rid_base(void);
 int lp_name_cache_timeout(void);
@@ -3971,6 +3550,8 @@ const char *lp_ldap_group_suffix(void);
 const char *lp_ldap_idmap_suffix(void);
 void *lp_local_ptr_by_snum(int snum, void *ptr);
 bool lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue);
+bool lp_set_cmdline(const char *pszParmName, const char *pszParmValue);
+bool lp_set_option(const char *option);
 void init_locals(void);
 bool lp_is_default(int snum, struct parm_struct *parm);
 bool dump_a_parameter(int snum, char *parm_name, FILE * f, bool isGlobal);
@@ -3999,13 +3580,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,
@@ -4057,6 +3631,7 @@ int lp_min_receive_file_size(void);
 char* lp_perfcount_module(void);
 void lp_set_passdb_backend(const char *backend);
 void widelinks_warning(int snum);
+char *lp_ncalrpc_dir(void);
 
 /* The following definitions come from param/loadparm_server_role.c  */
 
@@ -4333,17 +3908,17 @@ NTSTATUS make_pdb_method( struct pdb_methods **methods ) ;
 
 /* The following definitions come from passdb/pdb_ldap.c  */
 
+struct ldapsam_privates;
+
 const char** get_userattr_list( TALLOC_CTX *mem_ctx, int schema_ver );
-int ldapsam_search_suffix_by_name(struct ldapsam_privates *ldap_state,
-                                         const char *user,
-                                         LDAPMessage ** result,
-                                         const char **attr);
 NTSTATUS pdb_init_ldapsam_compat(struct pdb_methods **pdb_method, const char *location);
 NTSTATUS pdb_init_ldapsam(struct pdb_methods **pdb_method, const char *location);
 NTSTATUS pdb_ldap_init(void);
 
 /* The following definitions come from passdb/pdb_nds.c  */
 
+struct smbldap_state;
+
 int pdb_nds_get_password(
        struct smbldap_state *ldap_state,
        char *object_dn,
@@ -4537,16 +4112,27 @@ 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,
+                                             struct client_address *client_id,
+                                             const struct auth_serversupplied_info *server_info,
                                              struct messaging_context *msg_ctx);
+NTSTATUS rpcint_binding_handle(TALLOC_CTX *mem_ctx,
+                              const struct ndr_interface_table *ndr_table,
+                              struct client_address *client_id,
+                              const struct auth_serversupplied_info *server_info,
+                              struct messaging_context *msg_ctx,
+                              struct dcerpc_binding_handle **binding_handle);
 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);
+NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
+                                const struct ndr_syntax_id *syntax,
+                                struct auth_serversupplied_info *server_info,
+                                struct client_address *client_id,
+                                struct messaging_context *msg_ctx,
+                                struct rpc_pipe_client **cli_pipe);
 NTSTATUS cli_rpc_pipe_open_noauth(struct cli_state *cli,
                                  const struct ndr_syntax_id *interface,
                                  struct rpc_pipe_client **presult);
@@ -4665,26 +4251,12 @@ 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_client/rpc_transport_tstream.c  */
+NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx,
+                               struct tstream_context *npipe,
+                               struct tevent_queue *read_queue,
+                               struct tevent_queue *write_queue,
+                                struct rpc_cli_transport **presult);
 
 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
 
@@ -4742,22 +4314,20 @@ 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  */
 
 struct pipes_struct *get_first_internal_pipe(void);
 struct pipes_struct *get_next_internal_pipe(struct pipes_struct *p);
 bool check_open_pipes(void);
+int close_internal_rpc_pipe_hnd(struct pipes_struct *p);
 
 bool fsp_is_np(struct files_struct *fsp);
 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);
@@ -4772,7 +4342,10 @@ struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
 NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
                      bool *is_data_outstanding);
 
+ssize_t process_incoming_data(struct pipes_struct *p, char *data, size_t n);
+
 /* The following definitions come from rpc_server/srv_spoolss_nt.c  */
+void srv_spoolss_cleanup(void);
 
 void do_drv_upgrade_printer(struct messaging_context *msg,
                            void *private_data,
@@ -4836,11 +4409,14 @@ bool init_service_op_table( void );
 /* The following definitions come from services/services_db.c  */
 
 void svcctl_init_keys( void );
-struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token );
-bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, struct security_descriptor *sec_desc, NT_USER_TOKEN *token );
-const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token );
-const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *token );
-struct regval_ctr *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *token );
+struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, struct security_token *token );
+bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc,
+                       struct security_token *token);
+const char *svcctl_get_string_value(TALLOC_CTX *ctx, const char *key_name,
+                                   const char *value_name,
+                                   struct security_token *token);
+const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, struct security_token *token );
+const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, struct security_token *token );
 
 /* The following definitions come from services/svc_netlogon.c  */
 
@@ -5175,24 +4751,21 @@ bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname);
 NTSTATUS file_new(struct smb_request *req, connection_struct *conn,
                  files_struct **result);
 void file_close_conn(connection_struct *conn);
-void file_close_pid(uint16 smbpid, int vuid);
+void file_close_pid(struct smbd_server_connection *sconn, uint16 smbpid,
+                   int vuid);
 void file_init(void);
 void file_close_user(int vuid);
-void file_dump_open_table(void);
 struct files_struct *files_forall(
        struct files_struct *(*fn)(struct files_struct *fsp,
                                   void *private_data),
        void *private_data);
 files_struct *file_find_fd(int fd);
 files_struct *file_find_dif(struct file_id id, unsigned long gen_id);
-files_struct *file_find_fsp(files_struct *orig_fsp);
 files_struct *file_find_di_first(struct file_id id);
 files_struct *file_find_di_next(files_struct *start_fsp);
-files_struct *file_find_print(void);
 bool file_find_subpath(files_struct *dir_fsp);
 void file_sync_all(connection_struct *conn);
 void file_free(struct smb_request *req, files_struct *fsp);
-files_struct *file_fnum(uint16 fnum);
 files_struct *file_fsp(struct smb_request *req, uint16 fid);
 NTSTATUS dup_file_fsp(struct smb_request *req, files_struct *from,
                      uint32 access_mask, uint32 share_access,
@@ -5247,10 +4820,31 @@ const struct mangle_fns *mangle_hash_init(void);
 const struct mangle_fns *mangle_hash2_init(void);
 const struct mangle_fns *posix_mangle_init(void);
 
-/* The following definitions come from smbd/map_username.c  */
+/* The following definitions come from auth/user_util.c  */
 
 bool map_username(fstring user);
 
+/* The following definitions come from auth/user_krb5.c  */
+struct PAC_LOGON_INFO;
+NTSTATUS get_user_from_kerberos_info(TALLOC_CTX *mem_ctx,
+                                    const char *cli_name,
+                                    const char *princ_name,
+                                    struct PAC_LOGON_INFO *logon_info,
+                                    bool *is_mapped,
+                                    bool *mapped_to_guest,
+                                    char **ntuser,
+                                    char **ntdomain,
+                                    char **username,
+                                    struct passwd **_pw);
+NTSTATUS make_server_info_krb5(TALLOC_CTX *mem_ctx,
+                               char *ntuser,
+                               char *ntdomain,
+                               char *username,
+                               struct passwd *pw,
+                               struct PAC_LOGON_INFO *logon_info,
+                               bool mapped_to_guest,
+                               struct auth_serversupplied_info **server_info);
+
 /* The following definitions come from smbd/message.c  */
 
 void reply_sends(struct smb_request *req);
@@ -5294,7 +4888,7 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
                                connection_struct **pconn,
                                int snum,
                                const char *path,
-                               struct auth_serversupplied_info *server_info,
+                               const struct auth_serversupplied_info *server_info,
                                char **poldcwd);
 
 /* The following definitions come from smbd/negprot.c  */
@@ -5352,7 +4946,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
                                   struct messaging_context *messaging_ctx,
                                   struct event_context *ev,
                                   connection_struct *conn);
-bool notify_internal_parent_init(void);
+bool notify_internal_parent_init(TALLOC_CTX *mem_ctx);
 NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
                    void (*callback)(void *, const struct notify_event *), 
                    void *private_data);
@@ -5398,7 +4992,7 @@ void reply_nttranss(struct smb_request *req);
 
 NTSTATUS smb1_file_se_access_check(connection_struct *conn,
                                const struct security_descriptor *sd,
-                               const NT_USER_TOKEN *token,
+                               const struct security_token *token,
                                uint32_t access_desired,
                                uint32_t *access_granted);
 NTSTATUS fd_close(files_struct *fsp);
@@ -5584,7 +5178,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);
@@ -5671,7 +5265,7 @@ bool check_fsp(connection_struct *conn, struct smb_request *req,
               files_struct *fsp);
 bool check_fsp_ntquota_handle(connection_struct *conn, struct smb_request *req,
                              files_struct *fsp);
-void reply_special(struct smbd_server_connection *sconn, char *inbuf);
+void reply_special(struct smbd_server_connection *sconn, char *inbuf, size_t inbuf_len);
 void reply_tcon(struct smb_request *req);
 void reply_tcon_and_X(struct smb_request *req);
 void reply_unknown_new(struct smb_request *req, uint8 type);
@@ -5774,7 +5368,7 @@ void server_encryption_shutdown(void);
 
 bool unix_token_equal(const UNIX_USER_TOKEN *t1, const UNIX_USER_TOKEN *t2);
 bool push_sec_ctx(void);
-void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, NT_USER_TOKEN *token);
+void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, struct security_token *token);
 void set_root_sec_ctx(void);
 bool pop_sec_ctx(void);
 void init_sec_ctx(void);
@@ -5787,12 +5381,12 @@ void server_messaging_context_free(void);
 
 /* The following definitions come from smbd/server.c  */
 
-int smbd_server_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);
@@ -5818,7 +5412,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);
 
@@ -5852,13 +5446,13 @@ void reply_sesssetup_and_X(struct smb_request *req);
 bool token_contains_name_in_list(const char *username,
                                 const char *domain,
                                 const char *sharename,
-                                const struct nt_user_token *token,
+                                const struct security_token *token,
                                 const char **list);
 bool user_ok_token(const char *username, const char *domain,
-                  const struct nt_user_token *token, int snum);
+                  const struct security_token *token, int snum);
 bool is_share_read_only_for_token(const char *username,
                                  const char *domain,
-                                 const struct nt_user_token *token,
+                                 const struct security_token *token,
                                  connection_struct *conn);
 
 /* The following definitions come from smbd/srvstr.c  */
@@ -5940,7 +5534,7 @@ bool unbecome_user(void);
 uid_t get_current_uid(connection_struct *conn);
 gid_t get_current_gid(connection_struct *conn);
 const UNIX_USER_TOKEN *get_current_utok(connection_struct *conn);
-const NT_USER_TOKEN *get_current_nttok(connection_struct *conn);
+const struct security_token *get_current_nttok(connection_struct *conn);
 uint16_t get_current_vuid(connection_struct *conn);
 
 /* The following definitions come from smbd/utmp.c  */
@@ -6003,55 +5597,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);
-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_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);
-
-/* 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_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);
-bool idmap_unix_id_is_in_range(uint32_t id, struct idmap_domain *dom);
-
 /* The following definitions come from winbindd/nss_info.c  */
 
 
@@ -6080,11 +5625,12 @@ struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 int fncall_recv(struct tevent_req *req, int *perr);
 
 /* The following definitions come from rpc_server/srv_samr_nt.c */
-NTSTATUS access_check_object( struct security_descriptor *psd, NT_USER_TOKEN *token,
-                               SE_PRIV *rights, uint32 rights_mask,
-                               uint32 des_access, uint32 *acc_granted,
-                               const char *debug);
-void map_max_allowed_access(const NT_USER_TOKEN *nt_token,
+NTSTATUS access_check_object( struct security_descriptor *psd, struct security_token *token,
+                             enum sec_privilege needed_priv_1, enum sec_privilege needed_priv_2,
+                             uint32 rights_mask,
+                             uint32 des_access, uint32 *acc_granted,
+                             const char *debug );
+void map_max_allowed_access(const struct security_token *nt_token,
                            const struct unix_user_token *unix_token,
                            uint32_t *pacc_requested);
 
@@ -6095,5 +5641,6 @@ uint32_t ds_uf2acb(uint32_t uf);
 uint32_t ds_uf2atype(uint32_t uf);
 uint32_t ds_gtype2atype(uint32_t gtype);
 enum lsa_SidType ds_atype_map(uint32_t atype);
+uint32_t ds_uf2prim_group_rid(uint32_t uf);
 
 #endif /*  _PROTO_H_  */