From: Lukasz Wojciechowski Date: Tue, 23 Sep 2014 15:50:27 +0000 (+0200) Subject: Adjust admin API policy type codes X-Git-Tag: submit/R4/20141115.054144~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F27971%2F5;p=platform%2Fcore%2Fsecurity%2Fcynara.git Adjust admin API policy type codes External admin API policy types should match inner cynara values used in storage and protocols. That would make plugins work easier and allows correct work of cynara_admin_check function. New header cynara-policy-types.h is provided by libcynara-common. It defines policy type values and is included by external admin API. Predefined policies variables use same values for initialization. Change-Id: If1b158dcd5abbe9ee3af692e706a2d2e886f8631 --- diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 8212f7e..4d067c3 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -458,6 +458,7 @@ fi %{_libdir}/libcynara-commons.so.* %files -n libcynara-commons-devel +%{_includedir}/cynara/cynara-policy-types.h %{_includedir}/cynara/types/PolicyResult.h %{_includedir}/cynara/types/PolicyType.h %{_libdir}/libcynara-commons.so diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 77c7d56..6cd0005 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -21,6 +21,10 @@ SET(CYNARA_COMMON_VERSION ${CYNARA_COMMON_VERSION_MAJOR}.3.0) SET(COMMON_PATH ${CYNARA_PATH}/common) +INCLUDE_DIRECTORIES( + ${CYNARA_PATH}/include + ) + SET(COMMON_SOURCES ${COMMON_PATH}/containers/BinaryQueue.cpp ${COMMON_PATH}/log/log.cpp diff --git a/src/common/types/PolicyType.h b/src/common/types/PolicyType.h index 5bef612..36c84e6 100644 --- a/src/common/types/PolicyType.h +++ b/src/common/types/PolicyType.h @@ -27,15 +27,17 @@ #include #include +#include + namespace Cynara { typedef std::uint16_t PolicyType; namespace PredefinedPolicyType { - const PolicyType DENY = 0; - const PolicyType NONE = 1; - const PolicyType BUCKET = 0xFFFE; - const PolicyType ALLOW = 0xFFFF; + const PolicyType DENY = CYNARA_ADMIN_DENY; + const PolicyType NONE = CYNARA_ADMIN_NONE; + const PolicyType BUCKET = CYNARA_ADMIN_BUCKET; + const PolicyType ALLOW = CYNARA_ADMIN_ALLOW; }; class PolicyResult; diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 245962d..1d672a8 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -26,6 +26,7 @@ INSTALL(FILES ${CYNARA_PATH}/include/cynara-creds-socket.h ${CYNARA_PATH}/include/cynara-error.h ${CYNARA_PATH}/include/cynara-plugin.h + ${CYNARA_PATH}/include/cynara-policy-types.h ${CYNARA_PATH}/include/cynara-session.h DESTINATION ${INCLUDE_INSTALL_DIR}/cynara ) diff --git a/src/include/cynara-admin-types.h b/src/include/cynara-admin-types.h index 073881a..8dd3c66 100644 --- a/src/include/cynara-admin-types.h +++ b/src/include/cynara-admin-types.h @@ -63,29 +63,6 @@ struct cynara_admin_policy { */ #define CYNARA_ADMIN_DEFAULT_BUCKET "" -/** - * \name Operation Codes - * operation codes that define action type to be taken in below defined functions - * they are used mostly to define policy result - * @{ - */ - -/*! \brief a policy or bucket should be removed */ -#define CYNARA_ADMIN_DELETE -1 - -/*! \brief set policy result or bucket's default policy to DENY */ -#define CYNARA_ADMIN_DENY 0 - -/*! \brief set bucket's default policy to NONE */ -#define CYNARA_ADMIN_NONE 1 - -/*! \brief set policy result or bucket's default policy to ALLOW */ -#define CYNARA_ADMIN_ALLOW 2 - -/*! \brief set policy to point into another bucket */ -#define CYNARA_ADMIN_BUCKET 3 -/** @}*/ - #ifdef __cplusplus } #endif diff --git a/src/include/cynara-admin.h b/src/include/cynara-admin.h index 0e92b18..cd51465 100644 --- a/src/include/cynara-admin.h +++ b/src/include/cynara-admin.h @@ -25,6 +25,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/include/cynara-offline-admin.h b/src/include/cynara-offline-admin.h index dbecc78..ce711f7 100644 --- a/src/include/cynara-offline-admin.h +++ b/src/include/cynara-offline-admin.h @@ -27,6 +27,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/src/include/cynara-policy-types.h b/src/include/cynara-policy-types.h new file mode 100644 index 0000000..398c267 --- /dev/null +++ b/src/include/cynara-policy-types.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +/** + * \file src/include/cynara-policy-types.h + * \author Lukasz Wojciechowski + * \version 1.0 + * \brief This file contains policy types / operations definitions. + */ + +#ifndef CYNARA_POLICY_TYPES_H +#define CYNARA_POLICY_TYPES_H + +/** + * \name Operation Codes + * operation codes that define action type to be taken in below defined functions + * they are used mostly to define policy result + * @{ + */ + +/*! \brief a policy or bucket should be removed */ +#define CYNARA_ADMIN_DELETE -1 + +/*! \brief set policy result or bucket's default policy to DENY */ +#define CYNARA_ADMIN_DENY 0 + +/*! \brief set bucket's default policy to NONE */ +#define CYNARA_ADMIN_NONE 1 + +/*! \brief set policy to point into another bucket */ +#define CYNARA_ADMIN_BUCKET 0xFFFE + +/*! \brief set policy result or bucket's default policy to ALLOW */ +#define CYNARA_ADMIN_ALLOW 0xFFFF +/** @}*/ + +#endif /* CYNARA_POLICY_TYPES_H */