summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2008-09-03 11:52:54 -0400
committerSimo Sorce <idra@samba.org>2008-09-03 11:52:54 -0400
commitc5894e14771562bccd153a98610722632ca3956a (patch)
tree5ea00141df4ffa12bad3475fdafc525ffa4d92af /source3/include
parenta1de4e988d7780f687bb7ed2288faf3dfbb9da71 (diff)
parent84fca380f2040c53d20fff41972d2f4102183766 (diff)
downloadsamba-c5894e14771562bccd153a98610722632ca3956a.tar.gz
samba-c5894e14771562bccd153a98610722632ca3956a.tar.bz2
samba-c5894e14771562bccd153a98610722632ca3956a.zip
Merge branch 'v3-devel' of ssh://git.samba.org/data/git/samba into v3-devel
(This used to be commit 8e4dca3b9416d9b5e535bda5e4befc073bfc1641)
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/ads.h25
-rw-r--r--source3/include/async_smb.h126
-rw-r--r--source3/include/client.h41
-rw-r--r--source3/include/doserr.h1
-rw-r--r--source3/include/includes.h2
-rw-r--r--source3/include/proto.h39
-rw-r--r--source3/include/rpc_client.h48
7 files changed, 165 insertions, 117 deletions
diff --git a/source3/include/ads.h b/source3/include/ads.h
index 0d464b2d81..97faf0b6eb 100644
--- a/source3/include/ads.h
+++ b/source3/include/ads.h
@@ -372,9 +372,30 @@ typedef struct {
krb5_addresses *addrs;
#else
#error UNKNOWN_KRB5_ADDRESS_TYPE
-#endif
+#endif /* defined(HAVE_MAGIC_IN_KRB5_ADDRESS) && defined(HAVE_ADDRTYPE_IN_KRB5_ADDRESS) */
} smb_krb5_addresses;
-#endif
+
+#ifdef HAVE_KRB5_KEYBLOCK_KEYVALUE /* Heimdal */
+#define KRB5_KEY_TYPE(k) ((k)->keytype)
+#define KRB5_KEY_LENGTH(k) ((k)->keyvalue.length)
+#define KRB5_KEY_DATA(k) ((k)->keyvalue.data)
+#define KRB5_KEY_DATA_CAST void
+#else /* MIT */
+#define KRB5_KEY_TYPE(k) ((k)->enctype)
+#define KRB5_KEY_LENGTH(k) ((k)->length)
+#define KRB5_KEY_DATA(k) ((k)->contents)
+#define KRB5_KEY_DATA_CAST krb5_octet
+#endif /* HAVE_KRB5_KEYBLOCK_KEYVALUE */
+
+#ifdef HAVE_KRB5_KEYTAB_ENTRY_KEY /* MIT */
+#define KRB5_KT_KEY(k) (&(k)->key)
+#elif HAVE_KRB5_KEYTAB_ENTRY_KEYBLOCK /* Heimdal */
+#define KRB5_KT_KEY(k) (&(k)->keyblock)
+#else
+#error krb5_keytab_entry has no key or keyblock member
+#endif /* HAVE_KRB5_KEYTAB_ENTRY_KEY */
+
+#endif /* HAVE_KRB5 */
enum ads_extended_dn_flags {
ADS_EXTENDED_DN_HEX_STRING = 0,
diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h
index 19408be74b..e9e10023e3 100644
--- a/source3/include/async_smb.h
+++ b/source3/include/async_smb.h
@@ -17,23 +17,117 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef __ASYNC_SMB_H__
+#define __ASYNC_SMB_H__
+
#include "includes.h"
-/*
- * Create a fresh async smb request
+/**
+ * struct cli_request is the state holder for an async client request we sent
+ * to the server. It can consist of more than one struct async_req that we
+ * have to server if the application did a cli_chain_cork() and
+ * cli_chain_uncork()
*/
-struct async_req *cli_request_new(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint8_t num_words, size_t num_bytes,
- struct cli_request **preq);
+struct cli_request {
+ /**
+ * "prev" and "next" form the doubly linked list in
+ * cli_state->outstanding_requests
+ */
+ struct cli_request *prev, *next;
+
+ /**
+ * num_async: How many chained requests do we serve?
+ */
+ int num_async;
+
+ /**
+ * async: This is the list of chained requests that were queued up by
+ * cli_request_chain before we sent out this request
+ */
+ struct async_req **async;
+
+ /**
+ * The client connection for this request
+ */
+ struct cli_state *cli;
+
+ /**
+ * The enc_state to decrypt the reply
+ */
+ struct smb_trans_enc_state *enc_state;
+
+ /**
+ * The mid we used for this request. Mainly used to demultiplex on
+ * receiving replies.
+ */
+ uint16_t mid;
+
+ /**
+ * The bytes we have to ship to the server
+ */
+ char *outbuf;
+
+ /**
+ * How much from "outbuf" did we already send
+ */
+ size_t sent;
+
+ /**
+ * The reply comes in here. Its intended size is implicit by
+ * smb_len(), its current size can be read via talloc_get_size()
+ */
+ char *inbuf;
+
+ /**
+ * Specific requests might add stuff here. Maybe convert this to a
+ * private_pointer at some point.
+ */
+ union {
+ struct {
+ off_t ofs;
+ size_t size;
+ ssize_t received;
+ uint8_t *rcvbuf;
+ } read;
+ struct {
+ DATA_BLOB data;
+ uint16_t num_echos;
+ } echo;
+ } data;
+
+ /**
+ * For requests that don't follow the strict request/reply pattern
+ * such as the transaction request family and echo requests it is
+ * necessary to break the standard procedure in
+ * handle_incoming_pdu(). For a simple example look at
+ * cli_echo_recv_helper().
+ */
+ struct {
+ void (*fn)(struct async_req *req);
+ void *priv;
+ } recv_helper;
+};
/*
- * Convenience function to get the SMB part out of an async_req
+ * Ship a new smb request to the server
*/
-struct cli_request *cli_request_get(struct async_req *req);
+struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ struct cli_state *cli,
+ uint8_t smb_command,
+ uint8_t additional_flags,
+ uint8_t wct, const uint16_t *vwv,
+ uint16_t num_bytes, const uint8_t *bytes);
+
+bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
+ size_t size_hint);
+void cli_chain_uncork(struct cli_state *cli);
+
+NTSTATUS cli_pull_reply(struct async_req *req,
+ uint8_t *pwct, uint16_t **pvwv,
+ uint16_t *pnum_bytes, uint8_t **pbytes);
/*
* Fetch an error out of a NBT packet
@@ -47,16 +141,4 @@ NTSTATUS cli_pull_error(char *buf);
void cli_set_error(struct cli_state *cli, NTSTATUS status);
-/*
- * Create a temporary event context for use in the sync helper functions
- */
-
-struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx,
- struct cli_state *cli);
-
-/*
- * Attach an event context permanently to a cli_struct
- */
-
-NTSTATUS cli_add_event_ctx(struct cli_state *cli,
- struct event_context *event_ctx);
+#endif
diff --git a/source3/include/client.h b/source3/include/client.h
index 51ced9907f..9b564fc48e 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -204,35 +204,28 @@ struct cli_state {
bool force_dos_errors;
bool case_sensitive; /* False by default. */
- struct event_context *event_ctx;
+ /**
+ * fd_event is around while we have async requests outstanding or are
+ * building a chained request.
+ *
+ * (fd_event!=NULL) &&
+ * ((outstanding_request!=NULL)||(chain_accumulator!=NULL))
+ *
+ * should always be true, as well as the reverse: If both cli_request
+ * pointers are NULL, no fd_event is around.
+ */
struct fd_event *fd_event;
char *evt_inbuf;
+ /**
+ * A linked list of requests that are waiting for a reply
+ */
struct cli_request *outstanding_requests;
-};
-
-struct cli_request {
- struct cli_request *prev, *next;
- struct async_req *async;
-
- struct cli_state *cli;
-
- struct smb_trans_enc_state *enc_state;
- uint16_t mid;
-
- char *outbuf;
- size_t sent;
- char *inbuf;
-
- union {
- struct {
- off_t ofs;
- size_t size;
- ssize_t received;
- uint8_t *rcvbuf;
- } read;
- } data;
+ /**
+ * The place to build up the list of chained requests.
+ */
+ struct cli_request *chain_accumulator;
};
typedef struct file_info {
diff --git a/source3/include/doserr.h b/source3/include/doserr.h
index 9dd20e87e7..c901df28e4 100644
--- a/source3/include/doserr.h
+++ b/source3/include/doserr.h
@@ -214,6 +214,7 @@
#define WERR_GROUP_EXISTS W_ERROR(1318)
#define WERR_MEMBER_IN_GROUP W_ERROR(1320)
#define WERR_USER_NOT_IN_GROUP W_ERROR(1321)
+#define WERR_WRONG_PASSWORD W_ERROR(1323)
#define WERR_PASSWORD_RESTRICTION W_ERROR(1325)
#define WERR_LOGON_FAILURE W_ERROR(1326)
#define WERR_NO_SUCH_DOMAIN W_ERROR(1355)
diff --git a/source3/include/includes.h b/source3/include/includes.h
index fa385cba2a..958e7cba1f 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -1234,7 +1234,7 @@ krb5_error_code smb_krb5_mk_error(krb5_context context,
krb5_error_code error_code,
const krb5_principal server,
krb5_data *reply);
-krb5_enctype smb_get_enctype_from_kt_entry(const krb5_keytab_entry *kt_entry);
+krb5_enctype smb_get_enctype_from_kt_entry(krb5_keytab_entry *kt_entry);
krb5_error_code smb_krb5_enctype_to_string(krb5_context context,
krb5_enctype enctype,
char **etype_s);
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d757b2db80..a81375c2db 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1185,7 +1185,6 @@ 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);
-time_t get_create_time(const SMB_STRUCT_STAT *st,bool fake_dirs);
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);
@@ -4202,21 +4201,6 @@ bool asn1_write_enumerated(ASN1_DATA *data, uint8 v);
bool ber_write_OID_String(DATA_BLOB *blob, const char *OID);
bool ber_read_OID_String(TALLOC_CTX *mem_ctx, DATA_BLOB blob, const char **OID);
-/* The following definitions come from libsmb/async_smb.c */
-
-NTSTATUS cli_pull_error(char *buf);
-void cli_set_error(struct cli_state *cli, NTSTATUS status);
-struct async_req *cli_request_new(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct cli_state *cli,
- uint8_t num_words, size_t num_bytes,
- struct cli_request **preq);
-struct cli_request *cli_request_get(struct async_req *req);
-struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx,
- struct cli_state *cli);
-NTSTATUS cli_add_event_ctx(struct cli_state *cli,
- struct event_context *event_ctx);
-
/* The following definitions come from libsmb/cliconnect.c */
ADS_STATUS cli_session_setup_spnego(struct cli_state *cli, const char *user,
@@ -4354,8 +4338,11 @@ void cli_sockopt(struct cli_state *cli, const char *options);
uint16 cli_setpid(struct cli_state *cli, uint16 pid);
bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
bool cli_send_keepalive(struct cli_state *cli);
-bool cli_echo(struct cli_state *cli, uint16 num_echos,
- unsigned char *data, size_t length);
+struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli, uint16_t num_echos,
+ DATA_BLOB data);
+NTSTATUS cli_echo_recv(struct async_req *req);
+NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
/* The following definitions come from libsmb/clierror.c */
@@ -4394,7 +4381,14 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
uint32 CreateDisposition, uint32 CreateOptions,
uint8 SecuityFlags);
int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess);
+struct async_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 async_req *req, int *fnum);
int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode);
+struct async_req *cli_close_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+ struct cli_state *cli, int fnum);
+NTSTATUS cli_close_recv(struct async_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,
@@ -4628,11 +4622,14 @@ int cli_NetConnectionEnum(struct cli_state *cli, const char *qualifier,
/* The following definitions come from libsmb/clireadwrite.c */
struct async_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
struct cli_state *cli, int fnum,
off_t offset, size_t size);
NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received,
uint8_t **rcvbuf);
-struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+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,
@@ -5003,7 +5000,7 @@ void pwd_get_cleartext(struct pwd_info *pwd, fstring clr);
bool netsamlogon_cache_init(void);
bool netsamlogon_cache_shutdown(void);
-void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, struct netr_SamInfo3 *info3);
+void netsamlogon_clear_cached_user(struct netr_SamInfo3 *info3);
bool netsamlogon_cache_store(const char *username, struct netr_SamInfo3 *info3);
struct netr_SamInfo3 *netsamlogon_cache_get(TALLOC_CTX *mem_ctx, const DOM_SID *user_sid);
bool netsamlogon_cache_have(const DOM_SID *user_sid);
@@ -7829,6 +7826,8 @@ uint32 prs_data_size(prs_struct *ps);
uint32 prs_offset(prs_struct *ps);
bool prs_set_offset(prs_struct *ps, uint32 offset);
bool prs_append_prs_data(prs_struct *dst, prs_struct *src);
+bool prs_append_some_data(prs_struct *dst, void *src_base, uint32_t start,
+ uint32_t len);
bool prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len);
bool prs_copy_data_in(prs_struct *dst, const char *src, uint32 len);
bool prs_copy_data_out(char *dst, prs_struct *src, uint32 len);
diff --git a/source3/include/rpc_client.h b/source3/include/rpc_client.h
index d1af6f958d..684044b871 100644
--- a/source3/include/rpc_client.h
+++ b/source3/include/rpc_client.h
@@ -42,54 +42,6 @@
/* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */
-#define CLI_DO_RPC_INTERNAL( pcli, ctx, interface, opnum, q_in, r_out, \
- q_ps, r_ps, q_io_fn, r_io_fn, default_error, copy_sess_key ) \
-{\
- SMB_ASSERT(ndr_syntax_id_equal(&pcli->abstract_syntax, interface)); \
- if (!prs_init( &q_ps, RPC_MAX_PDU_FRAG_LEN, ctx, MARSHALL )) { \
- return NT_STATUS_NO_MEMORY;\
- }\
- prs_init_empty( &r_ps, ctx, UNMARSHALL );\
- if ( copy_sess_key) prs_set_session_key(&q_ps, (const char *)pcli->dc->sess_key);\
- if ( q_io_fn("", &q_in, &q_ps, 0) ) {\
- NTSTATUS _smb_pipe_stat_ = rpc_api_pipe_req(pcli, opnum, &q_ps, &r_ps); \
- if (!NT_STATUS_IS_OK(_smb_pipe_stat_)) {\
- prs_mem_free( &q_ps );\
- prs_mem_free( &r_ps );\
- return _smb_pipe_stat_;\
- }\
- if ( copy_sess_key ) prs_set_session_key(&r_ps, (const char *)pcli->dc->sess_key);\
- if (!r_io_fn("", &r_out, &r_ps, 0)) {\
- prs_mem_free( &q_ps );\
- prs_mem_free( &r_ps );\
- return default_error;\
- }\
- } else {\
- prs_mem_free( &q_ps );\
- prs_mem_free( &r_ps );\
- return default_error;\
- }\
- prs_mem_free( &q_ps );\
- prs_mem_free( &r_ps );\
-}
-
-#define CLI_DO_RPC_COPY_SESS_KEY( pcli, ctx, p_idx, opnum, q_in, r_out, \
- q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
-{\
- CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \
- q_ps, r_ps, q_io_fn, r_io_fn, default_error, True ); \
-}
-
-#define CLI_DO_RPC( pcli, ctx, p_idx, opnum, q_in, r_out, \
- q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
-{\
- CLI_DO_RPC_INTERNAL( pcli, ctx, p_idx, opnum, q_in, r_out, \
- q_ps, r_ps, q_io_fn, r_io_fn, default_error, False ); \
-}
-
-
-/* Arrrgg. Same but with WERRORS. Needed for registry code. */
-
#define CLI_DO_RPC_WERR( pcli, ctx, interface, opnum, q_in, r_out, \
q_ps, r_ps, q_io_fn, r_io_fn, default_error ) \
{\