Merge branch 'master' of ssh://git.samba.org/data/git/samba into libcli-auth-merge...
[ira/wip.git] / source3 / include / proto.h
index f8a28ef1650b66a492d9aab2ebdac947eeeae620..9b27ca608a158aa3cfb456875ee7a966b38a58d9 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,
@@ -1358,6 +1351,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);
@@ -1788,6 +1782,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);
@@ -1834,7 +1845,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, 
@@ -2779,15 +2789,15 @@ struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
                                      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),
@@ -2815,14 +2825,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),
@@ -2940,31 +2950,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);
@@ -3116,21 +3101,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);
@@ -3152,13 +3122,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,
@@ -3242,84 +3205,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);
@@ -4751,11 +4636,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]);
@@ -4850,7 +4735,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 );
@@ -5360,7 +5244,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,
@@ -5391,11 +5275,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,
@@ -5405,13 +5289,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,
@@ -5421,11 +5305,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,
@@ -5844,7 +5728,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 );
@@ -5874,6 +5758,10 @@ 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  */