diff options
author | Samuel Cabrero <scabrero@samba.org> | 2019-10-03 16:44:36 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-10-18 16:07:36 +0000 |
commit | ae9956a65e6913a73dfa68e2b5deebfeaf52c0e5 (patch) | |
tree | 6c67482e036b867d7bd71e075a327ff4fc411ad3 /librpc | |
parent | b6c8afa98c5c1f9853b09fd83b039aacc79700db (diff) | |
download | samba-ae9956a65e6913a73dfa68e2b5deebfeaf52c0e5.tar.gz |
librpc: Move dcerpc_ncacn_push_auth from s4 librpc to common librpc
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'librpc')
-rw-r--r-- | librpc/rpc/dcerpc_util.c | 55 | ||||
-rw-r--r-- | librpc/rpc/rpc_common.h | 5 |
2 files changed, 60 insertions, 0 deletions
diff --git a/librpc/rpc/dcerpc_util.c b/librpc/rpc/dcerpc_util.c index 103a24e9284..3386d5e2f15 100644 --- a/librpc/rpc/dcerpc_util.c +++ b/librpc/rpc/dcerpc_util.c @@ -1350,3 +1350,58 @@ NTSTATUS dcerpc_generic_session_key(DATA_BLOB *session_key) session_key->length = 16; return NT_STATUS_OK; } + +/* + push a ncacn_packet into a blob, potentially with auth info +*/ +NTSTATUS dcerpc_ncacn_push_auth(DATA_BLOB *blob, + TALLOC_CTX *mem_ctx, + struct ncacn_packet *pkt, + struct dcerpc_auth *auth_info) +{ + struct ndr_push *ndr; + enum ndr_err_code ndr_err; + + ndr = ndr_push_init_ctx(mem_ctx); + if (!ndr) { + return NT_STATUS_NO_MEMORY; + } + + if (auth_info) { + pkt->auth_length = auth_info->credentials.length; + } else { + pkt->auth_length = 0; + } + + ndr_err = ndr_push_ncacn_packet(ndr, NDR_SCALARS|NDR_BUFFERS, pkt); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } + + if (auth_info) { +#if 0 + /* the s3 rpc server doesn't handle auth padding in + bind requests. Use zero auth padding to keep us + working with old servers */ + uint32_t offset = ndr->offset; + ndr_err = ndr_push_align(ndr, 16); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } + auth_info->auth_pad_length = ndr->offset - offset; +#else + auth_info->auth_pad_length = 0; +#endif + ndr_err = ndr_push_dcerpc_auth(ndr, NDR_SCALARS|NDR_BUFFERS, auth_info); + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + return ndr_map_error2ntstatus(ndr_err); + } + } + + *blob = ndr_push_blob(ndr); + + /* fill in the frag length */ + dcerpc_set_frag_length(blob, blob->length); + + return NT_STATUS_OK; +} diff --git a/librpc/rpc/rpc_common.h b/librpc/rpc/rpc_common.h index e109dfee4d6..7cd6d16bf58 100644 --- a/librpc/rpc/rpc_common.h +++ b/librpc/rpc/rpc_common.h @@ -447,4 +447,9 @@ struct ndr_syntax_id dcerpc_construct_bind_time_features(uint64_t features); NTSTATUS dcerpc_generic_session_key(DATA_BLOB *session_key); +NTSTATUS dcerpc_ncacn_push_auth(DATA_BLOB *blob, + TALLOC_CTX *mem_ctx, + struct ncacn_packet *pkt, + struct dcerpc_auth *auth_info); + #endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */ |