summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-07-17 14:08:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:46 -0500
commit00b27d2d6933e29d9d89652e4f193562bb204f39 (patch)
tree16b956dd5a0498c1189bb7d733e8399efe079d01 /source3/libads
parentdc278f2d8f1878b31acedb0271fcf964b4952114 (diff)
downloadsamba-00b27d2d6933e29d9d89652e4f193562bb204f39.tar.gz
samba-00b27d2d6933e29d9d89652e4f193562bb204f39.tar.bz2
samba-00b27d2d6933e29d9d89652e4f193562bb204f39.zip
r23933: - implement ctrl SASL wrapping hook
- pass down sign or seal hooks - some sasl wrapping fixes metze (This used to be commit 8c64ca3394489b28034310fe64d6998e49827196)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/sasl_wrapping.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/source3/libads/sasl_wrapping.c b/source3/libads/sasl_wrapping.c
index 419557a7bb..77a71d8e96 100644
--- a/source3/libads/sasl_wrapping.c
+++ b/source3/libads/sasl_wrapping.c
@@ -98,7 +98,7 @@ static ber_slen_t ads_saslwrap_read(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_t
if (ads->ldap.in.ofs < 4) goto eagain;
- ads->ldap.in.needed = RIVAL(ads->ldap.in.buf, 4);
+ ads->ldap.in.needed = RIVAL(ads->ldap.in.buf, 0);
if (ads->ldap.in.needed > ads->ldap.in.max) {
errno = EINVAL;
return -1;
@@ -172,8 +172,8 @@ eagain:
static ber_slen_t ads_saslwrap_prepare_outbuf(ADS_STRUCT *ads, uint32 len)
{
- ads->ldap.out.ofs = 4;
- ads->ldap.out.left = 4;
+ ads->ldap.out.ofs = 0;
+ ads->ldap.out.left = 0;
ads->ldap.out.size = 4 + ads->ldap.out.sig_size + len;
ads->ldap.out.buf = talloc_array(ads->ldap.mem_ctx,
uint8, ads->ldap.out.size);
@@ -219,7 +219,7 @@ static ber_slen_t ads_saslwrap_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_
return -1;
}
- RSIVAL(ads->ldap.out.buf, 0, ads->ldap.out.size - 4);
+ RSIVAL(ads->ldap.out.buf, 0, ads->ldap.out.left - 4);
} else {
rlen = -1;
}
@@ -243,7 +243,22 @@ static ber_slen_t ads_saslwrap_write(Sockbuf_IO_Desc *sbiod, void *buf, ber_len_
static int ads_saslwrap_ctrl(Sockbuf_IO_Desc *sbiod, int opt, void *arg)
{
- return LBER_SBIOD_CTRL_NEXT(sbiod, opt, arg);
+ ADS_STRUCT *ads = (ADS_STRUCT *)sbiod->sbiod_pvt;
+ int ret;
+
+ switch (opt) {
+ case LBER_SB_OPT_DATA_READY:
+ if (ads->ldap.in.left > 0) {
+ return 1;
+ }
+ ret = LBER_SBIOD_CTRL_NEXT(sbiod, opt, arg);
+ break;
+ default:
+ ret = LBER_SBIOD_CTRL_NEXT(sbiod, opt, arg);
+ break;
+ }
+
+ return ret;
}
static int ads_saslwrap_close(Sockbuf_IO_Desc *sbiod)
@@ -260,7 +275,9 @@ static const Sockbuf_IO ads_saslwrap_sockbuf_io = {
ads_saslwrap_close /* sbi_close */
};
-ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads)
+ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads,
+ const struct ads_saslwrap_ops *ops,
+ void *private_data)
{
ADS_STATUS status;
Sockbuf *sb;
@@ -280,6 +297,9 @@ ADS_STATUS ads_setup_sasl_wrapping(ADS_STRUCT *ads)
return status;
}
+ ads->ldap.wrap_ops = ops;
+ ads->ldap.wrap_private_data = private_data;
+
return ADS_SUCCESS;
}