Add cli_posix_readlink() and a torture test for it.
[ira/wip.git] / source3 / include / proto.h
index d76ee08fd27fbefba54d1919ab8cd4615c1de8b5..342c1432eb336dbf620b135401e57353b3f2eb0b 100644 (file)
@@ -348,30 +348,23 @@ void init_iconv(void);
 size_t convert_string(charset_t from, charset_t to,
                      void const *src, size_t srclen, 
                      void *dest, size_t destlen, bool allow_bad_conv);
-bool convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
-                            void const *src, size_t srclen, void *dst,
-                            size_t *converted_size, bool allow_bad_conv);
 size_t unix_strupper(const char *src, size_t srclen, char *dest, size_t destlen);
-char *strdup_upper(const char *s);
 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 *strdup_lower(const char *s);
 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);
 size_t push_ascii_nstring(void *dest, const char *src);
-bool push_ascii_allocate(char **dest, const char *src, size_t *converted_size);
 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);
-bool push_ucs2_allocate(smb_ucs2_t **dest, const char *src,
-                       size_t *converted_size);
 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);
-bool push_utf8_allocate(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_base_talloc(TALLOC_CTX *ctx,
                        const void *base_ptr,
@@ -382,19 +375,19 @@ size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
 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_ucs2_allocate(char **dest, const smb_ucs2_t *src,
-                       size_t *converted_size);
 bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src,
                      size_t *converted_size);
-bool pull_utf8_allocate(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_fn(const char *function, unsigned int line,
-                     const void *base_ptr, uint16 flags2,
-                     void *dest, const char *src,
-                     size_t dest_len, int flags);
+size_t push_string_check_fn(const char *function, unsigned int line,
+                           void *dest, const char *src,
+                           size_t dest_len, int flags);
+size_t push_string_base(const char *function, unsigned int line,
+                       const char *base, uint16 flags2, 
+                       void *dest, const char *src,
+                       size_t dest_len, int flags);
 size_t pull_string_fn(const char *function,
                        unsigned int line,
                        const void *base_ptr,
@@ -604,6 +597,7 @@ bool revoke_privilege(const DOM_SID *sid, const SE_PRIV *priv_mask);
 bool revoke_all_privileges( DOM_SID *sid );
 bool revoke_privilege_by_name(DOM_SID *sid, const char *name);
 NTSTATUS privilege_create_account(const 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);
@@ -654,7 +648,6 @@ ssize_t drain_socket(int sockfd, size_t count);
 
 /* The following definitions come from lib/secdesc.c  */
 
-bool sec_desc_equal(SEC_DESC *s1, SEC_DESC *s2);
 uint32_t get_sec_info(const SEC_DESC *sd);
 SEC_DESC_BUF *sec_desc_merge(TALLOC_CTX *ctx, SEC_DESC_BUF *new_sdb, SEC_DESC_BUF *old_sdb);
 SEC_DESC *make_sec_desc(TALLOC_CTX *ctx,
@@ -1017,14 +1010,9 @@ void srv_put_dos_date2(char *buf,int offset, time_t unixdate);
 void srv_put_dos_date3(char *buf,int offset,time_t unixdate);
 void put_long_date_timespec(char *p, struct timespec ts);
 void put_long_date(char *p, time_t t);
-struct timespec get_create_timespec(const SMB_STRUCT_STAT *st,bool fake_dirs);
-struct timespec get_atimespec(const SMB_STRUCT_STAT *pst);
-void set_atimespec(SMB_STRUCT_STAT *pst, struct timespec ts);
-struct timespec get_mtimespec(const SMB_STRUCT_STAT *pst);
-void set_mtimespec(SMB_STRUCT_STAT *pst, struct timespec ts);
-struct timespec get_ctimespec(const SMB_STRUCT_STAT *pst);
-void set_ctimespec(SMB_STRUCT_STAT *pst, struct timespec ts);
 void dos_filetime_timespec(struct timespec *tsp);
+time_t make_unix_date2(const void *date_ptr, int zone_offset);
+time_t make_unix_date3(const void *date_ptr, int zone_offset);
 time_t srv_make_unix_date(const void *date_ptr);
 time_t srv_make_unix_date2(const void *date_ptr);
 time_t srv_make_unix_date3(const void *date_ptr);
@@ -1118,7 +1106,7 @@ 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);
-bool reinit_after_fork(struct messaging_context *msg_ctx,
+NTSTATUS reinit_after_fork(struct messaging_context *msg_ctx,
                       struct event_context *ev_ctx,
                       bool parent_longlived);
 bool yesno(const char *p);
@@ -1358,6 +1346,7 @@ char *print_canonical_sockaddr(TALLOC_CTX *ctx,
                        const struct sockaddr_storage *pss);
 void set_sockaddr_port(struct sockaddr *psa, uint16_t port);
 const char *client_name(int fd);
+int get_socket_port(int fd);
 const char *client_addr(int fd, char *addr, size_t addrlen);
 const char *client_socket_addr(int fd, char *addr, size_t addr_len);
 int client_socket_port(int fd);
@@ -1420,11 +1409,13 @@ int create_pipe_sock(const char *socket_dir,
                     mode_t dir_perms);
 const char *get_mydnsfullname(void);
 bool is_myname_or_ipaddr(const char *s);
-struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
-                                struct tevent_context *ev,
-                                int fd);
-ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-                     uint8_t **pbuf, int *perrno);
+struct tevent_req *getaddrinfo_send(TALLOC_CTX *mem_ctx,
+                                   struct tevent_context *ev,
+                                   struct fncall_context *ctx,
+                                   const char *node,
+                                   const char *service,
+                                   const struct addrinfo *hints);
+int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res);
 
 /* The following definitions come from lib/util_str.c  */
 
@@ -1560,13 +1551,8 @@ int rpcstr_pull_talloc(TALLOC_CTX *ctx,
                        void *src,
                        int src_len,
                        int flags);
-int rpcstr_pull_unistr2_fstring(char *dest, UNISTR2 *src);
-char *rpcstr_pull_unistr2_talloc(TALLOC_CTX *ctx, const UNISTR2 *src);
 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);
-void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen);
-char *unistr2_to_ascii_talloc(TALLOC_CTX *ctx, const UNISTR2 *str);
-const char *unistr2_static(const UNISTR2 *str);
 smb_ucs2_t toupper_w(smb_ucs2_t val);
 smb_ucs2_t tolower_w( smb_ucs2_t val );
 bool islower_w(smb_ucs2_t c);
@@ -1600,9 +1586,6 @@ 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 unistrlen(uint16 *s);
-int unistrcpy(uint16 *dst, uint16 *src);
-UNISTR2* ucs2_to_unistr2(TALLOC_CTX *ctx, UNISTR2* dst, smb_ucs2_t* src);
 int toupper_ascii(int c);
 int tolower_ascii(int c);
 int isupper_ascii(int c);
@@ -1690,6 +1673,7 @@ uint32 ads_uf2acb(uint32 uf);
 uint32 ads_uf2atype(uint32 uf);
 uint32 ads_gtype2atype(uint32 gtype);
 enum lsa_SidType ads_atype_map(uint32 atype);
+const char *ads_get_ldap_server_name(ADS_STRUCT *ads);
 
 /* The following definitions come from libads/authdata.c  */
 
@@ -1796,6 +1780,23 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
                                                const char *sitename,
                                                struct sockaddr_storage *pss);
 
+
+/* The following definitions come from libsmb/credentials.c  */
+
+char *credstr(const unsigned char *cred);
+void creds_server_init(uint32 neg_flags,
+                       struct dcinfo *dc,
+                       struct netr_Credential *clnt_chal,
+                       struct netr_Credential *srv_chal,
+                       const unsigned char mach_pw[16],
+                       struct netr_Credential *init_chal_out);
+bool netlogon_creds_server_check(const struct dcinfo *dc,
+                                const struct netr_Credential *rcv_cli_chal_in);
+bool netlogon_creds_server_step(struct dcinfo *dc,
+                               const struct netr_Authenticator *received_cred,
+                               struct netr_Authenticator *cred_out);
+void cred_hash3(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw);
+
 /* The following definitions come from libads/kerberos_keytab.c  */
 
 int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc);
@@ -1842,7 +1843,6 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
                                int scope, const char *expr, const char **attrs,
                                bool (*fn)(ADS_STRUCT *, char *, void **, void *), 
                                void *data_area);
-void ads_memfree(ADS_STRUCT *ads, void *mem);
 char *ads_parent_dn(const char *dn);
 ADS_MODLIST ads_init_mods(TALLOC_CTX *ctx);
 ADS_STATUS ads_mod_str(TALLOC_CTX *ctx, ADS_MODLIST *mods, 
@@ -1990,61 +1990,6 @@ ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_princip
 ADS_STATUS ads_guess_service_principal(ADS_STRUCT *ads,
                                       char **returned_principal);
 
-/* The following definitions come from libgpo/gpext/gpext.c  */
-
-struct gp_extension *get_gp_extension_list(void);
-NTSTATUS unregister_gp_extension(const char *name);
-NTSTATUS register_gp_extension(TALLOC_CTX *gpext_ctx,
-                              int version,
-                              const char *name,
-                              const char *guid,
-                              struct gp_extension_methods *methods);
-NTSTATUS gp_ext_info_add_entry(TALLOC_CTX *mem_ctx,
-                              const char *module,
-                              const char *ext_guid,
-                              struct gp_extension_reg_table *table,
-                              struct gp_extension_reg_info *info);
-NTSTATUS shutdown_gp_extensions(void);
-NTSTATUS init_gp_extensions(TALLOC_CTX *mem_ctx);
-NTSTATUS free_gp_extensions(void);
-void debug_gpext_header(int lvl,
-                       const char *name,
-                       uint32_t flags,
-                       struct GROUP_POLICY_OBJECT *gpo,
-                       const char *extension_guid,
-                       const char *snapin_guid);
-NTSTATUS process_gpo_list_with_extension(ADS_STRUCT *ads,
-                          TALLOC_CTX *mem_ctx,
-                          uint32_t flags,
-                          const struct nt_user_token *token,
-                          struct GROUP_POLICY_OBJECT *gpo_list,
-                          const char *extension_guid,
-                          const char *snapin_guid);
-NTSTATUS gpext_process_extension(ADS_STRUCT *ads,
-                                TALLOC_CTX *mem_ctx,
-                                uint32_t flags,
-                                const struct nt_user_token *token,
-                                struct registry_key *root_key,
-                                struct GROUP_POLICY_OBJECT *gpo,
-                                const char *extension_guid,
-                                const char *snapin_guid);
-
-/* The following definitions come from libgpo/gpo_fetch.c  */
-
-NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
-                                const char *file_sys_path,
-                                char **server,
-                                char **service,
-                                char **nt_path,
-                                char **unix_path);
-NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
-                        struct cli_state *cli,
-                        struct GROUP_POLICY_OBJECT *gpo);
-NTSTATUS gpo_get_sysvol_gpt_version(TALLOC_CTX *mem_ctx,
-                                   const char *unix_path,
-                                   uint32_t *sysvol_version,
-                                   char **display_name);
-
 /* The following definitions come from libgpo/gpo_filesync.c  */
 
 NTSTATUS gpo_copy_file(TALLOC_CTX *mem_ctx,
@@ -2063,41 +2008,6 @@ NTSTATUS parse_gpt_ini(TALLOC_CTX *mem_ctx,
                       uint32_t *version,
                       char **display_name);
 
-/* The following definitions come from libgpo/gpo_ldap.c  */
-
-bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
-                     const char *extension_raw,
-                     struct GP_EXT **gp_ext);
-ADS_STATUS ads_get_gpo_link(ADS_STRUCT *ads,
-                           TALLOC_CTX *mem_ctx,
-                           const char *link_dn,
-                           struct GP_LINK *gp_link_struct);
-ADS_STATUS ads_add_gpo_link(ADS_STRUCT *ads,
-                           TALLOC_CTX *mem_ctx,
-                           const char *link_dn,
-                           const char *gpo_dn,
-                           uint32_t gpo_opt);
-ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads,
-                              TALLOC_CTX *mem_ctx,
-                              const char *link_dn,
-                              const char *gpo_dn);
-ADS_STATUS ads_get_gpo(ADS_STRUCT *ads,
-                      TALLOC_CTX *mem_ctx,
-                      const char *gpo_dn,
-                      const char *display_name,
-                      const char *guid_name,
-                      struct GROUP_POLICY_OBJECT *gpo);
-ADS_STATUS ads_get_sid_token(ADS_STRUCT *ads,
-                            TALLOC_CTX *mem_ctx,
-                            const char *dn,
-                            struct nt_user_token **token);
-ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads,
-                           TALLOC_CTX *mem_ctx,
-                           const char *dn,
-                           uint32_t flags,
-                           const struct nt_user_token *token,
-                           struct GROUP_POLICY_OBJECT **gpo_list);
-
 /* The following definitions come from libgpo/gpo_reg.c  */
 
 struct nt_user_token *registry_create_system_token(TALLOC_CTX *mem_ctx);
@@ -2157,61 +2067,6 @@ WERROR reg_apply_registry_entry(TALLOC_CTX *mem_ctx,
                                const struct nt_user_token *token,
                                uint32_t flags);
 
-/* The following definitions come from libgpo/gpo_sec.c  */
-
-NTSTATUS gpo_apply_security_filtering(const struct GROUP_POLICY_OBJECT *gpo,
-                                     const struct nt_user_token *token);
-
-/* The following definitions come from libgpo/gpo_util.c  */
-
-const char *cse_gpo_guid_string_to_name(const char *guid);
-const char *cse_gpo_name_to_guid_string(const char *name);
-const char *cse_snapin_gpo_guid_string_to_name(const char *guid);
-void dump_gp_ext(struct GP_EXT *gp_ext, int debuglevel);
-void dump_gpo(ADS_STRUCT *ads,
-             TALLOC_CTX *mem_ctx,
-             struct GROUP_POLICY_OBJECT *gpo,
-             int debuglevel);
-void dump_gpo_list(ADS_STRUCT *ads,
-                  TALLOC_CTX *mem_ctx,
-                  struct GROUP_POLICY_OBJECT *gpo_list,
-                  int debuglevel);
-void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link);
-ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
-                            TALLOC_CTX *mem_ctx,
-                            const struct nt_user_token *token,
-                            struct registry_key *root_key,
-                            struct GROUP_POLICY_OBJECT *gpo,
-                            const char *extension_guid_filter,
-                            uint32_t flags);
-ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
-                               TALLOC_CTX *mem_ctx,
-                               const struct nt_user_token *token,
-                               struct GROUP_POLICY_OBJECT *gpo_list,
-                               const char *extensions_guid_filter,
-                               uint32_t flags);
-NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
-                          TALLOC_CTX *mem_ctx,
-                          uint32_t flags,
-                          struct GROUP_POLICY_OBJECT *gpo,
-                          struct cli_state **cli_out);
-NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
-                               TALLOC_CTX *mem_ctx,
-                               uint32_t flags,
-                               struct GROUP_POLICY_OBJECT *gpo_list);
-NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx,
-                          struct GROUP_POLICY_OBJECT *gpo,
-                          char **unix_path);
-char *gpo_flag_str(uint32_t flags);
-NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx,
-                     uint32_t flags,
-                     const char *filename,
-                     const char *suffix,
-                     const char **filename_out);
-ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads,
-                               TALLOC_CTX *mem_ctx,
-                               const char *dn,
-                               struct nt_user_token **token);
 
 #include "librpc/gen_ndr/ndr_dfs.h"
 #include "librpc/gen_ndr/ndr_dssetup.h"
@@ -2303,11 +2158,21 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
                           const char *pass, int passlen,
                           const char *ntpass, int ntpasslen,
                           const char *workgroup);
+struct tevent_req *cli_session_setup_guest_create(TALLOC_CTX *mem_ctx,
+                                                 struct event_context *ev,
+                                                 struct cli_state *cli,
+                                                 struct tevent_req **psmbreq);
 struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
                                                struct event_context *ev,
                                                struct cli_state *cli);
 NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
 bool cli_ulogoff(struct cli_state *cli);
+struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct cli_state *cli,
+                                       const char *share, const char *dev,
+                                       const char *pass, int passlen,
+                                       struct tevent_req **psmbreq);
 struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
                                      struct event_context *ev,
                                      struct cli_state *cli,
@@ -2467,27 +2332,83 @@ void cli_reset_error(struct cli_state *cli);
 
 /* The following definitions come from libsmb/clifile.c  */
 
-uint32 unix_perms_to_wire(mode_t perms);
-mode_t wire_perms_to_unix(uint32 perms);
+struct tevent_req *cli_posix_symlink_send(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct cli_state *cli,
+                                       const char *oldname,
+                                       const char *newname);
+NTSTATUS cli_posix_symlink_recv(struct tevent_req *req);
+NTSTATUS cli_posix_symlink(struct cli_state *cli,
+                       const char *oldname,
+                       const char *newname);
+struct tevent_req *cli_posix_readlink_send(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct cli_state *cli,
+                                       const char *fname,
+                                       size_t len);
+NTSTATUS cli_posix_readlink_recv(struct tevent_req *req, struct cli_state *cli,
+                               char *retpath, size_t len);
+NTSTATUS cli_posix_readlink(struct cli_state *cli, const char *fname,
+                       char *linkpath, size_t len);
+struct tevent_req *cli_posix_hardlink_send(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct cli_state *cli,
+                                       const char *oldname,
+                                       const char *newname);
+NTSTATUS cli_posix_hardlink_recv(struct tevent_req *req);
+NTSTATUS cli_posix_hardlink(struct cli_state *cli,
+                       const char *oldname,
+                       const char *newname);
+uint32_t unix_perms_to_wire(mode_t perms);
+mode_t wire_perms_to_unix(uint32_t perms);
 bool cli_unix_getfacl(struct cli_state *cli, const char *name, size_t *prb_size, char **retbuf);
 bool cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbuf);
-bool cli_unix_symlink(struct cli_state *cli, const char *oldname, const char *newname);
-bool cli_unix_hardlink(struct cli_state *cli, const char *oldname, const char *newname);
 bool cli_unix_chmod(struct cli_state *cli, const char *fname, mode_t mode);
 bool cli_unix_chown(struct cli_state *cli, const char *fname, uid_t uid, gid_t gid);
-bool cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
-bool cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
-bool cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
-bool cli_unlink_full(struct cli_state *cli, const char *fname, uint16 attrs);
-bool cli_unlink(struct cli_state *cli, const char *fname);
-bool cli_mkdir(struct cli_state *cli, const char *dname);
-bool cli_rmdir(struct cli_state *cli, const char *dname);
-int cli_nt_delete_on_close(struct cli_state *cli, int fnum, bool flag);
-int cli_nt_create_full(struct cli_state *cli, const char *fname,
-                uint32 CreatFlags, uint32 DesiredAccess,
-                uint32 FileAttributes, uint32 ShareAccess,
-                uint32 CreateDisposition, uint32 CreateOptions,
-                uint8 SecuityFlags);
+struct tevent_req *cli_rename_send(TALLOC_CTX *mem_ctx,
+                                struct event_context *ev,
+                                struct cli_state *cli,
+                                const char *fname_src,
+                                const char *fname_dst);
+NTSTATUS cli_rename_recv(struct tevent_req *req);
+NTSTATUS cli_rename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
+struct tevent_req *cli_ntrename_send(TALLOC_CTX *mem_ctx,
+                                struct event_context *ev,
+                                struct cli_state *cli,
+                                const char *fname_src,
+                                const char *fname_dst);
+NTSTATUS cli_ntrename_recv(struct tevent_req *req);
+NTSTATUS cli_ntrename(struct cli_state *cli, const char *fname_src, const char *fname_dst);
+
+struct tevent_req *cli_nt_hardlink_send(TALLOC_CTX *mem_ctx,
+                                struct event_context *ev,
+                                struct cli_state *cli,
+                                const char *fname_src,
+                                const char *fname_dst);
+NTSTATUS cli_nt_hardlink_recv(struct tevent_req *req);
+NTSTATUS cli_nt_hardlink(struct cli_state *cli, const char *fname_src, const char *fname_dst);
+
+struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
+                                struct event_context *ev,
+                                struct cli_state *cli,
+                                const char *fname,
+                                uint16_t mayhave_attrs);
+NTSTATUS cli_unlink_recv(struct tevent_req *req);
+NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_attrs);
+
+struct tevent_req *cli_mkdir_send(TALLOC_CTX *mem_ctx,
+                                 struct event_context *ev,
+                                 struct cli_state *cli,
+                                 const char *dname);
+NTSTATUS cli_mkdir_recv(struct tevent_req *req);
+NTSTATUS cli_mkdir(struct cli_state *cli, const char *dname);
+struct tevent_req *cli_rmdir_send(TALLOC_CTX *mem_ctx,
+                                 struct event_context *ev,
+                                 struct cli_state *cli,
+                                 const char *dname);
+NTSTATUS cli_rmdir_recv(struct tevent_req *req);
+NTSTATUS cli_rmdir(struct cli_state *cli, const char *dname);
+int cli_nt_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
 struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
                                     struct event_context *ev,
                                     struct cli_state *cli,
@@ -2510,7 +2431,6 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
                      uint32_t CreateOptions,
                      uint8_t SecurityFlags,
                      uint16_t *pfid);
-int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess);
 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
                            size_t str_len, size_t *pconverted_size);
 struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
@@ -2521,62 +2441,140 @@ struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
 struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                 struct cli_state *cli, const char *fname,
                                 int flags, int share_mode);
-NTSTATUS cli_open_recv(struct tevent_req *req, int *fnum);
-int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode);
+NTSTATUS cli_open_recv(struct tevent_req *req, uint16_t *fnum);
+NTSTATUS cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode, uint16_t *pfnum);
 struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
                                    struct event_context *ev,
-                                   struct cli_state *cli, int fnum,
+                                   struct cli_state *cli, uint16_t fnum,
                                    struct tevent_req **psubreq);
 struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
                                  struct event_context *ev,
-                                 struct cli_state *cli, int fnum);
+                                 struct cli_state *cli, uint16_t fnum);
 NTSTATUS cli_close_recv(struct tevent_req *req);
-bool cli_close(struct cli_state *cli, int fnum);
-bool cli_ftruncate(struct cli_state *cli, int fnum, uint64_t size);
-NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
-                     uint32 offset, uint32 len,
+NTSTATUS cli_close(struct cli_state *cli, uint16_t fnum);
+bool cli_ftruncate(struct cli_state *cli, uint16_t fnum, uint64_t size);
+NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
+                     uint32_t offset, uint32_t len,
                      int timeout, unsigned char locktype);
-bool cli_lock(struct cli_state *cli, int fnum,
-             uint32 offset, uint32 len, int timeout, enum brl_type lock_type);
-bool cli_unlock(struct cli_state *cli, int fnum, uint32 offset, uint32 len);
-bool cli_lock64(struct cli_state *cli, int fnum,
+bool cli_lock(struct cli_state *cli, uint16_t fnum,
+             uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type);
+bool cli_unlock(struct cli_state *cli, uint16_t fnum, uint32_t offset, uint32_t len);
+bool cli_lock64(struct cli_state *cli, uint16_t fnum,
                uint64_t offset, uint64_t len, int timeout, enum brl_type lock_type);
-bool cli_unlock64(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len);
-bool cli_posix_lock(struct cli_state *cli, int fnum,
+bool cli_unlock64(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
+bool cli_posix_lock(struct cli_state *cli, uint16_t fnum,
                        uint64_t offset, uint64_t len,
                        bool wait_lock, enum brl_type lock_type);
-bool cli_posix_unlock(struct cli_state *cli, int fnum, uint64_t offset, uint64_t len);
-bool cli_posix_getlock(struct cli_state *cli, int fnum, uint64_t *poffset, uint64_t *plen);
-bool cli_getattrE(struct cli_state *cli, int fd,
-                 uint16 *attr, SMB_OFF_T *size,
-                 time_t *change_time,
-                  time_t *access_time,
-                  time_t *write_time);
-bool cli_getatr(struct cli_state *cli, const char *fname,
-               uint16 *attr, SMB_OFF_T *size, time_t *write_time);
-bool cli_setattrE(struct cli_state *cli, int fd,
-                 time_t change_time,
-                  time_t access_time,
-                  time_t write_time);
-bool cli_setatr(struct cli_state *cli, const char *fname, uint16 attr, time_t t);
-bool cli_chkpath(struct cli_state *cli, const char *path);
-bool cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
+bool cli_posix_unlock(struct cli_state *cli, uint16_t fnum, uint64_t offset, uint64_t len);
+bool cli_posix_getlock(struct cli_state *cli, uint16_t fnum, uint64_t *poffset, uint64_t *plen);
+struct tevent_req *cli_getattrE_send(TALLOC_CTX *mem_ctx,
+                               struct event_context *ev,
+                               struct cli_state *cli,
+                                uint16_t fnum);
+NTSTATUS cli_getattrE_recv(struct tevent_req *req,
+                        uint16_t *attr,
+                        SMB_OFF_T *size,
+                        time_t *change_time,
+                        time_t *access_time,
+                        time_t *write_time);
+NTSTATUS cli_getattrE(struct cli_state *cli,
+                       uint16_t fnum,
+                       uint16_t *attr,
+                       SMB_OFF_T *size,
+                       time_t *change_time,
+                       time_t *access_time,
+                       time_t *write_time);
+struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
+                               struct event_context *ev,
+                               struct cli_state *cli,
+                               uint16_t fnum,
+                               time_t change_time,
+                               time_t access_time,
+                               time_t write_time);
+NTSTATUS cli_setattrE_recv(struct tevent_req *req);
+NTSTATUS cli_setattrE(struct cli_state *cli,
+                       uint16_t fnum,
+                       time_t change_time,
+                       time_t access_time,
+                       time_t write_time);
+struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
+                               struct event_context *ev,
+                               struct cli_state *cli,
+                               const char *fname);
+NTSTATUS cli_getatr_recv(struct tevent_req *req,
+                               uint16_t *attr,
+                               SMB_OFF_T *size,
+                               time_t *write_time);
+NTSTATUS cli_getatr(struct cli_state *cli,
+                       const char *fname,
+                       uint16_t *attr,
+                       SMB_OFF_T *size,
+                       time_t *write_time);
+struct tevent_req *cli_setatr_send(TALLOC_CTX *mem_ctx,
+                               struct event_context *ev,
+                               struct cli_state *cli,
+                               const char *fname,
+                               uint16_t attr,
+                               time_t mtime);
+NTSTATUS cli_setatr_recv(struct tevent_req *req);
+NTSTATUS cli_setatr(struct cli_state *cli,
+                const char *fname,
+                uint16_t attr,
+                time_t mtime);
+struct tevent_req *cli_chkpath_send(TALLOC_CTX *mem_ctx,
+                                 struct event_context *ev,
+                                 struct cli_state *cli,
+                                 const char *fname);
+NTSTATUS cli_chkpath_recv(struct tevent_req *req);
+NTSTATUS cli_chkpath(struct cli_state *cli, const char *path);
+struct tevent_req *cli_dskattr_send(TALLOC_CTX *mem_ctx,
+                                 struct event_context *ev,
+                                 struct cli_state *cli);
+NTSTATUS cli_dskattr_recv(struct tevent_req *req, int *bsize, int *total,
+                         int *avail);
+NTSTATUS cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
 int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path);
-NTSTATUS cli_raw_ioctl(struct cli_state *cli, int fnum, uint32 code, DATA_BLOB *blob);
+NTSTATUS cli_raw_ioctl(struct cli_state *cli, uint16_t fnum, uint32_t code, DATA_BLOB *blob);
 bool cli_set_ea_path(struct cli_state *cli, const char *path, const char *ea_name, const char *ea_val, size_t ea_len);
-bool cli_set_ea_fnum(struct cli_state *cli, int fnum, const char *ea_name, const char *ea_val, size_t ea_len);
+bool cli_set_ea_fnum(struct cli_state *cli, uint16_t fnum, const char *ea_name, const char *ea_val, size_t ea_len);
 bool cli_get_ea_list_path(struct cli_state *cli, const char *path,
                TALLOC_CTX *ctx,
                size_t *pnum_eas,
                struct ea_struct **pea_list);
-bool cli_get_ea_list_fnum(struct cli_state *cli, int fnum,
+bool cli_get_ea_list_fnum(struct cli_state *cli, uint16_t fnum,
                TALLOC_CTX *ctx,
                size_t *pnum_eas,
                struct ea_struct **pea_list);
-int cli_posix_open(struct cli_state *cli, const char *fname, int flags, mode_t mode);
-int cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
-bool cli_posix_unlink(struct cli_state *cli, const char *fname);
-int cli_posix_rmdir(struct cli_state *cli, const char *fname);
+struct tevent_req *cli_posix_open_send(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct cli_state *cli,
+                                       const char *fname,
+                                       int flags,
+                                       mode_t mode);
+NTSTATUS cli_posix_open_recv(struct tevent_req *req, uint16_t *pfnum);
+NTSTATUS cli_posix_open(struct cli_state *cli, const char *fname,
+                       int flags, mode_t mode, uint16_t *fnum);
+struct tevent_req *cli_posix_mkdir_send(TALLOC_CTX *mem_ctx,
+                                        struct event_context *ev,
+                                        struct cli_state *cli,
+                                        const char *fname,
+                                        mode_t mode);
+NTSTATUS cli_posix_mkdir_recv(struct tevent_req *req);
+NTSTATUS cli_posix_mkdir(struct cli_state *cli, const char *fname, mode_t mode);
+
+struct tevent_req *cli_posix_unlink_send(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct cli_state *cli,
+                                       const char *fname);
+NTSTATUS cli_posix_unlink_recv(struct tevent_req *req);
+NTSTATUS cli_posix_unlink(struct cli_state *cli, const char *fname);
+
+struct tevent_req *cli_posix_rmdir_send(TALLOC_CTX *mem_ctx,
+                                       struct event_context *ev,
+                                       struct cli_state *cli,
+                                       const char *fname);
+NTSTATUS cli_posix_rmdir_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+NTSTATUS cli_posix_rmdir(struct cli_state *cli, const char *fname);
 
 /* The following definitions come from libsmb/clifsinfo.c  */
 
@@ -2649,9 +2647,9 @@ struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
                                       struct cli_state *cli,
                                       uint16_t fnum, uint8_t level);
 NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
-bool cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level);
+NTSTATUS cli_oplock_ack(struct cli_state *cli, uint16_t fnum, unsigned char level);
 void cli_oplock_handler(struct cli_state *cli, 
-                       bool (*handler)(struct cli_state *, int, unsigned char));
+                       NTSTATUS (*handler)(struct cli_state *, uint16_t, unsigned char));
 
 /* The following definitions come from libsmb/cliprint.c  */
 
@@ -2659,11 +2657,11 @@ int cli_print_queue(struct cli_state *cli,
                    void (*fn)(struct print_job_info *));
 int cli_printjob_del(struct cli_state *cli, int job);
 int cli_spl_open(struct cli_state *cli, const char *fname, int flags, int share_mode);
-bool cli_spl_close(struct cli_state *cli, int fnum);
+bool cli_spl_close(struct cli_state *cli, uint16_t fnum);
 
 /* The following definitions come from libsmb/cliquota.c  */
 
-bool cli_get_quota_handle(struct cli_state *cli, int *quota_fnum);
+NTSTATUS cli_get_quota_handle(struct cli_state *cli, uint16_t *quota_fnum);
 void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list);
 bool cli_get_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
 bool cli_set_user_quota(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
@@ -2711,8 +2709,8 @@ bool cli_qpathinfo_streams(struct cli_state *cli, const char *fname,
                           TALLOC_CTX *mem_ctx,
                           unsigned int *pnum_streams,
                           struct stream_struct **pstreams);
-bool cli_qfilename(struct cli_state *cli, int fnum, char *name, size_t namelen);
-bool cli_qfileinfo(struct cli_state *cli, int fnum,
+bool cli_qfilename(struct cli_state *cli, uint16_t fnum, char *name, size_t namelen);
+bool cli_qfileinfo(struct cli_state *cli, uint16_t fnum,
                   uint16 *mode, SMB_OFF_T *size,
                   struct timespec *create_time,
                    struct timespec *access_time,
@@ -2721,7 +2719,7 @@ bool cli_qfileinfo(struct cli_state *cli, int fnum,
                    SMB_INO_T *ino);
 bool cli_qpathinfo_basic( struct cli_state *cli, const char *name,
                           SMB_STRUCT_STAT *sbuf, uint32 *attributes );
-bool cli_qfileinfo_test(struct cli_state *cli, int fnum, int level, char **poutdata, uint32 *poutlen);
+bool cli_qfileinfo_test(struct cli_state *cli, uint16_t fnum, int level, char **poutdata, uint32 *poutlen);
 NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstring alt_name);
 
 /* The following definitions come from libsmb/clirap2.c  */
@@ -2778,36 +2776,36 @@ int cli_NetConnectionEnum(struct cli_state *cli, const char *qualifier,
 
 struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
                                        struct event_context *ev,
-                                       struct cli_state *cli, int fnum,
+                                       struct cli_state *cli, uint16_t fnum,
                                        off_t offset, size_t size,
                                        struct tevent_req **psmbreq);
 struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
                                      struct event_context *ev,
-                                     struct cli_state *cli, int fnum,
+                                     struct cli_state *cli, uint16_t fnum,
                                      off_t offset, size_t size);
 NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
                            uint8_t **rcvbuf);
-struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx,
-                               struct event_context *ev,
-                               struct cli_state *cli,
-                               uint16_t fnum, off_t start_offset,
-                               SMB_OFF_T size, size_t window_size,
-                               NTSTATUS (*sink)(char *buf, size_t n,
-                                                void *priv),
-                               void *priv);
-NTSTATUS cli_pull_recv(struct async_req *req, SMB_OFF_T *received);
+struct tevent_req *cli_pull_send(TALLOC_CTX *mem_ctx,
+                                struct event_context *ev,
+                                struct cli_state *cli,
+                                uint16_t fnum, off_t start_offset,
+                                SMB_OFF_T size, size_t window_size,
+                                NTSTATUS (*sink)(char *buf, size_t n,
+                                                 void *priv),
+                                void *priv);
+NTSTATUS cli_pull_recv(struct tevent_req *req, SMB_OFF_T *received);
 NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
                  off_t start_offset, SMB_OFF_T size, size_t window_size,
                  NTSTATUS (*sink)(char *buf, size_t n, void *priv),
                  void *priv, SMB_OFF_T *received);
-ssize_t cli_read(struct cli_state *cli, int fnum, char *buf,
+ssize_t cli_read(struct cli_state *cli, uint16_t fnum, char *buf,
                 off_t offset, size_t size);
-ssize_t cli_readraw(struct cli_state *cli, int fnum, char *buf, off_t offset, size_t size);
+ssize_t cli_readraw(struct cli_state *cli, uint16_t fnum, char *buf, off_t offset, size_t size);
 ssize_t cli_write(struct cli_state *cli,
-                int fnum, uint16 write_mode,
+                uint16_t fnum, uint16 write_mode,
                 const char *buf, off_t offset, size_t size);
 ssize_t cli_smbwrite(struct cli_state *cli,
-                    int fnum, char *buf, off_t offset, size_t size1);
+                    uint16_t fnum, char *buf, off_t offset, size_t size1);
 struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
                                         struct event_context *ev,
                                         struct cli_state *cli, uint16_t fnum,
@@ -2823,14 +2821,14 @@ 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);
 
-struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-                               struct cli_state *cli,
-                               uint16_t fnum, uint16_t mode,
-                               off_t start_offset, size_t window_size,
-                               size_t (*source)(uint8_t *buf, size_t n,
-                                                void *priv),
-                               void *priv);
-NTSTATUS cli_push_recv(struct async_req *req);
+struct tevent_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+                                struct cli_state *cli,
+                                uint16_t fnum, uint16_t mode,
+                                off_t start_offset, size_t window_size,
+                                size_t (*source)(uint8_t *buf, size_t n,
+                                                 void *priv),
+                                void *priv);
+NTSTATUS cli_push_recv(struct tevent_req *req);
 NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
                  off_t start_offset, size_t window_size,
                  size_t (*source)(uint8_t *buf, size_t n, void *priv),
@@ -2838,9 +2836,9 @@ NTSTATUS cli_push(struct cli_state *cli, uint16_t fnum, uint16_t mode,
 
 /* The following definitions come from libsmb/clisecdesc.c  */
 
-SEC_DESC *cli_query_secdesc(struct cli_state *cli, int fnum, 
+SEC_DESC *cli_query_secdesc(struct cli_state *cli, uint16_t fnum, 
                            TALLOC_CTX *mem_ctx);
-bool cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd);
+bool cli_set_secdesc(struct cli_state *cli, uint16_t fnum, SEC_DESC *sd);
 
 /* The following definitions come from libsmb/clispnego.c  */
 
@@ -2948,31 +2946,6 @@ void delete_negative_conn_cache(const char *domain, const char *server);
 void flush_negative_conn_cache( void );
 void flush_negative_conn_cache_for_domain(const char *domain);
 
-/* The following definitions come from libsmb/credentials.c  */
-
-char *credstr(const unsigned char *cred);
-void creds_server_init(uint32 neg_flags,
-                       struct dcinfo *dc,
-                       struct netr_Credential *clnt_chal,
-                       struct netr_Credential *srv_chal,
-                       const unsigned char mach_pw[16],
-                       struct netr_Credential *init_chal_out);
-bool netlogon_creds_server_check(const struct dcinfo *dc,
-                                const struct netr_Credential *rcv_cli_chal_in);
-bool netlogon_creds_server_step(struct dcinfo *dc,
-                               const struct netr_Authenticator *received_cred,
-                               struct netr_Authenticator *cred_out);
-void creds_client_init(uint32 neg_flags,
-                       struct dcinfo *dc,
-                       struct netr_Credential *clnt_chal,
-                       struct netr_Credential *srv_chal,
-                       const unsigned char mach_pw[16],
-                       struct netr_Credential *init_chal_out);
-bool netlogon_creds_client_check(const struct dcinfo *dc,
-                                const struct netr_Credential *rcv_srv_chal_in);
-void netlogon_creds_client_step(struct dcinfo *dc,
-                               struct netr_Authenticator *next_cred_out);
-
 /* The following definitions come from ../librpc/rpc/dcerpc_error.c  */
 
 const char *dcerpc_errstr(TALLOC_CTX *mem_ctx, uint32_t fault_code);
@@ -3124,21 +3097,6 @@ 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);
 
-/* The following definitions come from libsmb/ntlm_check.c  */
-
-NTSTATUS ntlm_password_check(TALLOC_CTX *mem_ctx,
-                            const DATA_BLOB *challenge,
-                            const DATA_BLOB *lm_response,
-                            const DATA_BLOB *nt_response,
-                            const DATA_BLOB *lm_interactive_pwd,
-                            const DATA_BLOB *nt_interactive_pwd,
-                            const char *username, 
-                            const char *client_username, 
-                            const char *client_domain,
-                            const uint8 *lm_pw, const uint8 *nt_pw, 
-                            DATA_BLOB *user_sess_key, 
-                            DATA_BLOB *lm_sess_key);
-
 /* The following definitions come from libsmb/ntlmssp.c  */
 
 void debug_ntlmssp_flags(uint32 neg_flags);
@@ -3160,13 +3118,6 @@ DATA_BLOB ntlmssp_weaken_keys(NTLMSSP_STATE *ntlmssp_state, TALLOC_CTX *mem_ctx)
 NTSTATUS ntlmssp_server_start(NTLMSSP_STATE **ntlmssp_state);
 NTSTATUS ntlmssp_client_start(NTLMSSP_STATE **ntlmssp_state);
 
-/* The following definitions come from libsmb/ntlmssp_parse.c  */
-
-bool msrpc_gen(DATA_BLOB *blob,
-              const char *format, ...);
-bool msrpc_parse(const DATA_BLOB *blob,
-                const char *format, ...);
-
 /* The following definitions come from libsmb/ntlmssp_sign.c  */
 
 NTSTATUS ntlmssp_sign_packet(NTLMSSP_STATE *ntlmssp_state,
@@ -3250,84 +3201,6 @@ void srv_set_signing(struct smbd_server_connection *conn,
                     const DATA_BLOB user_session_key,
                     const DATA_BLOB response);
 
-/* The following definitions come from libsmb/smbdes.c  */
-
-void des_crypt56(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw);
-void E_P16(const unsigned char *p14,unsigned char *p16);
-void E_P24(const unsigned char *p21, const unsigned char *c8, unsigned char *p24);
-void D_P16(const unsigned char *p14, const unsigned char *in, unsigned char *out);
-void E_old_pw_hash( unsigned char *p14, const unsigned char *in, unsigned char *out);
-void des_crypt128(unsigned char out[8], const unsigned char in[8], const unsigned char key[16]);
-void des_crypt64(unsigned char out[8], const unsigned char in[8], const unsigned char key[8]);
-void des_crypt112(unsigned char out[8], const unsigned char in[8], const unsigned char key[14], int forw);
-void cred_hash3(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw);
-void des_crypt112_16(unsigned char out[16], unsigned char in[16], const unsigned char key[14], int forw);
-void SamOEMhash( unsigned char *data, const unsigned char key[16], size_t len);
-void SamOEMhashBlob( unsigned char *data, size_t len, DATA_BLOB *key);
-void sam_pwd_hash(unsigned int rid, const uchar *in, uchar *out, int forw);
-
-/* The following definitions come from libsmb/smbencrypt.c  */
-
-void SMBencrypt_hash(const uchar lm_hash[16], const uchar *c8, uchar p24[24]);
-bool SMBencrypt(const char *passwd, const uchar *c8, uchar p24[24]);
-void E_md4hash(const char *passwd, uchar p16[16]);
-void E_md5hash(const uchar salt[16], const uchar nthash[16], uchar hash_out[16]);
-bool E_deshash(const char *passwd, uchar p16[16]);
-void nt_lm_owf_gen(const char *pwd, uchar nt_p16[16], uchar p16[16]);
-bool ntv2_owf_gen(const uchar owf[16],
-                 const char *user_in, const char *domain_in,
-                 bool upper_case_domain, /* Transform the domain into UPPER case */
-                 uchar kr_buf[16]);
-void SMBOWFencrypt(const uchar passwd[16], const uchar *c8, uchar p24[24]);
-void NTLMSSPOWFencrypt(const uchar passwd[8], const uchar *ntlmchalresp, uchar p24[24]);
-void SMBNTencrypt_hash(const uchar nt_hash[16], uchar *c8, uchar *p24);
-void SMBNTencrypt(const char *passwd, uchar *c8, uchar *p24);
-void SMBOWFencrypt_ntv2(const uchar kr[16],
-                       const DATA_BLOB *srv_chal,
-                       const DATA_BLOB *cli_chal,
-                       uchar resp_buf[16]);
-void SMBsesskeygen_ntv2(const uchar kr[16],
-                       const uchar * nt_resp, uint8 sess_key[16]);
-void SMBsesskeygen_ntv1(const uchar kr[16],
-                       const uchar * nt_resp, uint8 sess_key[16]);
-void SMBsesskeygen_lm_sess_key(const uchar lm_hash[16],
-                       const uchar lm_resp[24], /* only uses 8 */ 
-                       uint8 sess_key[16]);
-DATA_BLOB NTLMv2_generate_names_blob(const char *hostname, 
-                                    const char *domain);
-bool SMBNTLMv2encrypt_hash(const char *user, const char *domain, const uchar nt_hash[16], 
-                     const DATA_BLOB *server_chal, 
-                     const DATA_BLOB *names_blob,
-                     DATA_BLOB *lm_response, DATA_BLOB *nt_response, 
-                     DATA_BLOB *user_session_key) ;
-bool SMBNTLMv2encrypt(const char *user, const char *domain, const char *password, 
-                     const DATA_BLOB *server_chal, 
-                     const DATA_BLOB *names_blob,
-                     DATA_BLOB *lm_response, DATA_BLOB *nt_response, 
-                     DATA_BLOB *user_session_key) ;
-bool encode_pw_buffer(uint8 buffer[516], const char *password, int string_flags);
-bool decode_pw_buffer(TALLOC_CTX *ctx,
-                       uint8 in_buffer[516],
-                       char **pp_new_pwrd,
-                       uint32 *new_pw_len,
-                       int string_flags);
-void encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532], const DATA_BLOB *psession_key);
-void sess_crypt_blob(DATA_BLOB *out, const DATA_BLOB *in, const DATA_BLOB *session_key, int forward);
-char *decrypt_trustdom_secret(uint8_t nt_hash[16], DATA_BLOB *data_in);
-void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx,
-                                       const char *pwd,
-                                       DATA_BLOB *session_key,
-                                       struct wkssvc_PasswordBuffer **pwd_buf);
-WERROR decode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx,
-                                         struct wkssvc_PasswordBuffer *pwd_buf,
-                                         DATA_BLOB *session_key,
-                                         char **pwd);
-DATA_BLOB decrypt_drsuapi_blob(TALLOC_CTX *mem_ctx,
-                              const DATA_BLOB *session_key,
-                              bool rcrypt,
-                              uint32_t rid,
-                              const DATA_BLOB *buffer);
-
 /* The following definitions come from libsmb/smberr.c  */
 
 const char *smb_dos_err_name(uint8 e_class, uint16 num);
@@ -4232,7 +4105,7 @@ bool lp_recursive_veto_delete(int );
 bool lp_dos_filemode(int );
 bool lp_dos_filetimes(int );
 bool lp_dos_filetime_resolution(int );
-bool lp_fake_dir_create_times(int );
+bool lp_fake_dir_create_times(void);
 bool lp_blocking_locks(int );
 bool lp_inherit_perms(int );
 bool lp_inherit_acls(int );
@@ -4309,6 +4182,8 @@ bool lp_string_is_valid_boolean(const char *parm_value);
 bool lp_invert_boolean(const char *str, const char **inverse_str);
 bool lp_canonicalize_boolean(const char *str, const char**canon_str);
 bool service_ok(int iService);
+bool process_registry_service(const char *service_name);
+bool process_registry_shares(void);
 bool lp_config_backend_is_registry(void);
 bool lp_config_backend_is_file(void);
 bool lp_file_list_changed(void);
@@ -4405,13 +4280,6 @@ int lp_min_receive_file_size(void);
 char* lp_perfcount_module(void);
 
 
-/* The following definitions come from param/params.c  */
-
-bool pm_process( const char *FileName,
-               bool (*sfunc)(const char *, void *),
-               bool (*pfunc)(const char *, const char *, void *),
-               void *userdata);
-
 /* The following definitions come from param/util.c  */
 
 uint32 get_int_param( const char* param );
@@ -4497,11 +4365,6 @@ bool get_trust_pw_hash(const char *domain, uint8 ret_pwd[16],
                       const char **account_name, uint32 *channel);
 struct samr_LogonHours get_logon_hours_from_pdb(TALLOC_CTX *mem_ctx,
                                                struct samu *pw);
-NTSTATUS smb_create_user(TALLOC_CTX *mem_ctx,
-                        uint32_t acct_flags,
-                        const char *account,
-                        struct passwd **passwd_p);
-
 /* The following definitions come from passdb/pdb_compat.c  */
 
 uint32 pdb_get_user_rid (const struct samu *sampass);
@@ -4759,11 +4622,11 @@ bool secrets_store_afs_keyfile(const char *cell, const struct afs_keyfile *keyfi
 bool secrets_fetch_afs_key(const char *cell, struct afs_key *result);
 void secrets_fetch_ipc_userpass(char **username, char **domain, char **password);
 bool secrets_store_schannel_session_info(TALLOC_CTX *mem_ctx,
-                               const char *remote_machine,
-                               const struct dcinfo *pdc);
+                                        const char *remote_machine,
+                                        const struct dcinfo *pdc);
 bool secrets_restore_schannel_session_info(TALLOC_CTX *mem_ctx,
-                               const char *remote_machine,
-                               struct dcinfo **ppdc);
+                                          const char *remote_machine,
+                                          struct dcinfo **ppdc);
 bool secrets_store_generic(const char *owner, const char *key, const char *secret);
 char *secrets_fetch_generic(const char *owner, const char *key);
 bool secrets_store_local_schannel_key(uint8_t schannel_key[16]);
@@ -4858,7 +4721,6 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
 int pack_devicemode(NT_DEVICEMODE *nt_devmode, uint8 *buf, int buflen);
 uint32 del_a_printer(const char *sharename);
 NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename);
-NT_DEVICEMODE *dup_nt_devicemode(NT_DEVICEMODE *nt_devicemode);
 void free_nt_devicemode(NT_DEVICEMODE **devmode_ptr);
 int unpack_devicemode(NT_DEVICEMODE **nt_devmode, const uint8 *buf, int buflen);
 int add_new_printer_key( NT_PRINTER_DATA *data, const char *name );
@@ -4877,7 +4739,7 @@ WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key );
 WERROR delete_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
 WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value, 
                            uint32 type, uint8 *data, int real_len );
-REGISTRY_VALUE* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
+struct regval_blob* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value );
 WERROR mod_a_printer(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
 bool set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level);
 bool del_driver_init(const char *drivername);
@@ -4982,12 +4844,9 @@ bool print_job_end(int snum, uint32 jobid, enum file_close_type close_type);
 int print_queue_status(int snum, 
                       print_queue_struct **ppqueue,
                       print_status_struct *status);
-bool print_queue_pause(struct auth_serversupplied_info *server_info, int snum,
-                      WERROR *errcode);
-bool print_queue_resume(struct auth_serversupplied_info *server_info, int snum,
-                       WERROR *errcode);
-bool print_queue_purge(struct auth_serversupplied_info *server_info, int snum,
-                      WERROR *errcode);
+WERROR print_queue_pause(struct auth_serversupplied_info *server_info, int snum);
+WERROR print_queue_resume(struct auth_serversupplied_info *server_info, int snum);
+WERROR print_queue_purge(struct auth_serversupplied_info *server_info, int snum);
 
 /* The following definitions come from printing/printing_db.c  */
 
@@ -5070,10 +4929,10 @@ WERROR regdb_transaction_cancel(void);
 int regdb_get_seqnum(void);
 bool regdb_store_keys(const char *key, struct regsubkey_ctr *ctr);
 int regdb_fetch_keys(const char *key, struct regsubkey_ctr *ctr);
-int regdb_fetch_values( const char* key, REGVAL_CTR *values );
-bool regdb_store_values( const char *key, REGVAL_CTR *values );
+int regdb_fetch_values(const char* key, struct regval_ctr *values);
+bool regdb_store_values(const char *key, struct regval_ctr *values);
 bool regdb_subkeys_need_update(struct regsubkey_ctr *subkeys);
-bool regdb_values_need_update(REGVAL_CTR *values);
+bool regdb_values_need_update(struct regval_ctr *values);
 
 /* The following definitions come from registry/reg_backend_hkpt_params.c  */
 
@@ -5102,26 +4961,31 @@ bool regdb_values_need_update(REGVAL_CTR *values);
 /* The following definitions come from registry/reg_cachehook.c  */
 
 WERROR reghook_cache_init(void);
-WERROR reghook_cache_add(const char *keyname, REGISTRY_OPS *ops);
-REGISTRY_OPS *reghook_cache_find(const char *keyname);
+WERROR reghook_cache_add(const char *keyname, struct registry_ops *ops);
+struct registry_ops *reghook_cache_find(const char *keyname);
 void reghook_dump_cache( int debuglevel );
 
 /* The following definitions come from registry/reg_dispatcher.c  */
 
-bool store_reg_keys( REGISTRY_KEY *key, struct regsubkey_ctr *subkeys );
-bool store_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val );
-WERROR create_reg_subkey(REGISTRY_KEY *key, const char *subkey);
-WERROR delete_reg_subkey(REGISTRY_KEY *key, const char *subkey);
-int fetch_reg_keys( REGISTRY_KEY *key, struct regsubkey_ctr *subkey_ctr );
-int fetch_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val );
-bool regkey_access_check( REGISTRY_KEY *key, uint32 requested, uint32 *granted,
-                         const struct nt_user_token *token );
-WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, REGISTRY_KEY *key,
+bool store_reg_keys(struct registry_key_handle *key,
+                   struct regsubkey_ctr *subkeys);
+bool store_reg_values(struct registry_key_handle *key, struct regval_ctr *val);
+WERROR create_reg_subkey(struct registry_key_handle *key, const char *subkey);
+WERROR delete_reg_subkey(struct registry_key_handle *key, const char *subkey);
+int fetch_reg_keys(struct registry_key_handle *key,
+                  struct regsubkey_ctr *subkey_ctr);
+int fetch_reg_values(struct registry_key_handle *key, struct regval_ctr *val);
+bool regkey_access_check(struct registry_key_handle *key, uint32 requested,
+                        uint32 *granted,
+                        const struct nt_user_token *token);
+WERROR regkey_get_secdesc(TALLOC_CTX *mem_ctx, struct registry_key_handle *key,
                          struct security_descriptor **psecdesc);
-WERROR regkey_set_secdesc(REGISTRY_KEY *key,
+WERROR regkey_set_secdesc(struct registry_key_handle *key,
                          struct security_descriptor *psecdesc);
-bool reg_subkeys_need_update(REGISTRY_KEY *key, struct regsubkey_ctr *subkeys);
-bool reg_values_need_update(REGISTRY_KEY *key, REGVAL_CTR *values);
+bool reg_subkeys_need_update(struct registry_key_handle *key,
+                            struct regsubkey_ctr *subkeys);
+bool reg_values_need_update(struct registry_key_handle *key,
+                           struct regval_ctr *values);
 
 /* The following definitions come from registry/reg_eventlog.c  */
 
@@ -5154,24 +5018,27 @@ WERROR regsubkey_ctr_delkey( struct regsubkey_ctr *ctr, const char *keyname );
 bool regsubkey_ctr_key_exists( struct regsubkey_ctr *ctr, const char *keyname );
 int regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr );
 char* regsubkey_ctr_specific_key( struct regsubkey_ctr *ctr, uint32 key_index );
-int regval_ctr_numvals( REGVAL_CTR *ctr );
-REGISTRY_VALUE* dup_registry_value( REGISTRY_VALUE *val );
-void free_registry_value( REGISTRY_VALUE *val );
-uint8* regval_data_p( REGISTRY_VALUE *val );
-uint32 regval_size( REGISTRY_VALUE *val );
-char* regval_name( REGISTRY_VALUE *val );
-uint32 regval_type( REGISTRY_VALUE *val );
-REGISTRY_VALUE* regval_ctr_specific_value( REGVAL_CTR *ctr, uint32 idx );
-bool regval_ctr_key_exists( REGVAL_CTR *ctr, const char *value );
-REGISTRY_VALUE *regval_compose(TALLOC_CTX *ctx, const char *name, uint16 type,
-                              const char *data_p, size_t size);
-int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type,
-                         const char *data_p, size_t size );
-int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val );
-int regval_ctr_delvalue( REGVAL_CTR *ctr, const char *name );
-REGISTRY_VALUE* regval_ctr_getvalue( REGVAL_CTR *ctr, const char *name );
-uint32 regval_dword( REGISTRY_VALUE *val );
-char *regval_sz(REGISTRY_VALUE *val);
+int regval_ctr_numvals(struct regval_ctr *ctr);
+struct regval_blob* dup_registry_value(struct regval_blob *val);
+void free_registry_value(struct regval_blob *val);
+uint8* regval_data_p(struct regval_blob *val);
+uint32 regval_size(struct regval_blob *val);
+char* regval_name(struct regval_blob *val);
+uint32 regval_type(struct regval_blob *val);
+struct regval_blob* regval_ctr_specific_value(struct regval_ctr *ctr,
+                                             uint32 idx);
+bool regval_ctr_key_exists(struct regval_ctr *ctr, const char *value);
+struct regval_blob *regval_compose(TALLOC_CTX *ctx, const char *name,
+                                  uint16 type,
+                                  const char *data_p, size_t size);
+int regval_ctr_addvalue(struct regval_ctr *ctr, const char *name, uint16 type,
+                       const char *data_p, size_t size);
+int regval_ctr_copyvalue(struct regval_ctr *ctr, struct regval_blob *val);
+int regval_ctr_delvalue(struct regval_ctr *ctr, const char *name);
+struct regval_blob* regval_ctr_getvalue(struct regval_ctr *ctr,
+                                       const char *name);
+uint32 regval_dword(struct regval_blob *val);
+char *regval_sz(struct regval_blob *val);
 
 /* The following definitions come from registry/reg_perfcount.c  */
 
@@ -5209,10 +5076,11 @@ size_t regval_build_multi_sz( char **values, uint16 **buffer );
 
 /* The following definitions come from registry/reg_util_legacy.c  */
 
-WERROR regkey_open_internal( TALLOC_CTX *ctx, REGISTRY_KEY **regkey,
-                            const char *path,
-                             const struct nt_user_token *token,
-                            uint32 access_desired );
+WERROR regkey_open_internal(TALLOC_CTX *ctx,
+                           struct registry_key_handle **regkey,
+                           const char *path,
+                           const struct nt_user_token *token,
+                           uint32 access_desired );
 
 /* The following definitions come from registry/regfio.c  */
 
@@ -5368,7 +5236,7 @@ NTSTATUS cli_rpc_pipe_open_schannel_with_key(struct cli_state *cli,
                                             const struct ndr_syntax_id *interface,
                                             enum pipe_auth_level auth_level,
                                             const char *domain,
-                                            const struct dcinfo *pdc,
+                                            struct netlogon_creds_CredentialState **pdc,
                                             struct rpc_pipe_client **presult);
 NTSTATUS cli_rpc_pipe_open_ntlmssp_auth_schannel(struct cli_state *cli,
                                                 const struct ndr_syntax_id *interface,
@@ -5399,11 +5267,11 @@ NTSTATUS rpc_pipe_open_local(TALLOC_CTX *mem_ctx,
 
 /* The following definitions come from rpc_client/rpc_transport_np.c  */
 
-struct async_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 async_req *req,
+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,
@@ -5413,13 +5281,13 @@ struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
 
 /* The following definitions come from rpc_client/rpc_transport_smbd.c  */
 
-struct async_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
-                                             struct event_context *ev,
-                                             void (*stdout_callback)(char *buf,
-                                                                     size_t len,
-                                                                     void *priv),
-                                             void *priv);
-NTSTATUS rpc_cli_smbd_conn_init_recv(struct async_req *req,
+struct tevent_req *rpc_cli_smbd_conn_init_send(TALLOC_CTX *mem_ctx,
+                                              struct event_context *ev,
+                                              void (*stdout_callback)(char *buf,
+                                                                      size_t len,
+                                                                      void *priv),
+                                              void *priv);
+NTSTATUS rpc_cli_smbd_conn_init_recv(struct tevent_req *req,
                                     TALLOC_CTX *mem_ctx,
                                     struct rpc_cli_smbd_conn **pconn);
 NTSTATUS rpc_cli_smbd_conn_init(TALLOC_CTX *mem_ctx,
@@ -5429,11 +5297,11 @@ NTSTATUS rpc_cli_smbd_conn_init(TALLOC_CTX *mem_ctx,
                                                        void *priv),
                                void *priv);
 
-struct async_req *rpc_transport_smbd_init_send(TALLOC_CTX *mem_ctx,
-                                              struct event_context *ev,
-                                              struct rpc_cli_smbd_conn *conn,
-                                              const struct ndr_syntax_id *abstract_syntax);
-NTSTATUS rpc_transport_smbd_init_recv(struct async_req *req,
+struct tevent_req *rpc_transport_smbd_init_send(TALLOC_CTX *mem_ctx,
+                                               struct event_context *ev,
+                                               struct rpc_cli_smbd_conn *conn,
+                                               const struct ndr_syntax_id *abstract_syntax);
+NTSTATUS rpc_transport_smbd_init_recv(struct tevent_req *req,
                                      TALLOC_CTX *mem_ctx,
                                      struct rpc_cli_transport **presult);
 NTSTATUS rpc_transport_smbd_init(TALLOC_CTX *mem_ctx,
@@ -5788,7 +5656,6 @@ bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint
 bool prs_uint16s(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
 bool prs_uint16uni(bool charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
 bool prs_uint32s(bool charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len);
-bool prs_unistr2(bool charmode, const char *name, prs_struct *ps, int depth, UNISTR2 *str);
 bool prs_unistr(const char *name, prs_struct *ps, int depth, UNISTR *str);
 bool prs_string(const char *name, prs_struct *ps, int depth, char *str, int max_buf_size);
 bool prs_string_alloc(const char *name, prs_struct *ps, int depth, const char **str);
@@ -5853,7 +5720,7 @@ bool smb_io_rpc_auth_schannel_chk(const char *desc, int auth_len,
                                 RPC_AUTH_SCHANNEL_CHK * chk,
                                prs_struct *ps, int depth);
 
-/* The following definitions come from rpc_server/srv_eventlog_lib.c  */
+/* The following definitions come from lib/eventlog/eventlog.c  */
 
 TDB_CONTEXT *elog_init_tdb( char *tdbfilename );
 char *elog_tdbname(TALLOC_CTX *ctx, const char *name );
@@ -5883,19 +5750,42 @@ NTSTATUS evlog_evt_entry_to_tdb_entry(TALLOC_CTX *mem_ctx,
 NTSTATUS evlog_tdb_entry_to_evt_entry(TALLOC_CTX *mem_ctx,
                                      const struct eventlog_Record_tdb *t,
                                      struct EVENTLOGRECORD *e);
+NTSTATUS evlog_convert_tdb_to_evt(TALLOC_CTX *mem_ctx,
+                                 ELOG_TDB *etdb,
+                                 DATA_BLOB *blob_p,
+                                 uint32_t *num_records_p);
 
 /* The following definitions come from rpc_server/srv_eventlog_nt.c  */
 
 /* The following definitions come from rpc_server/srv_lsa_hnd.c  */
 
+size_t num_pipe_handles(struct handle_list *list);
 bool init_pipe_handle_list(pipes_struct *p,
                           const struct ndr_syntax_id *syntax);
 bool create_policy_hnd(pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
-bool find_policy_by_hnd(pipes_struct *p, struct policy_handle *hnd, void **data_p);
+bool find_policy_by_hnd(pipes_struct *p, const struct policy_handle *hnd,
+                       void **data_p);
 bool close_policy_hnd(pipes_struct *p, struct policy_handle *hnd);
 void close_policy_by_pipe(pipes_struct *p);
 bool pipe_access_check(pipes_struct *p);
 
+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_pipe.c  */
 
 bool create_next_pdu(pipes_struct *p);
@@ -5943,6 +5833,28 @@ NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
 
 /* The following definitions come from rpc_server/srv_samr_util.c  */
 
+void copy_id2_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo2 *from);
+void copy_id4_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo4 *from);
+void copy_id6_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo6 *from);
+void copy_id8_to_sam_passwd(struct samu *to,
+                           struct samr_UserInfo8 *from);
+void copy_id10_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo10 *from);
+void copy_id11_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo11 *from);
+void copy_id12_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo12 *from);
+void copy_id13_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo13 *from);
+void copy_id14_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo14 *from);
+void copy_id16_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo16 *from);
+void copy_id17_to_sam_passwd(struct samu *to,
+                            struct samr_UserInfo17 *from);
 void copy_id18_to_sam_passwd(struct samu *to,
                             struct samr_UserInfo18 *from);
 void copy_id20_to_sam_passwd(struct samu *to,
@@ -6108,7 +6020,7 @@ SEC_DESC *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, NT_USER_TOKEN *
 bool svcctl_set_secdesc( TALLOC_CTX *ctx, const char *name, SEC_DESC *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 );
-REGVAL_CTR *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *token );
+struct regval_ctr *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *token );
 
 /* The following definitions come from services/svc_netlogon.c  */
 
@@ -6262,7 +6174,7 @@ void dptr_SeekDir(struct dptr_struct *dptr, long offset);
 long dptr_TellDir(struct dptr_struct *dptr);
 bool dptr_has_wild(struct dptr_struct *dptr);
 int dptr_dnum(struct dptr_struct *dptr);
-const char *dptr_ReadDirName(TALLOC_CTX *ctx,
+char *dptr_ReadDirName(TALLOC_CTX *ctx,
                        struct dptr_struct *dptr,
                        long *poffset,
                        SMB_STRUCT_STAT *pst);
@@ -6280,7 +6192,7 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                char **pp_fname_out,
                SMB_OFF_T *size,
                uint32 *mode,
-               time_t *date,
+               struct timespec *date,
                bool check_descend,
                bool ask_sharemode);
 bool is_visible_file(connection_struct *conn, const char *dir_path, const char *name, SMB_STRUCT_STAT *pst, bool use_veto);
@@ -6384,13 +6296,13 @@ int fsp_stat(files_struct *fsp, SMB_STRUCT_STAT *pst);
 
 /* The following definitions come from smbd/filename.c  */
 
+NTSTATUS get_full_smb_filename(TALLOC_CTX *ctx, const struct smb_filename *smb_fname,
+                             char **full_name);
 NTSTATUS unix_convert(TALLOC_CTX *ctx,
-                       connection_struct *conn,
-                       const char *orig_path,
-                       bool allow_wcard_last_component,
-                       char **pp_conv_path,
-                       char **pp_saved_last_component,
-                       SMB_STRUCT_STAT *pst);
+                     connection_struct *conn,
+                     const char *orig_path,
+                     struct smb_filename **smb_fname,
+                     uint32_t ucf_flags);
 NTSTATUS check_name(connection_struct *conn, const char *name);
 int get_real_filename(connection_struct *conn, const char *path,
                      const char *name, TALLOC_CTX *mem_ctx,
@@ -6405,6 +6317,10 @@ void file_close_pid(uint16 smbpid, int vuid);
 void file_init(void);
 void file_close_user(int vuid);
 void file_dump_open_table(void);
+struct files_struct *file_walk_table(
+       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);
@@ -6567,6 +6483,11 @@ NTSTATUS notify_add(struct notify_context *notify, struct notify_entry *e0,
                    void (*callback)(void *, const struct notify_event *), 
                    void *private_data);
 NTSTATUS notify_remove(struct notify_context *notify, void *private_data);
+NTSTATUS notify_remove_onelevel(struct notify_context *notify,
+                               const struct file_id *fid,
+                               void *private_data);
+void notify_onelevel(struct notify_context *notify, uint32_t action,
+                    uint32_t filter, struct file_id fid, const char *name);
 void notify_trigger(struct notify_context *notify,
                    uint32_t action, uint32_t filter, const char *path);
 
@@ -6677,6 +6598,7 @@ void release_file_oplock(files_struct *fsp);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);
 bool should_notify_deferred_opens(void);
+void break_level2_to_none_async(files_struct *fsp);
 void reply_to_oplock_break_requests(files_struct *fsp);
 void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx,
                                                      void *private_data,
@@ -7276,4 +7198,19 @@ void *avahi_start_register(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 
 /* Misc protos */
 
+struct fncall_context *fncall_context_init(TALLOC_CTX *mem_ctx,
+                                          int max_threads);
+struct tevent_req *fncall_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
+                              struct fncall_context *ctx,
+                              void (*fn)(void *private_data),
+                              void *private_data);
+int fncall_recv(struct tevent_req *req, int *perr);
+
+/* The following definitions come from rpc_server/srv_samr_nt.c */
+NTSTATUS access_check_object( SEC_DESC *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 *token,
+                               uint32_t *pacc_requested);
 #endif /*  _PROTO_H_  */