]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
librpc: Move dcerpc_ncacn_push_auth from s4 librpc to common librpc
authorSamuel Cabrero <scabrero@samba.org>
Thu, 3 Oct 2019 14:44:36 +0000 (16:44 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 18 Oct 2019 16:07:36 +0000 (16:07 +0000)
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
librpc/rpc/dcerpc_util.c
librpc/rpc/rpc_common.h
source4/librpc/rpc/dcerpc_util.c

index 103a24e92844c7fe2ce35482065c0f5a0dec2422..3386d5e2f15259c5805bb459205448077343dce3 100644 (file)
@@ -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;
+}
index e109dfee4d6d18ad84f3417bbd47abe8609b3eff..7cd6d16bf58e53a32d41bc3e702970aaf58d1d99 100644 (file)
@@ -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__ */
index f2db5875af35278862d75722cdf13f25e5cf0e4f..b856ebe5620311cb8bd1563915a9f12e6a9b9def 100644 (file)
@@ -49,62 +49,6 @@ const struct ndr_interface_call *dcerpc_iface_find_call(const struct ndr_interfa
        return NULL;
 }
 
-/* 
-   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;
-}
-
-
 struct epm_map_binding_state {
        struct dcerpc_binding *binding;
        const struct ndr_interface_table *table;