nterr: Add mem_ctx for return string from get_nt_error_c_code()
[ddiss/samba.git] / source3 / include / proto.h
index 730960b851e5427e975b2dc3bd3f81ac72a39c98..a6e9cf9b5db0bff4e5b9a3f830a6a6d0b4c7aa3c 100644 (file)
 #ifndef _PROTO_H_
 #define _PROTO_H_
 
-
-/* The following definitions come from auth/auth.c  */
-
-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(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  */
-
-NTSTATUS auth_builtin_init(void);
-
-/* The following definitions come from auth/auth_compat.c  */
-
-NTSTATUS check_plaintext_password(const char *smb_name,
-                                 DATA_BLOB plaintext_password,
-                                 struct auth_serversupplied_info **server_info);
-bool password_ok(struct auth_context *actx, bool global_encrypted,
-                const char *session_workgroup,
-                const char *smb_name, DATA_BLOB password_blob);
-
-/* The following definitions come from auth/auth_domain.c  */
-
-void attempt_machine_password_change(void);
-NTSTATUS auth_domain_init(void);
-
-NTSTATUS auth_netlogond_init(void);
-
-/* The following definitions come from auth/auth_ntlmssp.c  */
-
-NTSTATUS auth_ntlmssp_steal_session_info(TALLOC_CTX *mem_ctx,
-                               struct auth_ntlmssp_state *auth_ntlmssp_state,
-                               struct auth_serversupplied_info **session_info);
-NTSTATUS auth_ntlmssp_start(struct auth_ntlmssp_state **auth_ntlmssp_state);
-
-
-/* The following definitions come from auth/auth_sam.c  */
-
-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  */
-
-NTSTATUS auth_server_init(void);
-
-/* The following definitions come from auth/auth_unix.c  */
-
-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 *workstation_name,
-                           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, 
-                                    const char *workstation_name,
-                                    uint32 logon_parameters,
-                                    const uchar *lm_network_pwd,
-                                    int lm_pwd_len,
-                                    const uchar *nt_network_pwd,
-                                    int nt_pwd_len);
-bool make_user_info_netlogon_interactive(struct auth_usersupplied_info **user_info,
-                                        const char *smb_name, 
-                                        const char *client_domain, 
-                                        const char *workstation_name,
-                                        uint32 logon_parameters,
-                                        const uchar chal[8], 
-                                        const uchar lm_interactive_pwd[16], 
-                                        const uchar nt_interactive_pwd[16], 
-                                        const uchar *dc_sess_key);
-bool make_user_info_for_reply(struct auth_usersupplied_info **user_info,
-                             const char *smb_name, 
-                             const char *client_domain,
-                             const uint8 chal[8],
-                             DATA_BLOB plaintext_password);
-NTSTATUS make_user_info_for_reply_enc(struct auth_usersupplied_info **user_info,
-                                      const char *smb_name,
-                                      const char *client_domain, 
-                                      DATA_BLOB lm_resp, DATA_BLOB nt_resp);
-bool make_user_info_guest(struct auth_usersupplied_info **user_info) ;
-struct samu;
-NTSTATUS make_server_info_sam(struct auth_serversupplied_info **server_info,
-                             struct samu *sampass);
-NTSTATUS create_local_token(struct auth_serversupplied_info *server_info);
-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 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);
-struct passwd;
-NTSTATUS make_server_info_pw(struct auth_serversupplied_info **server_info,
-                             char *unix_username,
-                            struct passwd *pwd);
-NTSTATUS make_serverinfo_from_username(TALLOC_CTX *mem_ctx,
-                                      const char *username,
-                                      bool is_guest,
-                                      struct auth_serversupplied_info **presult);
-struct auth_serversupplied_info *copy_serverinfo(TALLOC_CTX *mem_ctx,
-                                                const struct auth_serversupplied_info *src);
-bool init_guest_info(void);
-NTSTATUS init_system_info(void);
-bool session_info_set_session_key(struct auth_serversupplied_info *info,
-                                DATA_BLOB session_key);
-NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx,
-                               struct auth_serversupplied_info **server_info);
-NTSTATUS make_session_info_system(TALLOC_CTX *mem_ctx,
-                                struct auth_serversupplied_info **session_info);
-const struct auth_serversupplied_info *get_session_info_system(void);
-bool copy_current_user(struct current_user *dst, struct current_user *src);
-struct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser,
-                            char **p_save_username, bool create );
-NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, 
-                               const char *sent_nt_username,
-                               const char *domain,
-                               struct auth_serversupplied_info **server_info,
-                               struct netr_SamInfo3 *info3);
-struct wbcAuthUserInfo;
-NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
-                                         const char *sent_nt_username,
-                                         const char *domain,
-                                         const struct wbcAuthUserInfo *info,
-                                         struct auth_serversupplied_info **server_info);
-void free_user_info(struct auth_usersupplied_info **user_info);
-bool make_auth_methods(struct auth_context *auth_context, auth_methods **auth_method) ;
-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 **ret_user_info,
-                       const char *smb_name,
-                       const char *internal_username,
-                       const char *client_domain,
-                       const char *domain,
-                       const char *workstation_name,
-                       const DATA_BLOB *lm_pwd,
-                       const DATA_BLOB *nt_pwd,
-                       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  */
-
-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,
-                               size_t pipe_session_key_len,
-                               struct netr_SamInfo2 *sam2);
-NTSTATUS serverinfo_to_SamInfo3(const struct auth_serversupplied_info *server_info,
-                               uint8_t *pipe_session_key,
-                               size_t pipe_session_key_len,
-                               struct netr_SamInfo3 *sam3);
-NTSTATUS serverinfo_to_SamInfo6(struct auth_serversupplied_info *server_info,
-                               uint8_t *pipe_session_key,
-                               size_t pipe_session_key_len,
-                               struct netr_SamInfo6 *sam6);
-NTSTATUS samu_to_SamInfo3(TALLOC_CTX *mem_ctx,
-                         struct samu *samu,
-                         const char *login_server,
-                         struct netr_SamInfo3 **_info3,
-                         struct extra_auth_info *extra);
-struct netr_SamInfo3 *copy_netr_SamInfo3(TALLOC_CTX *mem_ctx,
-                                        struct netr_SamInfo3 *orig);
-struct netr_SamInfo3 *wbcAuthUserInfo_to_netr_SamInfo3(TALLOC_CTX *mem_ctx,
-                                       const struct wbcAuthUserInfo *info);
-
-/* The following definitions come from auth/auth_wbc.c  */
-
-NTSTATUS auth_wbc_init(void);
-
-/* The following definitions come from auth/pampass.c  */
-
-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, 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 *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 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 security_token *token);
-struct security_token *create_local_nt_token(TALLOC_CTX *mem_ctx,
-                                           const struct dom_sid *user_sid,
-                                           bool is_guest,
-                                           int num_groupsids,
-                                           const struct dom_sid *groupsids);
-NTSTATUS create_local_nt_token_from_info3(TALLOC_CTX *mem_ctx,
-                                         bool is_guest,
-                                         struct netr_SamInfo3 *info3,
-                                         struct extra_auth_info *extra,
-                                         struct security_token **ntok);
-void debug_unix_user_token(int dbg_class, int dbg_lev, uid_t uid, gid_t gid,
-                          int n_groups, gid_t *groups);
-
 /* The following definitions come from lib/access.c  */
 
 bool client_match(const char *tok, const void *item);
@@ -314,22 +72,16 @@ int bitmap_find(struct bitmap *bm, unsigned ofs);
 
 /* The following definitions come from lib/charcnv.c  */
 
-void lazy_initialize_conv(void);
 void gfree_charcnv(void);
 void init_iconv(void);
-size_t convert_string(charset_t from, charset_t to,
+bool convert_string(charset_t from, charset_t to,
                      void const *src, size_t srclen, 
-                     void *dest, size_t destlen);
-size_t convert_string_error(charset_t from, charset_t to,
+                     void *dest, size_t destlen,
+                     size_t *converted_size);
+bool convert_string_error(charset_t from, charset_t to,
                            void const *src, size_t srclen,
                            void *dest, size_t destlen,
                            size_t *converted_size);
-size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen);
-char *talloc_strdup_upper(TALLOC_CTX *ctx, const char *s);
-char *strupper_talloc(TALLOC_CTX *ctx, const char *s);
-size_t unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen);
-char *talloc_strdup_lower(TALLOC_CTX *ctx, const char *s);
-char *strlower_talloc(TALLOC_CTX *ctx, const char *s);
 size_t ucs2_align(const void *base_ptr, const void *p, int flags);
 size_t push_ascii(void *dest, const char *src, size_t dest_len, int flags);
 size_t push_ascii_fstring(void *dest, const char *src);
@@ -337,20 +89,6 @@ size_t push_ascii_nstring(void *dest, const char *src);
 size_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
 size_t pull_ascii_fstring(char *dest, const void *src);
 size_t pull_ascii_nstring(char *dest, size_t dest_len, const void *src);
-size_t push_ucs2(const void *base_ptr, void *dest, const char *src, size_t dest_len, int flags);
-size_t push_utf8_fstring(void *dest, const char *src);
-bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
-                     size_t *converted_size);
-size_t pull_ucs2(const void *base_ptr, char *dest, const void *src, size_t dest_len, size_t src_len, int flags);
-size_t pull_ucs2_fstring(char *dest, const void *src);
-bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src,
-                     size_t *converted_size);
-bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
-                     size_t *converted_size);
-bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *src,
-                     size_t *converted_size);
-bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
-                      size_t *converted_size);
 size_t push_string_check_fn(void *dest, const char *src,
                            size_t dest_len, int flags);
 size_t push_string_base(const char *base, uint16 flags2,
@@ -371,6 +109,9 @@ size_t pull_string_talloc(TALLOC_CTX *ctx,
                        size_t src_len,
                        int flags);
 size_t align_string(const void *base_ptr, const char *p, int flags);
+size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate);
+int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags);
+int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
 
 /* The following definitions come from lib/conn_tdb.c  */
 
@@ -484,23 +225,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/privileges.c  */
-
-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(enum sec_privilege privilege, TALLOC_CTX *mem_ctx,
-                            struct dom_sid **sids, int *num_sids);
-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);
-bool is_privileged_sid( const struct dom_sid *sid );
-bool grant_all_privileges( const struct dom_sid *sid );
-
 /* The following definitions come from lib/recvfile.c  */
 
 ssize_t sys_recvfile(int fromfd,
@@ -803,16 +527,6 @@ int sys_aio_cancel(int fd, SMB_STRUCT_AIOCB *aiocb);
 int sys_aio_error(const SMB_STRUCT_AIOCB *aiocb);
 int sys_aio_fsync(int op, SMB_STRUCT_AIOCB *aiocb);
 int sys_aio_suspend(const SMB_STRUCT_AIOCB * const cblist[], int n, const struct timespec *timeout);
-int sys_getpeereid( int s, uid_t *uid);
-int sys_getnameinfo(const struct sockaddr *psa,
-                       socklen_t salen,
-                       char *host,
-                       size_t hostlen,
-                       char *service,
-                       size_t servlen,
-                       int flags);
-int sys_connect(int fd, const struct sockaddr * addr);
-
 /* The following definitions come from lib/system_smbd.c  */
 
 bool getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
@@ -896,45 +610,12 @@ void gfree_all( void );
 const char *my_netbios_names(int i);
 bool set_netbios_aliases(const char **str_array);
 bool init_names(void);
-struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx);
-const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info);
-void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
-                                   const char *username);
-const char *get_cmdline_auth_info_domain(const struct user_auth_info *auth_info);
-void set_cmdline_auth_info_domain(struct user_auth_info *auth_info,
-                                 const char *domain);
-void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
-                                   const char *password);
-const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info);
-bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
-                                        const char *arg);
-int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info);
-void set_cmdline_auth_info_use_ccache(struct user_auth_info *auth_info,
-                                     bool b);
-bool get_cmdline_auth_info_use_ccache(const struct user_auth_info *auth_info);
-void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
-                                       bool b);
-bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info);
-void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
-                                       bool b);
-bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info);
-void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info);
-void set_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info);
-void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info);
-bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info);
-bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info);
-bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info);
-struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
-                                                const struct user_auth_info *info);
-bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_info);
-void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info);
 bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
                     bool fake_dir_create_times);
 bool socket_exist(const char *fname);
 uint64_t get_file_size_stat(const SMB_STRUCT_STAT *sbuf);
 SMB_OFF_T get_file_size(char *file_name);
-char *attrib_string(uint16 mode);
-void show_msg(char *buf);
+void show_msg(const char *buf);
 void smb_set_enclen(char *buf,int len,uint16 enc_ctx_num);
 void smb_setlen(char *buf,int len);
 int set_message_bcc(char *buf,int num_bytes);
@@ -1040,6 +721,42 @@ bool tevent_req_poll_ntstatus(struct tevent_req *req,
                              NTSTATUS *status);
 bool any_nt_status_not_ok(NTSTATUS err1, NTSTATUS err2, NTSTATUS *result);
 int timeval_to_msec(struct timeval t);
+char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
+
+/* The following definitions come from lib/util_cmdline.c  */
+
+struct user_auth_info *user_auth_info_init(TALLOC_CTX *mem_ctx);
+const char *get_cmdline_auth_info_username(const struct user_auth_info *auth_info);
+void set_cmdline_auth_info_username(struct user_auth_info *auth_info,
+                                   const char *username);
+const char *get_cmdline_auth_info_domain(const struct user_auth_info *auth_info);
+void set_cmdline_auth_info_domain(struct user_auth_info *auth_info,
+                                 const char *domain);
+void set_cmdline_auth_info_password(struct user_auth_info *auth_info,
+                                   const char *password);
+const char *get_cmdline_auth_info_password(const struct user_auth_info *auth_info);
+bool set_cmdline_auth_info_signing_state(struct user_auth_info *auth_info,
+                                        const char *arg);
+int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info);
+void set_cmdline_auth_info_use_ccache(struct user_auth_info *auth_info,
+                                     bool b);
+bool get_cmdline_auth_info_use_ccache(const struct user_auth_info *auth_info);
+void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
+                                       bool b);
+bool get_cmdline_auth_info_use_kerberos(const struct user_auth_info *auth_info);
+void set_cmdline_auth_info_fallback_after_kerberos(struct user_auth_info *auth_info,
+                                       bool b);
+bool get_cmdline_auth_info_fallback_after_kerberos(const struct user_auth_info *auth_info);
+void set_cmdline_auth_info_use_krb5_ticket(struct user_auth_info *auth_info);
+void set_cmdline_auth_info_smb_encrypt(struct user_auth_info *auth_info);
+void set_cmdline_auth_info_use_machine_account(struct user_auth_info *auth_info);
+bool get_cmdline_auth_info_got_pass(const struct user_auth_info *auth_info);
+bool get_cmdline_auth_info_smb_encrypt(const struct user_auth_info *auth_info);
+bool get_cmdline_auth_info_use_machine_account(const struct user_auth_info *auth_info);
+struct user_auth_info *get_cmdline_auth_info_copy(TALLOC_CTX *mem_ctx,
+                                                const struct user_auth_info *info);
+bool set_cmdline_auth_info_machine_account_creds(struct user_auth_info *auth_info);
+void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info);
 
 /* The following definitions come from lib/util_builtin.c  */
 
@@ -1096,6 +813,7 @@ char *sid_string_tos(const struct dom_sid *sid);
 bool sid_linearize(char *outbuf, size_t len, const struct dom_sid *sid);
 bool non_mappable_sid(struct dom_sid *sid);
 char *sid_binstring_hex(const struct dom_sid *sid);
+struct netr_SamInfo3;
 NTSTATUS sid_array_from_info3(TALLOC_CTX *mem_ctx,
                              const struct netr_SamInfo3 *info3,
                              struct dom_sid **user_sids,
@@ -1193,6 +911,7 @@ struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
 int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
 int poll_one_fd(int fd, int events, int timeout, int *revents);
 int poll_intr_one_fd(int fd, int events, int timeout, int *revents);
+struct tstream_context;
 struct tevent_req *tstream_read_packet_send(TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
                                            struct tstream_context *stream,
@@ -1212,34 +931,16 @@ int StrnCaseCmp(const char *s, const char *t, size_t len);
 bool strnequal(const char *s1,const char *s2,size_t n);
 bool strcsequal(const char *s1,const char *s2);
 void strnorm(char *s, int case_default);
-bool strisnormal(const char *s, int case_default);
 char *push_skip_string(char *buf);
 char *skip_string(const char *base, size_t len, char *buf);
 size_t str_charnum(const char *s);
-size_t str_ascii_charnum(const char *s);
 bool trim_char(char *s,char cfront,char cback);
 bool strhasupper(const char *s);
 bool strhaslower(const char *s);
-char *safe_strcpy_fn(char *dest,
-               const char *src,
-               size_t maxlength);
-char *safe_strcat_fn(char *dest,
-               const char *src,
-               size_t maxlength);
-char *alpha_strcpy(char *dest,
-               const char *src,
-               const char *other_safe_chars,
-               size_t maxlength);
 char *StrnCpy(char *dest,const char *src,size_t n);
 bool in_list(const char *s, const char *list, bool casesensitive);
 void string_free(char **s);
 bool string_set(char **dest,const char *src);
-void string_sub2(char *s,const char *pattern, const char *insert, size_t len,
-                bool remove_unsafe_characters, bool replace_once,
-                bool allow_trailing_dollar);
-void string_sub_once(char *s, const char *pattern,
-               const char *insert, size_t len);
-void string_sub(char *s,const char *pattern, const char *insert, size_t len);
 void fstring_sub(char *s,const char *pattern,const char *insert);
 char *realloc_string_sub2(char *string,
                        const char *pattern,
@@ -1285,12 +986,8 @@ char *ipstr_list_make(char **ipstr_list,
                        int ip_count);
 int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list);
 void ipstr_list_free(char* ipstr_list);
-DATA_BLOB base64_decode_data_blob(const char *s);
-void base64_decode_inplace(char *s);
-char *base64_encode_data_blob(TALLOC_CTX *mem_ctx, DATA_BLOB data);
 uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr);
-SMB_OFF_T conv_str_size(const char * str);
-void string_append(char **left, const char *right);
+uint64_t conv_str_size(const char * str);
 bool add_string_to_array(TALLOC_CTX *mem_ctx,
                         const char *str, const char ***strings,
                         int *num);
@@ -1307,48 +1004,6 @@ char *escape_shell_string(const char *src);
 char **str_list_make_v3(TALLOC_CTX *mem_ctx, const char *string, const char *sep);
 char *sanitize_username(TALLOC_CTX *mem_ctx, const char *username);
 
-/* The following definitions come from lib/util_unistr.c  */
-
-void gfree_case_tables(void);
-void load_case_tables(void);
-size_t dos_PutUniCode(char *dst,const char *src, size_t len, bool null_terminate);
-char *skip_unibuf(char *src, size_t len);
-int rpcstr_push(void *dest, const char *src, size_t dest_len, int flags);
-int rpcstr_push_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *src);
-bool isvalid83_w(smb_ucs2_t c);
-size_t strlen_w(const smb_ucs2_t *src);
-size_t strnlen_w(const smb_ucs2_t *src, size_t max);
-smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
-smb_ucs2_t *strchr_wa(const smb_ucs2_t *s, char c);
-smb_ucs2_t *strrchr_w(const smb_ucs2_t *s, smb_ucs2_t c);
-smb_ucs2_t *strnrchr_w(const smb_ucs2_t *s, smb_ucs2_t c, unsigned int n);
-smb_ucs2_t *strstr_w(const smb_ucs2_t *s, const smb_ucs2_t *ins);
-bool strlower_w(smb_ucs2_t *s);
-bool strupper_w(smb_ucs2_t *s);
-void strnorm_w(smb_ucs2_t *s, int case_default);
-int strcmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
-int strncmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len);
-int strcasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b);
-int strncasecmp_w(const smb_ucs2_t *a, const smb_ucs2_t *b, size_t len);
-bool strequal_w(const smb_ucs2_t *s1, const smb_ucs2_t *s2);
-bool strnequal_w(const smb_ucs2_t *s1,const smb_ucs2_t *s2,size_t n);
-smb_ucs2_t *strdup_w(const smb_ucs2_t *src);
-smb_ucs2_t *strndup_w(const smb_ucs2_t *src, size_t len);
-smb_ucs2_t *strncpy_w(smb_ucs2_t *dest, const smb_ucs2_t *src, const size_t max);
-smb_ucs2_t *strncat_w(smb_ucs2_t *dest, const smb_ucs2_t *src, const size_t max);
-smb_ucs2_t *strcat_w(smb_ucs2_t *dest, const smb_ucs2_t *src);
-void string_replace_w(smb_ucs2_t *s, smb_ucs2_t oldc, smb_ucs2_t newc);
-bool trim_string_w(smb_ucs2_t *s, const smb_ucs2_t *front,
-                                 const smb_ucs2_t *back);
-int strcmp_wa(const smb_ucs2_t *a, const char *b);
-int strncmp_wa(const smb_ucs2_t *a, const char *b, size_t len);
-smb_ucs2_t *strpbrk_wa(const smb_ucs2_t *s, const char *p);
-smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins);
-int toupper_ascii(int c);
-int tolower_ascii(int c);
-int isupper_ascii(int c);
-int islower_ascii(int c);
-
 /* The following definitions come from lib/version.c  */
 
 const char *samba_version_string(void);
@@ -1439,7 +1094,7 @@ struct cli_state *get_ipc_connect(char *server,
                                struct sockaddr_storage *server_ss,
                                const struct user_auth_info *user_info);
 struct cli_state *get_ipc_connect_master_ip(TALLOC_CTX *ctx,
-                               struct ip_service *mb_ip,
+                               struct sockaddr_storage *mb_ip,
                                const struct user_auth_info *user_info,
                                char **pp_workgroup_out);
 struct cli_state *get_ipc_connect_master_ip_bcast(TALLOC_CTX *ctx,
@@ -1500,9 +1155,6 @@ bool cli_state_seqnum_remove(struct cli_state *cli,
                             uint16_t mid);
 bool cli_receive_smb(struct cli_state *cli);
 bool cli_send_smb(struct cli_state *cli);
-bool cli_send_smb_direct_writeX(struct cli_state *cli,
-                               const char *p,
-                               size_t extradata);
 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
 void cli_setup_packet(struct cli_state *cli);
 void cli_setup_bcc(struct cli_state *cli, void *p);
@@ -1962,13 +1614,6 @@ NTSTATUS cli_force_encryption(struct cli_state *c,
                        const char *password,
                        const char *domain);
 
-/* The following definitions come from libsmb/clikrb5.c  */
-
-bool unwrap_edata_ntstatus(TALLOC_CTX *mem_ctx, 
-                          DATA_BLOB *edata, 
-                          DATA_BLOB *edata_out);
-bool unwrap_pac(TALLOC_CTX *mem_ctx, DATA_BLOB *auth_data, DATA_BLOB *unwrapped_pac_data);
-
 /* The following definitions come from libsmb/clilist.c  */
 
 NTSTATUS cli_list_old(struct cli_state *cli,const char *Mask,uint16 attribute,
@@ -2062,9 +1707,6 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
                  void *priv, SMB_OFF_T *received);
 ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
                 off_t offset, size_t size);
-ssize_t cli_write(struct cli_state *cli,
-                uint16_t fnum, uint16 write_mode,
-                const char *buf, off_t offset, size_t size);
 NTSTATUS cli_smbwrite(struct cli_state *cli, uint16_t fnum, char *buf,
                      off_t offset, size_t size1, size_t *ptotal);
 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
@@ -2082,6 +1724,10 @@ struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
                                       off_t offset, size_t size);
 NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
 
+NTSTATUS cli_writeall(struct cli_state *cli, uint16_t fnum, uint16_t mode,
+                     const uint8_t *buf, off_t offset, size_t size,
+                     size_t *pwritten);
+
 struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                 struct cli_state *cli,
                                 uint16_t fnum, uint16_t mode,
@@ -2285,7 +1931,8 @@ NTSTATUS name_query(const char *name, int name_type,
                    int *num_addrs, uint8_t *flags);
 NTSTATUS name_resolve_bcast(const char *name,
                        int name_type,
-                       struct ip_service **return_iplist,
+                       TALLOC_CTX *mem_ctx,
+                       struct sockaddr_storage **return_iplist,
                        int *return_count);
 NTSTATUS resolve_wins(const char *name,
                int name_type,
@@ -2325,35 +1972,10 @@ bool get_dc_name(const char *domain,
                fstring srv_name,
                struct sockaddr_storage *ss_out);
 
-/* The following definitions come from libsmb/nmblib.c  */
-
-void debug_nmb_packet(struct packet_struct *p);
-void put_name(char *dest, const char *name, int pad, unsigned int name_type);
-char *nmb_namestr(const struct nmb_name *n);
-struct packet_struct *copy_packet(struct packet_struct *packet);
-void free_packet(struct packet_struct *packet);
-int packet_trn_id(struct packet_struct *p);
-struct packet_struct *parse_packet(char *buf,int length,
-                                  enum packet_type packet_type,
-                                  struct in_addr ip,
-                                  int port);
-struct packet_struct *read_packet(int fd,enum packet_type packet_type);
-void make_nmb_name( struct nmb_name *n, const char *name, int type);
-bool nmb_name_equal(struct nmb_name *n1, struct nmb_name *n2);
-int build_packet(char *buf, size_t buflen, struct packet_struct *p);
-bool send_packet(struct packet_struct *p);
-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, const char *In, char name_type);
-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  */
 
 const char *nt_errstr(NTSTATUS nt_code);
 const char *get_friendly_nt_error_msg(NTSTATUS nt_code);
-const char *get_nt_error_c_code(NTSTATUS nt_code);
 NTSTATUS nt_status_string_to_code(const char *nt_status_str);
 NTSTATUS nt_status_squash(NTSTATUS nt_status);
 
@@ -2464,237 +2086,6 @@ bool enumerate_domain_trusts( TALLOC_CTX *mem_ctx, const char *domain,
                                     struct dom_sid **sids );
 NTSTATUS change_trust_account_password( const char *domain, const char *remote_machine);
 
-/* The following definitions come from libsmb/unexpected.c  */
-
-struct nb_packet_server;
-struct nb_packet_reader;
-
-NTSTATUS nb_packet_server_create(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                int max_clients,
-                                struct nb_packet_server **presult);
-void nb_packet_dispatch(struct nb_packet_server *server,
-                       struct packet_struct *p);
-struct tevent_req *nb_packet_reader_send(TALLOC_CTX *mem_ctx,
-                                        struct tevent_context *ev,
-                                        enum packet_type type,
-                                        int trn_id,
-                                        const char *mailslot_name);
-NTSTATUS nb_packet_reader_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-                              struct nb_packet_reader **preader);
-struct tevent_req *nb_packet_read_send(TALLOC_CTX *mem_ctx,
-                                      struct tevent_context *ev,
-                                      struct nb_packet_reader *reader);
-NTSTATUS nb_packet_read_recv(struct tevent_req *req,
-                            struct packet_struct **ppacket);
-
-/* The following definitions come from locking/brlock.c  */
-
-bool brl_same_context(const struct lock_context *ctx1, 
-                            const struct lock_context *ctx2);
-NTSTATUS brl_lock_failed(files_struct *fsp, const struct lock_struct *lock, bool blocking_lock);
-void brl_init(bool read_only);
-void brl_shutdown(void);
-
-NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck,
-               struct lock_struct *plock,
-               bool blocking_lock);
-
-NTSTATUS brl_lock(struct messaging_context *msg_ctx,
-               struct byte_range_lock *br_lck,
-               uint64_t smblctx,
-               struct server_id pid,
-               br_off start,
-               br_off size, 
-               enum brl_type lock_type,
-               enum brl_flavour lock_flav,
-               bool blocking_lock,
-               uint64_t *psmblctx,
-               struct blocking_lock_record *blr);
-bool brl_unlock(struct messaging_context *msg_ctx,
-               struct byte_range_lock *br_lck,
-               uint64_t smblctx,
-               struct server_id pid,
-               br_off start,
-               br_off size,
-               enum brl_flavour lock_flav);
-bool brl_unlock_windows_default(struct messaging_context *msg_ctx,
-                              struct byte_range_lock *br_lck,
-                              const struct lock_struct *plock);
-bool brl_locktest(struct byte_range_lock *br_lck,
-               uint64_t smblctx,
-               struct server_id pid,
-               br_off start,
-               br_off size, 
-               enum brl_type lock_type,
-               enum brl_flavour lock_flav);
-NTSTATUS brl_lockquery(struct byte_range_lock *br_lck,
-               uint64_t *psmblctx,
-               struct server_id pid,
-               br_off *pstart,
-               br_off *psize, 
-               enum brl_type *plock_type,
-               enum brl_flavour lock_flav);
-bool brl_lock_cancel(struct byte_range_lock *br_lck,
-               uint64_t smblctx,
-               struct server_id pid,
-               br_off start,
-               br_off size,
-               enum brl_flavour lock_flav,
-               struct blocking_lock_record *blr);
-bool brl_lock_cancel_default(struct byte_range_lock *br_lck,
-               struct lock_struct *plock);
-void brl_close_fnum(struct messaging_context *msg_ctx,
-                   struct byte_range_lock *br_lck);
-int brl_forall(void (*fn)(struct file_id id, struct server_id pid,
-                         enum brl_type lock_type,
-                         enum brl_flavour lock_flav,
-                         br_off start, br_off size,
-                         void *private_data),
-              void *private_data);
-struct byte_range_lock *brl_get_locks(TALLOC_CTX *mem_ctx,
-                                       files_struct *fsp);
-struct byte_range_lock *brl_get_locks_readonly(files_struct *fsp);
-void brl_register_msgs(struct messaging_context *msg_ctx);
-
-/* The following definitions come from locking/locking.c  */
-
-const char *lock_type_name(enum brl_type lock_type);
-const char *lock_flav_name(enum brl_flavour lock_flav);
-void init_strict_lock_struct(files_struct *fsp,
-                               uint64_t smblctx,
-                               br_off start,
-                               br_off size,
-                               enum brl_type lock_type,
-                               struct lock_struct *plock);
-bool strict_lock_default(files_struct *fsp,
-                               struct lock_struct *plock);
-void strict_unlock_default(files_struct *fsp,
-                               struct lock_struct *plock);
-NTSTATUS query_lock(files_struct *fsp,
-                       uint64_t *psmblctx,
-                       uint64_t *pcount,
-                       uint64_t *poffset,
-                       enum brl_type *plock_type,
-                       enum brl_flavour lock_flav);
-struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
-                       files_struct *fsp,
-                       uint64_t smblctx,
-                       uint64_t count,
-                       uint64_t offset,
-                       enum brl_type lock_type,
-                       enum brl_flavour lock_flav,
-                       bool blocking_lock,
-                       NTSTATUS *perr,
-                       uint64_t *psmblctx,
-                       struct blocking_lock_record *blr);
-NTSTATUS do_unlock(struct messaging_context *msg_ctx,
-                       files_struct *fsp,
-                       uint64_t smblctx,
-                       uint64_t count,
-                       uint64_t offset,
-                       enum brl_flavour lock_flav);
-NTSTATUS do_lock_cancel(files_struct *fsp,
-                       uint64 smblctx,
-                       uint64_t count,
-                       uint64_t offset,
-                       enum brl_flavour lock_flav,
-                       struct blocking_lock_record *blr);
-void locking_close_file(struct messaging_context *msg_ctx,
-                       files_struct *fsp,
-                       enum file_close_type close_type);
-bool locking_init(void);
-bool locking_init_readonly(void);
-bool locking_end(void);
-char *share_mode_str(TALLOC_CTX *ctx, int num, const struct share_mode_entry *e);
-struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
-                                           const struct file_id id,
-                                           const char *servicepath,
-                                           const struct smb_filename *smb_fname,
-                                           const struct timespec *old_write_time);
-struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
-                                                 const struct file_id id);
-bool rename_share_filename(struct messaging_context *msg_ctx,
-                       struct share_mode_lock *lck,
-                       const char *servicepath,
-                       uint32_t orig_name_hash,
-                       uint32_t new_name_hash,
-                       const struct smb_filename *smb_fname);
-void get_file_infos(struct file_id id,
-                   uint32_t name_hash,
-                   bool *delete_on_close,
-                   struct timespec *write_time);
-bool is_valid_share_mode_entry(const struct share_mode_entry *e);
-bool is_deferred_open_entry(const struct share_mode_entry *e);
-bool is_unused_share_mode_entry(const struct share_mode_entry *e);
-void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
-                   uid_t uid, uint64_t mid, uint16 op_type);
-void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
-                      struct timeval request_time,
-                      struct server_id pid, struct file_id id);
-bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
-void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
-                            struct server_id pid);
-bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
-bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
-NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
-const struct security_unix_token *get_delete_on_close_token(struct share_mode_lock *lck, uint32_t name_hash);
-void set_delete_on_close_lck(files_struct *fsp,
-                       struct share_mode_lock *lck,
-                       bool delete_on_close,
-                       const struct security_unix_token *tok);
-bool set_delete_on_close(files_struct *fsp, bool delete_on_close, const struct security_unix_token *tok);
-bool is_delete_on_close_set(struct share_mode_lock *lck, uint32_t name_hash);
-bool set_sticky_write_time(struct file_id fileid, struct timespec write_time);
-bool set_write_time(struct file_id fileid, struct timespec write_time);
-int share_mode_forall(void (*fn)(const struct share_mode_entry *, const char *,
-                                const char *, void *),
-                     void *private_data);
-
-/* The following definitions come from locking/posix.c  */
-
-bool is_posix_locked(files_struct *fsp,
-                       uint64_t *pu_offset,
-                       uint64_t *pu_count,
-                       enum brl_type *plock_type,
-                       enum brl_flavour lock_flav);
-bool posix_locking_init(bool read_only);
-bool posix_locking_end(void);
-void reduce_windows_lock_ref_count(files_struct *fsp, unsigned int dcount);
-int fd_close_posix(struct files_struct *fsp);
-bool set_posix_lock_windows_flavour(files_struct *fsp,
-                       uint64_t u_offset,
-                       uint64_t u_count,
-                       enum brl_type lock_type,
-                       const struct lock_context *lock_ctx,
-                       const struct lock_struct *plocks,
-                       int num_locks,
-                       int *errno_ret);
-bool release_posix_lock_windows_flavour(files_struct *fsp,
-                               uint64_t u_offset,
-                               uint64_t u_count,
-                               enum brl_type deleted_lock_type,
-                               const struct lock_context *lock_ctx,
-                               const struct lock_struct *plocks,
-                               int num_locks);
-bool set_posix_lock_posix_flavour(files_struct *fsp,
-                       uint64_t u_offset,
-                       uint64_t u_count,
-                       enum brl_type lock_type,
-                       int *errno_ret);
-bool release_posix_lock_posix_flavour(files_struct *fsp,
-                               uint64_t u_offset,
-                               uint64_t u_count,
-                               const struct lock_context *lock_ctx,
-                               const struct lock_struct *plocks,
-                               int num_locks);
-
-/* The following definitions come from modules/vfs_default.c  */
-
-ssize_t vfswrap_llistxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size);
-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 param/loadparm.c  */
 
 char *lp_smb_ports(void);
@@ -3195,261 +2586,6 @@ void set_server_role(void);
 uint32 get_int_param( const char* param );
 char* get_string_param( const char* param );
 
-/* The following definitions come from profile/profile.c  */
-
-void set_profile_level(int level, struct server_id src);
-bool profile_setup(struct messaging_context *msg_ctx, bool rdonly);
-
-/* The following definitions come from librpc/rpc/rpc_common.c  */
-
-bool smb_register_ndr_interface(const struct ndr_interface_table *interface);
-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);
-
-/* The following definitions come from rpc_server/rpc_ncacn_np.c  */
-
-struct pipes_struct *make_internal_rpc_pipe_p(TALLOC_CTX *mem_ctx,
-                                             const struct ndr_syntax_id *syntax,
-                                             struct client_address *client_id,
-                                             const struct auth_serversupplied_info *session_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 *session_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,
-                               const struct auth_serversupplied_info *serversupplied_info,
-                               struct client_address *client_id,
-                               struct messaging_context *msg_ctx,
-                               struct rpc_pipe_client **presult);
-NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
-                                const struct ndr_syntax_id *syntax,
-                                const struct auth_serversupplied_info *session_info,
-                                struct client_address *client_id,
-                                struct messaging_context *msg_ctx,
-                                struct rpc_pipe_client **cli_pipe);
-
-/* The following definitions come from rpc_client/cli_pipe_schannel.c  */
-
-NTSTATUS get_schannel_session_key(struct cli_state *cli,
-                                 const char *domain,
-                                 uint32 *pneg_flags,
-                                 struct rpc_pipe_client **presult);
-
-/* The following definitions come from rpc_client/rpc_transport_np.c  */
-
-struct tevent_req *rpc_transport_np_init_send(TALLOC_CTX *mem_ctx,
-                                             struct event_context *ev,
-                                             struct cli_state *cli,
-                                             const struct ndr_syntax_id *abstract_syntax);
-NTSTATUS rpc_transport_np_init_recv(struct tevent_req *req,
-                                   TALLOC_CTX *mem_ctx,
-                                   struct rpc_cli_transport **presult);
-NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
-                              const struct ndr_syntax_id *abstract_syntax,
-                              struct rpc_cli_transport **presult);
-
-/* The following definitions come from rpc_client/rpc_transport_sock.c  */
-
-NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
-                                struct rpc_cli_transport **presult);
-
-/* The following definitions come from rpc_client/rpc_transport_tstream.c  */
-
-NTSTATUS rpc_transport_tstream_init(TALLOC_CTX *mem_ctx,
-                               struct tstream_context **stream,
-                               struct rpc_cli_transport **presult);
-struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
-
-/* The following definitions come from rpc_server/srv_eventlog_nt.c  */
-
-/* The following definitions come from rpc_server/rpc_handles.c  */
-
-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(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,
-                           const char *type, NTSTATUS *pstatus);
-#define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \
-       (_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \
-                                      (_pstatus))
-
-void *_policy_handle_find(struct pipes_struct *p,
-                         const struct policy_handle *hnd,
-                         uint32_t access_required, uint32_t *paccess_granted,
-                         const char *name, const char *location,
-                         NTSTATUS *pstatus);
-#define policy_handle_find(_p, _hnd, _access_required, _access_granted, _type, _pstatus) \
-       (_type *)_policy_handle_find((_p), (_hnd), (_access_required), \
-                                    (_access_granted), #_type, __location__, (_pstatus))
-
-
-/* The following definitions come from rpc_server/srv_rpc_register.c  */
-
-struct rpc_srv_callbacks {
-       bool (*init)(void *private_data);
-       bool (*shutdown)(void *private_data);
-       void *private_data;
-};
-
-NTSTATUS rpc_srv_register(int version, const char *clnt,
-                         const char *srv,
-                         const struct ndr_interface_table *iface,
-                         const struct api_struct *cmds, int size,
-                         const struct rpc_srv_callbacks *rpc_srv_cb);
-
-NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface);
-
-/* The following definitions come from rpc_server/srv_pipe.c  */
-
-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);
-
-/* 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 *session_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,
-                                struct fake_file_handle *handle,
-                                const uint8_t *data, size_t len);
-NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten);
-struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-                               struct fake_file_handle *handle,
-                               uint8_t *data, size_t len);
-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,
-                           uint32_t msg_type,
-                           struct server_id server_id,
-                           DATA_BLOB *data);
-void update_monitored_printq_cache(struct messaging_context *msg_ctx);
-
-/* The following definitions come from rpc_server/srv_srvsvc_nt.c  */
-
-char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname);
-
-/* The following definitions come from rpc_server/srv_svcctl_nt.c  */
-
-bool init_service_op_table( void );
-bool shutdown_service_op_table(void);
-
-/* The following definitions come from rpcclient/cmd_dfs.c  */
-
-
-/* The following definitions come from rpcclient/cmd_dssetup.c  */
-
-
-/* The following definitions come from rpcclient/cmd_echo.c  */
-
-
-/* The following definitions come from rpcclient/cmd_lsarpc.c  */
-
-
-/* The following definitions come from rpcclient/cmd_netlogon.c  */
-
-
-/* The following definitions come from rpcclient/cmd_ntsvcs.c  */
-
-
-/* The following definitions come from rpcclient/cmd_samr.c  */
-
-
-/* The following definitions come from rpcclient/cmd_shutdown.c  */
-
-
-/* The following definitions come from rpcclient/cmd_spoolss.c  */
-
-
-/* The following definitions come from rpcclient/cmd_srvsvc.c  */
-
-
-/* The following definitions come from rpcclient/cmd_test.c  */
-
-
-/* The following definitions come from rpcclient/cmd_wkssvc.c  */
-
-
-/* The following definitions come from rpcclient/rpcclient.c  */
-
-
-/* The following definitions come from services/svc_netlogon.c  */
-
-
-/* The following definitions come from services/svc_rcinit.c  */
-
-
-/* The following definitions come from services/svc_spoolss.c  */
-
-
-/* The following definitions come from services/svc_winreg.c  */
-
-
-/* The following definitions come from services/svc_wins.c  */
-
-
-/* The following definitions come from auth/user_util.c  */
-
-bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out);
-
-/* 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 lib/server_contexts.c  */
 struct tevent_context *server_event_context(void);
 void server_event_context_free(void);
@@ -3474,13 +2610,6 @@ int sessionid_traverse_read(int (*fn)(const char *key,
 char *stdin_new_passwd( void);
 char *get_pass( const char *prompt, bool stdin_get);
 
-/* The following definitions come from winbindd/nss_info.c  */
-
-
-/* The following definitions come from winbindd/nss_info_template.c  */
-
-NTSTATUS nss_info_template_init( void );
-
 /* The following definitions come from lib/avahi.c */
 
 struct AvahiPoll *tevent_avahi_poll(TALLOC_CTX *mem_ctx,
@@ -3511,7 +2640,7 @@ NTSTATUS smbsock_connect_recv(struct tevent_req *req, int *sock,
 NTSTATUS smbsock_connect(const struct sockaddr_storage *addr, uint16_t port,
                         const char *called_name, int called_type,
                         const char *calling_name, int calling_type,
-                        int *pfd, uint16_t *ret_port);
+                        int *pfd, uint16_t *ret_port, int sec_timeout);
 
 struct tevent_req *smbsock_any_connect_send(TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
@@ -3530,19 +2659,10 @@ NTSTATUS smbsock_any_connect(const struct sockaddr_storage *addrs,
                             int *calling_types,
                             size_t num_addrs,
                             uint16_t port,
+                            int sec_timeout,
                             int *pfd, size_t *chosen_index,
                             uint16_t *chosen_port);
 
-/* The following definitions come from rpc_server/srv_samr_nt.c */
-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 security_unix_token *unix_token,
-                           uint32_t *pacc_requested);
-
 /* The following definitions come from lib/util_wellknown.c  */
 
 bool sid_check_is_wellknown_domain(const struct dom_sid *sid, const char **name);
@@ -3608,7 +2728,4 @@ void contend_level2_oplocks_begin(files_struct *fsp,
 void contend_level2_oplocks_end(files_struct *fsp,
                                enum level2_contention_type type);
 
-/* FIXME */
-#include "smbd/proto.h"
-
 #endif /*  _PROTO_H_  */