From 7c2b987e394fcfe851b286a5e5210012c8f8f263 Mon Sep 17 00:00:00 2001 From: Vitalii Irkha Date: Tue, 22 Oct 2019 17:05:20 +0300 Subject: [PATCH] Added logging in CheckPermission() API Allow to track valuable OTM parameters https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/pull/592/commits/26549bd4237f6a4f8efa8d9a005adbf51d2de0db (cherry-picked from 26549bd4237f6a4f8efa8d9a005adbf51d2de0db) Change-Id: If6714129a488e5c198c39bacd220d0719c8392a5 Signed-off-by: Vitalii Irkha Signed-off-by: Sudipto Bal --- resource/csdk/security/src/doxmresource.c | 5 ++++- resource/csdk/security/src/policyengine.c | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/resource/csdk/security/src/doxmresource.c b/resource/csdk/security/src/doxmresource.c index d8b4506..ee63ffd 100644 --- a/resource/csdk/security/src/doxmresource.c +++ b/resource/csdk/security/src/doxmresource.c @@ -2226,9 +2226,12 @@ OCStackResult GetDoxmDeviceID(OicUuid_t *deviceID) OCStackResult GetDoxmIsOwned(bool *isOwned) { + OIC_LOG_V(INFO, TAG, "In %s", __func__); if (isOwned && gDoxm) { - *isOwned = gDoxm->owned; + *isOwned = gDoxm->owned; + OIC_LOG_V(INFO, TAG, "isOwned - %s", *isOwned ? "true" : "false"); + OIC_LOG_V(INFO, TAG, "Out %s", __func__); return OC_STACK_OK; } return OC_STACK_ERROR; diff --git a/resource/csdk/security/src/policyengine.c b/resource/csdk/security/src/policyengine.c index e38fc38..67bf641 100644 --- a/resource/csdk/security/src/policyengine.c +++ b/resource/csdk/security/src/policyengine.c @@ -554,6 +554,8 @@ SRMAccessResponse_t CheckPermission(PEContext_t *context, const char *resource, const uint16_t requestedPermission) { + OIC_LOG_V(INFO, TAG, "In %s", __func__); + SRMAccessResponse_t retVal = ACCESS_DENIED_POLICY_ENGINE_ERROR; VERIFY_NON_NULL(TAG, context, ERROR); @@ -577,6 +579,9 @@ SRMAccessResponse_t CheckPermission(PEContext_t *context, // AND c) the request is for a SVR resource. // If all 3 conditions are met, grant request. bool isDeviceOwned = true; // default to value that will not grant access + OIC_LOG_V(INFO, TAG, "IsRequestFromDevOwner - %s", IsRequestFromDevOwner(context) ? "true" : "false"); + OIC_LOG_V(INFO, TAG, "Pstat IsOp - %s", GetPstatIsop() ? "true" : "false"); + if (OC_STACK_OK != GetDoxmIsOwned(&isDeviceOwned)) // if runtime error, don't grant { context->retVal = ACCESS_DENIED_POLICY_ENGINE_ERROR; @@ -667,6 +672,8 @@ SRMAccessResponse_t CheckPermission(PEContext_t *context, } exit: + OIC_LOG_V(INFO, TAG, "context->retVal - %d", retVal); + OIC_LOG_V(INFO, TAG, "Out %s", __func__); return retVal; } -- 2.7.4