#include "libcli/security/security_token.h"
#include "libcli/security/dom_sid.h"
#include "libcli/security/privileges.h"
+#include "librpc/gen_ndr/ndr_security.h"
/*
return a blank security token
return st;
}
+/****************************************************************************
+ Duplicate a SID token.
+****************************************************************************/
+
+struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *src)
+{
+ TALLOC_CTX *frame = NULL;
+ struct security_token *dst = NULL;
+ DATA_BLOB blob;
+ enum ndr_err_code ndr_err;
+
+ if (src == NULL) {
+ return NULL;
+ }
+
+ frame = talloc_stackframe();
+
+ ndr_err = ndr_push_struct_blob(
+ &blob,
+ frame,
+ src,
+ (ndr_push_flags_fn_t)ndr_push_security_token);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DBG_ERR("Failed to duplicate security_token ndr_push_security_token failed: %s\n",
+ ndr_errstr(ndr_err));
+ TALLOC_FREE(frame);
+ return NULL;
+ }
+
+ dst = talloc_zero(mem_ctx, struct security_token);
+ if (dst == NULL) {
+ DBG_ERR("talloc failed\n");
+ TALLOC_FREE(frame);
+ return NULL;
+ }
+
+ ndr_err = ndr_pull_struct_blob(
+ &blob,
+ dst,
+ dst,
+ (ndr_pull_flags_fn_t)ndr_pull_security_token);
+
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DBG_ERR("Failed to duplicate security_token ndr_pull_security_token "
+ "failed: %s\n",
+ ndr_errstr(ndr_err));
+ TALLOC_FREE(dst);
+ TALLOC_FREE(frame);
+ return NULL;
+ }
+
+ TALLOC_FREE(frame);
+ return dst;
+}
+
/****************************************************************************
prints a struct security_token to debug output.
****************************************************************************/
struct security_token *security_token_initialise(TALLOC_CTX *mem_ctx,
enum claims_evaluation_control evaluate_claims);
+struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *ptoken);
+
/****************************************************************************
prints a struct security_token to debug output.
****************************************************************************/
/* The following definitions come from lib/util_nttoken.c */
-struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *ptoken);
NTSTATUS merge_nt_token(TALLOC_CTX *mem_ctx,
const struct security_token *token_1,
const struct security_token *token_2,
#include "includes.h"
#include "../libcli/security/security.h"
-#include "librpc/gen_ndr/ndr_security.h"
-
-/****************************************************************************
- Duplicate a SID token.
-****************************************************************************/
-
-struct security_token *dup_nt_token(TALLOC_CTX *mem_ctx, const struct security_token *src)
-{
- TALLOC_CTX *frame = NULL;
- struct security_token *dst = NULL;
- DATA_BLOB blob;
- enum ndr_err_code ndr_err;
-
- if (src == NULL) {
- return NULL;
- }
-
- frame = talloc_stackframe();
-
- ndr_err = ndr_push_struct_blob(
- &blob,
- frame,
- src,
- (ndr_push_flags_fn_t)ndr_push_security_token);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DBG_ERR("Failed to duplicate security_token ndr_push_security_token failed: %s\n",
- ndr_errstr(ndr_err));
- TALLOC_FREE(frame);
- return NULL;
- }
-
- dst = talloc_zero(mem_ctx, struct security_token);
- if (dst == NULL) {
- DBG_ERR("talloc failed\n");
- TALLOC_FREE(frame);
- return NULL;
- }
-
- ndr_err = ndr_pull_struct_blob(
- &blob,
- dst,
- dst,
- (ndr_pull_flags_fn_t)ndr_pull_security_token);
-
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DBG_ERR("Failed to duplicate security_token ndr_pull_security_token "
- "failed: %s\n",
- ndr_errstr(ndr_err));
- TALLOC_FREE(dst);
- TALLOC_FREE(frame);
- return NULL;
- }
-
- TALLOC_FREE(frame);
- return dst;
-}
/****************************************************************************
merge NT tokens