s4:rpc_server/backupkey: make use dcesrv_call_session_info()
authorStefan Metzmacher <metze@samba.org>
Sat, 3 Nov 2018 00:19:51 +0000 (01:19 +0100)
committerJeremy Allison <jra@samba.org>
Sat, 12 Jan 2019 02:13:32 +0000 (03:13 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/rpc_server/backupkey/dcesrv_backupkey.c
source4/rpc_server/backupkey/dcesrv_backupkey_heimdal.c

index fd9c101..10caf24 100644 (file)
@@ -524,6 +524,8 @@ static WERROR bkrp_client_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                                            struct bkrp_BackupKey *r,
                                            struct ldb_context *ldb_ctx)
 {
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
        struct bkrp_client_side_wrapped uncrypt_request;
        DATA_BLOB blob;
        enum ndr_err_code ndr_err;
@@ -659,7 +661,7 @@ static WERROR bkrp_client_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                                                           uncrypted_secretv2.payload_key,
                                                           uncrypt_request.access_check,
                                                           uncrypt_request.access_check_len,
-                                                          dce_call->conn->auth_state.session_info);
+                                                          session_info);
                        if (!W_ERROR_IS_OK(werr)) {
                                return werr;
                        }
@@ -702,7 +704,7 @@ static WERROR bkrp_client_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                                                           uncrypted_secretv3.payload_key,
                                                           uncrypt_request.access_check,
                                                           uncrypt_request.access_check_len,
-                                                          dce_call->conn->auth_state.session_info);
+                                                          session_info);
                        if (!W_ERROR_IS_OK(werr)) {
                                return werr;
                        }
@@ -1387,6 +1389,8 @@ static WERROR bkrp_do_retrieve_default_server_wrap_key(TALLOC_CTX *mem_ctx,
 static WERROR bkrp_server_wrap_decrypt_data(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                            struct bkrp_BackupKey *r ,struct ldb_context *ldb_ctx)
 {
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
        WERROR werr;
        struct bkrp_server_side_wrapped decrypt_request;
        DATA_BLOB sid_blob, encrypted_blob;
@@ -1524,7 +1528,7 @@ static WERROR bkrp_server_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                return WERR_INVALID_ACCESS;
        }
 
-       caller_sid = &dce_call->conn->auth_state.session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
+       caller_sid = &session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
 
        if (!dom_sid_equal(&rc4payload.sid, caller_sid)) {
                return WERR_INVALID_ACCESS;
@@ -1577,6 +1581,8 @@ static WERROR bkrp_generic_decrypt_data(struct dcesrv_call_state *dce_call, TALL
 static WERROR bkrp_server_wrap_encrypt_data(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                            struct bkrp_BackupKey *r ,struct ldb_context *ldb_ctx)
 {
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
        DATA_BLOB sid_blob, encrypted_blob, server_wrapped_blob;
        WERROR werr;
        struct dom_sid *caller_sid;
@@ -1625,7 +1631,7 @@ static WERROR bkrp_server_wrap_encrypt_data(struct dcesrv_call_state *dce_call,
                }
        }
 
-       caller_sid = &dce_call->conn->auth_state.session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
+       caller_sid = &session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
 
        dump_data_pw("server_key: \n", server_key.key, sizeof(server_key.key));
 
index 198a408..9cd9125 100644 (file)
@@ -588,6 +588,8 @@ static WERROR bkrp_client_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                                            struct bkrp_BackupKey *r,
                                            struct ldb_context *ldb_ctx)
 {
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
        struct bkrp_client_side_wrapped uncrypt_request;
        DATA_BLOB blob;
        enum ndr_err_code ndr_err;
@@ -723,7 +725,7 @@ static WERROR bkrp_client_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                                                           uncrypted_secretv2.payload_key,
                                                           uncrypt_request.access_check,
                                                           uncrypt_request.access_check_len,
-                                                          dce_call->conn->auth_state.session_info);
+                                                          session_info);
                        if (!W_ERROR_IS_OK(werr)) {
                                return werr;
                        }
@@ -767,7 +769,7 @@ static WERROR bkrp_client_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                                                           uncrypted_secretv3.payload_key,
                                                           uncrypt_request.access_check,
                                                           uncrypt_request.access_check_len,
-                                                          dce_call->conn->auth_state.session_info);
+                                                          session_info);
                        if (!W_ERROR_IS_OK(werr)) {
                                return werr;
                        }
@@ -1497,6 +1499,8 @@ static WERROR bkrp_do_retrieve_default_server_wrap_key(TALLOC_CTX *mem_ctx,
 static WERROR bkrp_server_wrap_decrypt_data(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                            struct bkrp_BackupKey *r ,struct ldb_context *ldb_ctx)
 {
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
        WERROR werr;
        struct bkrp_server_side_wrapped decrypt_request;
        DATA_BLOB sid_blob, encrypted_blob, symkey_blob;
@@ -1600,7 +1604,7 @@ static WERROR bkrp_server_wrap_decrypt_data(struct dcesrv_call_state *dce_call,
                return WERR_INVALID_ACCESS;
        }
 
-       caller_sid = &dce_call->conn->auth_state.session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
+       caller_sid = &session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
 
        if (!dom_sid_equal(&rc4payload.sid, caller_sid)) {
                return WERR_INVALID_ACCESS;
@@ -1653,6 +1657,8 @@ static WERROR bkrp_generic_decrypt_data(struct dcesrv_call_state *dce_call, TALL
 static WERROR bkrp_server_wrap_encrypt_data(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
                                            struct bkrp_BackupKey *r ,struct ldb_context *ldb_ctx)
 {
+       struct auth_session_info *session_info =
+               dcesrv_call_session_info(dce_call);
        DATA_BLOB sid_blob, encrypted_blob, symkey_blob, server_wrapped_blob;
        WERROR werr;
        struct dom_sid *caller_sid;
@@ -1699,7 +1705,7 @@ static WERROR bkrp_server_wrap_encrypt_data(struct dcesrv_call_state *dce_call,
                }
        }
 
-       caller_sid = &dce_call->conn->auth_state.session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
+       caller_sid = &session_info->security_token->sids[PRIMARY_USER_SID_INDEX];
 
        dump_data_pw("server_key: \n", server_key.key, sizeof(server_key.key));