diff options
author | Alexander Bokovoy <ab@samba.org> | 2017-05-05 15:37:20 +0300 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2017-05-17 23:02:09 +0200 |
commit | 2dbaade13a3b5917e05a60b274827cdf38fd3ced (patch) | |
tree | 1823160f030869b6f44d901dc9faced23f78ea1b /source3/include | |
parent | 6fbff7184e116c9afcbcd62a479b692154767b60 (diff) | |
download | samba-2dbaade13a3b5917e05a60b274827cdf38fd3ced.tar.gz |
libads: abstract out SASL wrapping code
Prepare for rebasing libads on top of libsmbldap.
To make libads using 'struct smbldap_state' instead of direct LDAP
structure, we need to abstract out libads logic from connection
handling. SASL wrapping does not really depend on availability of LDAP
handle and does not need direct access to ADS_STRUCT. As result, we'll
be able to move SASL wrapping code under smbldap once the latter is able
to pass settings that libads passes to the SASL wrapping.
Signed-off-by: Alexander Bokovoy <ab@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/include')
-rw-r--r-- | source3/include/ads.h | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/source3/include/ads.h b/source3/include/ads.h index cacb25ca325..2b25c1c6c29 100644 --- a/source3/include/ads.h +++ b/source3/include/ads.h @@ -9,13 +9,13 @@ #include "libads/ads_status.h" #include "smb_ldap.h" -struct ads_struct; +struct ads_saslwrap; struct ads_saslwrap_ops { const char *name; - ADS_STATUS (*wrap)(struct ads_struct *, uint8_t *buf, uint32_t len); - ADS_STATUS (*unwrap)(struct ads_struct *); - void (*disconnect)(struct ads_struct *); + ADS_STATUS (*wrap)(struct ads_saslwrap *, uint8_t *buf, uint32_t len); + ADS_STATUS (*unwrap)(struct ads_saslwrap *); + void (*disconnect)(struct ads_saslwrap *); }; enum ads_saslwrap_type { @@ -24,6 +24,37 @@ enum ads_saslwrap_type { ADS_SASLWRAP_TYPE_SEAL = 4 }; +struct ads_saslwrap { + /* expected SASL wrapping type */ + enum ads_saslwrap_type wrap_type; + /* SASL wrapping operations */ + const struct ads_saslwrap_ops *wrap_ops; +#ifdef HAVE_LDAP_SASL_WRAPPING + Sockbuf_IO_Desc *sbiod; /* lowlevel state for LDAP wrapping */ +#endif /* HAVE_LDAP_SASL_WRAPPING */ + TALLOC_CTX *mem_ctx; + void *wrap_private_data; + struct { + uint32_t ofs; + uint32_t needed; + uint32_t left; +#define ADS_SASL_WRAPPING_IN_MAX_WRAPPED 0x0FFFFFFF + uint32_t max_wrapped; + uint32_t min_wrapped; + uint32_t size; + uint8_t *buf; + } in; + struct { + uint32_t ofs; + uint32_t left; +#define ADS_SASL_WRAPPING_OUT_MAX_WRAPPED 0x00A00000 + uint32_t max_unwrapped; + uint32_t sig_size; + uint32_t size; + uint8_t *buf; + } out; +}; + typedef struct ads_struct { int is_mine; /* do I own this structure's memory? */ @@ -65,39 +96,12 @@ typedef struct ads_struct { /* info about the current LDAP connection */ #ifdef HAVE_LDAP + struct ads_saslwrap ldap_wrap_data; struct { LDAP *ld; struct sockaddr_storage ss; /* the ip of the active connection, if any */ time_t last_attempt; /* last attempt to reconnect, monotonic clock */ int port; - - enum ads_saslwrap_type wrap_type; - -#ifdef HAVE_LDAP_SASL_WRAPPING - Sockbuf_IO_Desc *sbiod; /* lowlevel state for LDAP wrapping */ -#endif /* HAVE_LDAP_SASL_WRAPPING */ - TALLOC_CTX *mem_ctx; - const struct ads_saslwrap_ops *wrap_ops; - void *wrap_private_data; - struct { - uint32_t ofs; - uint32_t needed; - uint32_t left; -#define ADS_SASL_WRAPPING_IN_MAX_WRAPPED 0x0FFFFFFF - uint32_t max_wrapped; - uint32_t min_wrapped; - uint32_t size; - uint8_t *buf; - } in; - struct { - uint32_t ofs; - uint32_t left; -#define ADS_SASL_WRAPPING_OUT_MAX_WRAPPED 0x00A00000 - uint32_t max_unwrapped; - uint32_t sig_size; - uint32_t size; - uint8_t *buf; - } out; } ldap; #endif /* HAVE_LDAP */ } ADS_STRUCT; |