From d8d0683a5716c7038c7806a3b534b9d631256ed7 Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Tue, 11 Nov 2014 12:18:42 +0100 Subject: [PATCH 01/16] packaging: tame the packaging madness Cynara seems to adapt the model of multiple small libraries put in separate package each. This leads into plethora of small packages. This commit tries to rationalize this decomposition, merging some of the packages: - all development packages are now merged into one cynara-devel - client, client-async and client-common are merged into one - storage is merged into libcynara-common The overall result is decrease in total number of packages from 24 to 12, not counting auto generated debuginfo and debugsource. Change-Id: I947e733872a4d5c96c722b207243e3c1cdfe1ba6 --- packaging/cynara.spec | 342 ++++------------------------ packaging/libcynara-client-async.manifest | 5 - packaging/libcynara-client-commons.manifest | 5 - packaging/libcynara-storage.manifest | 5 - 4 files changed, 49 insertions(+), 308 deletions(-) delete mode 100644 packaging/libcynara-client-async.manifest delete mode 100644 packaging/libcynara-client-commons.manifest delete mode 100644 packaging/libcynara-storage.manifest diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 62cfce1..bf5c00a 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -8,18 +8,15 @@ Source0: %{name}-%{version}.tar.gz Source1000: %{name}-rpmlintrc Source1001: cynara.manifest Source1002: libcynara-client.manifest -Source1003: libcynara-client-async.manifest -Source1004: libcynara-admin.manifest -Source1005: cynara-tests.manifest -Source1006: libcynara-agent.manifest -Source1007: libcynara-client-commons.manifest -Source1008: libcynara-commons.manifest -Source1009: libcynara-creds-commons.manifest -Source1010: libcynara-creds-dbus.manifest -Source1011: libcynara-creds-socket.manifest -Source1012: libcynara-session.manifest -Source1013: libcynara-storage.manifest -Source1014: cynara-db-migration.manifest +Source1003: libcynara-admin.manifest +Source1004: cynara-tests.manifest +Source1005: libcynara-agent.manifest +Source1006: libcynara-commons.manifest +Source1007: libcynara-creds-commons.manifest +Source1008: libcynara-creds-dbus.manifest +Source1009: libcynara-creds-socket.manifest +Source1010: libcynara-session.manifest +Source1011: cynara-db-migration.manifest Requires: default-ac-domains Requires(pre): pwdutils Requires(pre): cynara-db-migration >= %{version}-%{release} @@ -52,57 +49,40 @@ BuildRequires: pkgconfig(libunwind) %endif %description -service, client libraries (libcynara-client, libcynara-client-async, libcynara-admin), +service, client libraries (libcynara-client, libcynara-admin), agent library, helper libraries (libcynara-session, libcynara-creds-common, libcynara-creds-dbus, libcynara-creds-socket) and tests (cynara-tests) -####################################################### -%package -n libcynara-client -Summary: Cynara - client library -Requires: cynara = %{version}-%{release} - -%description -n libcynara-client -client library for checking policies - -%package -n libcynara-client-devel -Summary: Cynara - client library (devel) +%package devel +Summary: Cynara development files +Requires: libcynara-admin = %{version}-%{release} +Requires: libcynara-agent = %{version}-%{release} Requires: libcynara-client = %{version}-%{release} -Requires: libcynara-client-commons-devel = %{version}-%{release} - -%description -n libcynara-client-devel -client library (devel) for checking policies - -####################################################### -%package -n libcynara-client-async -Summary: Cynara - asynchronous client library -Requires: cynara = %{version}-%{release} - -%description -n libcynara-client-async -asynchronous client library for checking policies - -%package -n libcynara-client-async-devel -Summary: Cynara - asynchronous client library (devel) -Requires: libcynara-client-async = %{version}-%{release} -Requires: libcynara-client-commons-devel = %{version}-%{release} +Requires: libcynara-commons = %{version}-%{release} +Requires: libcynara-creds-commons = %{version}-%{release} +Requires: libcynara-creds-dbus = %{version}-%{release} +Requires: libcynara-creds-socket = %{version}-%{release} +Requires: libcynara-session = %{version}-%{release} -%description -n libcynara-client-async-devel -asynchronous client library (devel) for checking policies +%description devel +Cynara development files -####################################################### -%package -n libcynara-client-commons -Summary: Cynara - client commons library +%package tests +Summary: Cynara - cynara test binaries +BuildRequires: pkgconfig(gmock) -%description -n libcynara-client-commons -client commons library with common functionalities +%description tests +Cynara tests -%package -n libcynara-client-commons-devel -Summary: Cynara - client commons library (devel) -Requires: libcynara-client-commons = %{version}-%{release} +%package -n libcynara-client +Summary: Cynara - client libraries +Requires: cynara = %{version}-%{release} +Obsoletes: libcynara-client-commons +Obsoletes: libcynara-client-async -%description -n libcynara-client-commons-devel -client commons library (devel) with common functionalities +%description -n libcynara-client +Client libraries for checking policies: synchronous and asynchronous -####################################################### %package -n libcynara-admin Summary: Cynara - admin client library Requires: cynara = %{version}-%{release} @@ -110,16 +90,6 @@ Requires: cynara = %{version}-%{release} %description -n libcynara-admin admin client library for setting, listing and removing policies -%package -n libcynara-admin-devel -Summary: Cynara - admin client library (devel) -Requires: libcynara-admin = %{version}-%{release} -Requires: libcynara-client-commons-devel = %{version}-%{release} -Requires: libcynara-commons-devel = %{version}-%{release} - -%description -n libcynara-admin-devel -admin client library (devel) for setting, listing and removing policies - -####################################################### %package -n libcynara-agent Summary: Cynara - agent client library Requires: cynara = %{version}-%{release} @@ -127,66 +97,19 @@ Requires: cynara = %{version}-%{release} %description -n libcynara-agent agent client library for communication with cynara service and plugins -%package -n libcynara-agent-devel -Summary: Cynara - agent client library (devel) -Requires: libcynara-agent = %{version}-%{release} -Requires: libcynara-client-commons-devel = %{version}-%{release} - -%description -n libcynara-agent-devel -agent client library (devel) for communication with cynara service and plugins - -####################################################### -%package -n libcynara-storage -Summary: Cynara - storage - -%description -n libcynara-storage -cynara common storage library with common storage functionalities - -%package -n libcynara-storage-devel -Summary: Cynara - storage-devel -Requires: cynara = %{version}-%{release} - -%description -n libcynara-storage-devel -cynara common storage library (devel) with common storage functionalities - -####################################################### %package -n libcynara-commons Summary: Cynara - cynara commons library +Obsoletes: libcynara-storage %description -n libcynara-commons cynara common library with common functionalities -%package -n libcynara-commons-devel -Summary: Cynara - cynara commons library (devel) -Requires: libcynara-commons = %{version}-%{release} - -%description -n libcynara-commons-devel -cynara common library (devel) with common functionalities - -####################################################### -%package -n libcynara-plugin-devel -Summary: Cynara - cynara plugin library (devel) -Requires: libcynara-commons-devel = %{version}-%{release} - -%description -n libcynara-plugin-devel -cynara plugin library (devel) with plugin definitions - -####################################################### %package -n libcynara-creds-commons Summary: Base library for cynara credentials helpers %description -n libcynara-creds-commons Base library for cynara credentials helpers -%package -n libcynara-creds-commons-devel -Summary: Base library for cynara credentials helpers (devel) -Requires: libcynara-creds-commons = %{version}-%{release} -Requires: libcynara-client-commons-devel = %{version}-%{release} - -%description -n libcynara-creds-commons-devel -Base library for cynara credentials helpers (devel) - -####################################################### %package -n libcynara-creds-dbus Summary: Cynara credentials helpers library for dbus clients BuildRequires: pkgconfig(dbus-1) @@ -195,60 +118,18 @@ Requires: dbus %description -n libcynara-creds-dbus Cynara credentials helpers library for dbus clients -%package -n libcynara-creds-dbus-devel -Summary: Cynara credentials helpers library for dbus clients (devel) -Requires: libcynara-creds-dbus = %{version}-%{release} -Requires: libcynara-creds-commons-devel = %{version}-%{release} - -%description -n libcynara-creds-dbus-devel -Cynara credentials helpers library for dbus clients (devel) - -####################################################### %package -n libcynara-creds-socket Summary: Cynara credentials helpers library for socket clients %description -n libcynara-creds-socket Cynara credentials helpers library for socket clients -%package -n libcynara-creds-socket-devel -Summary: Cynara credentials helpers library for socket clients (devel) -Requires: libcynara-creds-socket = %{version}-%{release} -Requires: libcynara-creds-commons-devel = %{version}-%{release} - -%description -n libcynara-creds-socket-devel -Cynara credentials helpers library for socket clients (devel) - -####################################################### %package -n libcynara-session Summary: Cynara helper client session string creation library %description -n libcynara-session Cynara helper client session string creation library -%package -n libcynara-session-devel -Summary: Cynara helper client session string creation library (devel) -Requires: libcynara-session = %{version}-%{release} - -%description -n libcynara-session-devel -Cynara helper client session string creation library (devel) - -####################################################### -%package -n cynara-tests -Summary: Cynara - cynara test binaries -BuildRequires: pkgconfig(gmock) - -%description -n cynara-tests -Cynara tests - -####################################################### -%package -n cynara-devel -Summary: Cynara service (devel) -Requires: cynara = %{version}-%{release} - -%description -n cynara-devel -service (devel version) - -####################################################### %package -n cynara-db-migration Summary: Migration tools for Cynara's database @@ -268,9 +149,6 @@ cp -a %{SOURCE1008} . cp -a %{SOURCE1009} . cp -a %{SOURCE1010} . cp -a %{SOURCE1011} . -cp -a %{SOURCE1012} . -cp -a %{SOURCE1013} . -cp -a %{SOURCE1014} . cp -a test/db/db* . %build @@ -363,14 +241,6 @@ fi %postun -n libcynara-client -p /sbin/ldconfig -%post -n libcynara-client-async -p /sbin/ldconfig - -%postun -n libcynara-client-async -p /sbin/ldconfig - -%post -n libcynara-client-commons -p /sbin/ldconfig - -%postun -n libcynara-client-commons -p /sbin/ldconfig - %post -n libcynara-admin -p /sbin/ldconfig %postun -n libcynara-admin -p /sbin/ldconfig @@ -379,75 +249,27 @@ fi %postun -n libcynara-agent -p /sbin/ldconfig -%post -n libcynara-storage -p /sbin/ldconfig - -%postun -n libcynara-storage -p /sbin/ldconfig - -%post -n libcynara-storage-devel -p /sbin/ldconfig - -%postun -n libcynara-storage-devel -p /sbin/ldconfig - %post -n libcynara-commons -p /sbin/ldconfig %postun -n libcynara-commons -p /sbin/ldconfig -%post -n libcynara-client-devel -p /sbin/ldconfig - -%postun -n libcynara-client-devel -p /sbin/ldconfig - -%post -n libcynara-client-async-devel -p /sbin/ldconfig - -%postun -n libcynara-client-async-devel -p /sbin/ldconfig - -%post -n libcynara-client-commons-devel -p /sbin/ldconfig - -%postun -n libcynara-client-commons-devel -p /sbin/ldconfig - -%post -n libcynara-admin-devel -p /sbin/ldconfig - -%postun -n libcynara-admin-devel -p /sbin/ldconfig - -%post -n libcynara-agent-devel -p /sbin/ldconfig - -%postun -n libcynara-agent-devel -p /sbin/ldconfig - -%post -n libcynara-commons-devel -p /sbin/ldconfig - -%postun -n libcynara-commons-devel -p /sbin/ldconfig - %post -n libcynara-creds-commons -p /sbin/ldconfig %postun -n libcynara-creds-commons -p /sbin/ldconfig -%post -n libcynara-creds-commons-devel -p /sbin/ldconfig - -%postun -n libcynara-creds-commons-devel -p /sbin/ldconfig - %post -n libcynara-creds-dbus -p /sbin/ldconfig %postun -n libcynara-creds-dbus -p /sbin/ldconfig -%post -n libcynara-creds-dbus-devel -p /sbin/ldconfig - -%postun -n libcynara-creds-dbus-devel -p /sbin/ldconfig - %post -n libcynara-creds-socket -p /sbin/ldconfig %postun -n libcynara-creds-socket -p /sbin/ldconfig -%post -n libcynara-creds-socket-devel -p /sbin/ldconfig - -%postun -n libcynara-creds-socket-devel -p /sbin/ldconfig - %post -n libcynara-session -p /sbin/ldconfig %postun -n libcynara-session -p /sbin/ldconfig -%post -n libcynara-session-devel -p /sbin/ldconfig - -%postun -n libcynara-session-devel -p /sbin/ldconfig - -%files -n cynara +%files %manifest cynara.manifest %license LICENSE %attr(755,root,root) /usr/bin/cynara @@ -462,88 +284,42 @@ fi %dir %attr(700,cynara,cynara) %{state_path} %dir %attr(755,cynara,cynara) %{lib_path}/plugin/service +%files -n cynara-devel +%{_includedir}/cynara/*.h +%{_includedir}/cynara/plugin/*.h +%{_includedir}/cynara/types/*.h +%{_libdir}/pkgconfig/*.pc +%{_libdir}/*.so + +%files -n cynara-tests +%manifest cynara-tests.manifest +%attr(755,root,root) /usr/bin/cynara-tests +%attr(755,root,root) %{tests_dir}/db*/* +%dir %attr(755,root,root) %{tests_dir}/empty_db + %files -n libcynara-client %manifest libcynara-client.manifest %license LICENSE %{_libdir}/libcynara-client.so.* - -%files -n libcynara-client-devel -%{_includedir}/cynara/cynara-client.h -%{_libdir}/pkgconfig/cynara-client.pc -%{_libdir}/libcynara-client.so - -%files -n libcynara-client-async -%manifest libcynara-client-async.manifest -%license LICENSE %{_libdir}/libcynara-client-async.so.* - -%files -n libcynara-client-async-devel -%{_includedir}/cynara/cynara-client-async.h -%{_libdir}/pkgconfig/cynara-client-async.pc -%{_libdir}/libcynara-client-async.so - -%files -n libcynara-client-commons -%manifest libcynara-client-commons.manifest -%license LICENSE %{_libdir}/libcynara-client-commons.so.* %dir %attr(755,cynara,cynara) %{lib_path}/plugin/client -%files -n libcynara-client-commons-devel -%{_includedir}/cynara/cynara-error.h -%{_libdir}/libcynara-client-commons.so - %files -n libcynara-admin %manifest libcynara-admin.manifest %license LICENSE %{_libdir}/libcynara-admin.so.* -%files -n libcynara-admin-devel -%{_includedir}/cynara/cynara-admin.h -%{_includedir}/cynara/cynara-admin-types.h -%{_libdir}/libcynara-admin.so -%{_libdir}/pkgconfig/cynara-admin.pc - %files -n libcynara-agent %manifest libcynara-agent.manifest %license LICENSE %{_libdir}/libcynara-agent.so.* -%files -n libcynara-agent-devel -%{_includedir}/cynara/cynara-agent.h -%{_libdir}/libcynara-agent.so -%{_libdir}/pkgconfig/cynara-agent.pc - -%files -n libcynara-storage -%manifest libcynara-storage.manifest -%license LICENSE -%{_libdir}/libcynara-storage.so.* - -%files -n libcynara-storage-devel -%{_libdir}/libcynara-storage.so - %files -n libcynara-commons %manifest libcynara-commons.manifest %license LICENSE %{_libdir}/libcynara-commons.so.* - -%files -n libcynara-commons-devel -%{_includedir}/cynara/cynara-policy-types.h -%{_includedir}/cynara/plugin/ExternalPluginInterface.h -%{_includedir}/cynara/types/ClientSession.h -%{_includedir}/cynara/types/PolicyResult.h -%{_includedir}/cynara/types/PolicyType.h -%{_libdir}/libcynara-commons.so - -%files -n libcynara-plugin-devel -%{_includedir}/cynara/cynara-plugin.h -%{_includedir}/cynara/cynara-client-plugin.h -%{_libdir}/pkgconfig/cynara-plugin.pc - -%files -n cynara-tests -%manifest cynara-tests.manifest -%attr(755,root,root) /usr/bin/cynara-tests -%attr(755,root,root) %{tests_dir}/db*/* -%dir %attr(755,root,root) %{tests_dir}/empty_db +%{_libdir}/libcynara-storage.so.* %files -n libcynara-creds-commons %manifest libcynara-creds-commons.manifest @@ -551,41 +327,21 @@ fi %{_libdir}/libcynara-creds-commons.so.* %{conf_path}creds.conf -%files -n libcynara-creds-commons-devel -%{_includedir}/cynara/cynara-creds-commons.h -%{_libdir}/libcynara-creds-commons.so -%{_libdir}/pkgconfig/cynara-creds-commons.pc - %files -n libcynara-creds-dbus %manifest libcynara-creds-dbus.manifest %license LICENSE %{_libdir}/libcynara-creds-dbus.so.* -%files -n libcynara-creds-dbus-devel -%{_includedir}/cynara/cynara-creds-dbus.h -%{_libdir}/libcynara-creds-dbus.so -%{_libdir}/pkgconfig/cynara-creds-dbus.pc - %files -n libcynara-creds-socket %manifest libcynara-creds-socket.manifest %license LICENSE %{_libdir}/libcynara-creds-socket.so.* -%files -n libcynara-creds-socket-devel -%{_includedir}/cynara/cynara-creds-socket.h -%{_libdir}/libcynara-creds-socket.so -%{_libdir}/pkgconfig/cynara-creds-socket.pc - %files -n libcynara-session %manifest libcynara-session.manifest %license LICENSE %{_libdir}/libcynara-session.so.* -%files -n libcynara-session-devel -%{_includedir}/cynara/cynara-session.h -%{_libdir}/libcynara-session.so -%{_libdir}/pkgconfig/cynara-session.pc - %files -n cynara-db-migration %manifest cynara-db-migration.manifest %attr(744,root,root) %{_sbindir}/cynara/cynara-db-migration.sh diff --git a/packaging/libcynara-client-async.manifest b/packaging/libcynara-client-async.manifest deleted file mode 100644 index a76fdba..0000000 --- a/packaging/libcynara-client-async.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/libcynara-client-commons.manifest b/packaging/libcynara-client-commons.manifest deleted file mode 100644 index a76fdba..0000000 --- a/packaging/libcynara-client-commons.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/libcynara-storage.manifest b/packaging/libcynara-storage.manifest deleted file mode 100644 index a76fdba..0000000 --- a/packaging/libcynara-storage.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - -- 2.7.4 From 1d7785957f74ba5443759688245ec92a221bad78 Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Fri, 31 Oct 2014 14:33:16 +0100 Subject: [PATCH 02/16] packaging: make cynara-devel depend on dbus-devel D-Bus include is being included from cynara-creds-dbus.h. D-Bus headers will be required for successful compilation against cynara-creds-dbus. Change-Id: Ib223f7025fe7c49f57741b6dca11f294b927d06e --- packaging/cynara.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/cynara.spec b/packaging/cynara.spec index bf5c00a..a9fa629 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -63,6 +63,7 @@ Requires: libcynara-creds-commons = %{version}-%{release} Requires: libcynara-creds-dbus = %{version}-%{release} Requires: libcynara-creds-socket = %{version}-%{release} Requires: libcynara-session = %{version}-%{release} +Requires: pkgconfig(dbus-1) %description devel Cynara development files -- 2.7.4 From 332dcdd8783d9fd94a852b8ec9535a54029cc5a5 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Mon, 17 Nov 2014 11:57:07 +0100 Subject: [PATCH 03/16] Release 0.4.1 Change-Id: I79a7007db3af7e7815547c7ccbca8f23986fab02 --- CMakeLists.txt | 2 +- changelog | 23 +++++++++++++++++++++++ packaging/cynara.spec | 2 +- src/admin/CMakeLists.txt | 2 +- src/client-common/CMakeLists.txt | 2 +- src/client/CMakeLists.txt | 2 +- src/common/CMakeLists.txt | 2 +- src/helpers/creds-commons/CMakeLists.txt | 2 +- src/helpers/creds-dbus/CMakeLists.txt | 2 +- src/helpers/creds-socket/CMakeLists.txt | 2 +- src/helpers/session/CMakeLists.txt | 2 +- 11 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5271bb2..0bfb07d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) PROJECT("cynara") -set(CYNARA_VERSION 0.4.0) +set(CYNARA_VERSION 0.4.1) ############################# cmake packages ################################## diff --git a/changelog b/changelog index e841be7..aa297e4 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,28 @@ ############################## +Release: 0.4.1 +Date: 2014.11.17 +Name: Fix packaging problems + +Libraries: +libcynara-admin.0.4.1 +libcynara-agent.0.4.1 +libcynara-client-async.0.4.1 +libcynara-client-commmons.0.4.1 +libcynara-client.0.4.1 +libcynara-commons.0.4.1 +libcynara-creds-commons.0.4.1 +libcynara-creds-dbus.0.4.1 +libcynara-creds-socket.0.4.1 +libcynara-session.0.4.1 +libcynara-storage.0.4.1 + +Description: +Fix problems with packages dependencies +Create missing plugin directories + +############################## + Release: 0.4.0 Date: 2014.11.15 Name: Asynchronous client and extensions API diff --git a/packaging/cynara.spec b/packaging/cynara.spec index a9fa629..377d6b2 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -1,6 +1,6 @@ Name: cynara Summary: Cynara service with client libraries -Version: 0.4.0 +Version: 0.4.1 Release: 1 Group: Security/Application Privilege License: Apache-2.0 diff --git a/src/admin/CMakeLists.txt b/src/admin/CMakeLists.txt index 7cab9f6..3b46f63 100644 --- a/src/admin/CMakeLists.txt +++ b/src/admin/CMakeLists.txt @@ -17,7 +17,7 @@ # SET(LIB_CYNARA_ADMIN_VERSION_MAJOR 0) -SET(LIB_CYNARA_ADMIN_VERSION ${LIB_CYNARA_ADMIN_VERSION_MAJOR}.4.0) +SET(LIB_CYNARA_ADMIN_VERSION ${LIB_CYNARA_ADMIN_VERSION_MAJOR}.4.1) SET(CYNARA_LIB_CYNARA_ADMIN_PATH ${CYNARA_PATH}/admin) diff --git a/src/client-common/CMakeLists.txt b/src/client-common/CMakeLists.txt index 36c6806..0c3c431 100644 --- a/src/client-common/CMakeLists.txt +++ b/src/client-common/CMakeLists.txt @@ -17,7 +17,7 @@ # SET(LIB_CYNARA_CLIENT_COMMON_VERSION_MAJOR 0) -SET(LIB_CYNARA_CLIENT_COMMON_VERSION ${LIB_CYNARA_CLIENT_COMMON_VERSION_MAJOR}.4.0) +SET(LIB_CYNARA_CLIENT_COMMON_VERSION ${LIB_CYNARA_CLIENT_COMMON_VERSION_MAJOR}.4.1) SET(LIB_CYNARA_COMMON_PATH ${CYNARA_PATH}/client-common) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 79d85a2..e20fd51 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -18,7 +18,7 @@ # SET(LIB_CYNARA_VERSION_MAJOR 0) -SET(LIB_CYNARA_VERSION ${LIB_CYNARA_VERSION_MAJOR}.4.0) +SET(LIB_CYNARA_VERSION ${LIB_CYNARA_VERSION_MAJOR}.4.1) SET(LIB_CYNARA_PATH ${CYNARA_PATH}/client) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 68bda47..797e233 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -17,7 +17,7 @@ # SET(CYNARA_COMMON_VERSION_MAJOR 0) -SET(CYNARA_COMMON_VERSION ${CYNARA_COMMON_VERSION_MAJOR}.4.0) +SET(CYNARA_COMMON_VERSION ${CYNARA_COMMON_VERSION_MAJOR}.4.1) SET(COMMON_PATH ${CYNARA_PATH}/common) diff --git a/src/helpers/creds-commons/CMakeLists.txt b/src/helpers/creds-commons/CMakeLists.txt index bafa025..98ea56c 100644 --- a/src/helpers/creds-commons/CMakeLists.txt +++ b/src/helpers/creds-commons/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_CREDS_COMMONS_VERSION_MAJOR 0) -SET(LIB_CREDS_COMMONS_VERSION ${LIB_CREDS_COMMONS_VERSION_MAJOR}.4.0) +SET(LIB_CREDS_COMMONS_VERSION ${LIB_CREDS_COMMONS_VERSION_MAJOR}.4.1) SET(LIB_CREDS_COMMONS_PATH ${CYNARA_PATH}/helpers/creds-commons) diff --git a/src/helpers/creds-dbus/CMakeLists.txt b/src/helpers/creds-dbus/CMakeLists.txt index 69b94e2..b3c9ee6 100644 --- a/src/helpers/creds-dbus/CMakeLists.txt +++ b/src/helpers/creds-dbus/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_CREDS_DBUS_VERSION_MAJOR 0) -SET(LIB_CREDS_DBUS_VERSION ${LIB_CREDS_DBUS_VERSION_MAJOR}.4.0) +SET(LIB_CREDS_DBUS_VERSION ${LIB_CREDS_DBUS_VERSION_MAJOR}.4.1) SET(LIB_CREDS_DBUS_PATH ${CYNARA_PATH}/helpers/creds-dbus) diff --git a/src/helpers/creds-socket/CMakeLists.txt b/src/helpers/creds-socket/CMakeLists.txt index 1d40f3b..847ffe5 100644 --- a/src/helpers/creds-socket/CMakeLists.txt +++ b/src/helpers/creds-socket/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_CREDS_SOCKET_VERSION_MAJOR 0) -SET(LIB_CREDS_SOCKET_VERSION ${LIB_CREDS_SOCKET_VERSION_MAJOR}.4.0) +SET(LIB_CREDS_SOCKET_VERSION ${LIB_CREDS_SOCKET_VERSION_MAJOR}.4.1) SET(LIB_CREDS_SOCKET_PATH ${CYNARA_PATH}/helpers/creds-socket) diff --git a/src/helpers/session/CMakeLists.txt b/src/helpers/session/CMakeLists.txt index 6ad7234..8d3774c 100644 --- a/src/helpers/session/CMakeLists.txt +++ b/src/helpers/session/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_SESSION_VERSION_MAJOR 0) -SET(LIB_SESSION_VERSION ${LIB_SESSION_VERSION_MAJOR}.4.0) +SET(LIB_SESSION_VERSION ${LIB_SESSION_VERSION_MAJOR}.4.1) SET(LIB_SESSION_PATH ${CYNARA_PATH}/helpers/session) -- 2.7.4 From 50b4c070e01fbcf710e5b27f34eab00f0a48d892 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 18 Nov 2014 14:29:23 +0100 Subject: [PATCH 04/16] Make old devel packages names obsolete Merging all devel rpms into single cynara-devel causes all older devel packages to be obsolete. Change-Id: I6e10c7c74f58dbf8c5ca676ce817382f2c801752 --- packaging/cynara.spec | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 377d6b2..95d722d 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -64,6 +64,18 @@ Requires: libcynara-creds-dbus = %{version}-%{release} Requires: libcynara-creds-socket = %{version}-%{release} Requires: libcynara-session = %{version}-%{release} Requires: pkgconfig(dbus-1) +Obsoletes: libcynara-admin-devel +Obsoletes: libcynara-agent-devel +Obsoletes: libcynara-client-async-devel +Obsoletes: libcynara-client-commons-devel +Obsoletes: libcynara-client-devel +Obsoletes: libcynara-commons-devel +Obsoletes: libcynara-creds-commons-devel +Obsoletes: libcynara-creds-dbus-devel +Obsoletes: libcynara-creds-socket-devel +Obsoletes: libcynara-plugin-devel +Obsoletes: libcynara-session-devel +Obsoletes: libcynara-storage-devel %description devel Cynara development files -- 2.7.4 From b00d7fb59ba12ad6cfb53b5b476dc3c18e09f39d Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 18 Nov 2014 14:37:36 +0100 Subject: [PATCH 05/16] Release 0.4.2 Change-Id: I98e8bc31f89125fa7dd7a92b9feb7d93e24772c7 --- CMakeLists.txt | 2 +- changelog | 22 ++++++++++++++++++++++ packaging/cynara.spec | 2 +- src/admin/CMakeLists.txt | 2 +- src/client-common/CMakeLists.txt | 2 +- src/client/CMakeLists.txt | 2 +- src/common/CMakeLists.txt | 2 +- src/helpers/creds-commons/CMakeLists.txt | 2 +- src/helpers/creds-dbus/CMakeLists.txt | 2 +- src/helpers/creds-socket/CMakeLists.txt | 2 +- src/helpers/session/CMakeLists.txt | 2 +- 11 files changed, 32 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bfb07d..c7a802c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) PROJECT("cynara") -set(CYNARA_VERSION 0.4.1) +set(CYNARA_VERSION 0.4.2) ############################# cmake packages ################################## diff --git a/changelog b/changelog index aa297e4..25fb0f5 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,27 @@ ############################## +Release: 0.4.2 +Date: 2014.11.18 +Name: Fix packaging problems + +Libraries: +libcynara-admin.0.4.2 +libcynara-agent.0.4.2 +libcynara-client-async.0.4.2 +libcynara-client-commmons.0.4.2 +libcynara-client.0.4.2 +libcynara-commons.0.4.2 +libcynara-creds-commons.0.4.2 +libcynara-creds-dbus.0.4.2 +libcynara-creds-socket.0.4.2 +libcynara-session.0.4.2 +libcynara-storage.0.4.2 + +Description: +Fix problems with obsolete packages + +############################## + Release: 0.4.1 Date: 2014.11.17 Name: Fix packaging problems diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 95d722d..91b80a6 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -1,6 +1,6 @@ Name: cynara Summary: Cynara service with client libraries -Version: 0.4.1 +Version: 0.4.2 Release: 1 Group: Security/Application Privilege License: Apache-2.0 diff --git a/src/admin/CMakeLists.txt b/src/admin/CMakeLists.txt index 3b46f63..f58c751 100644 --- a/src/admin/CMakeLists.txt +++ b/src/admin/CMakeLists.txt @@ -17,7 +17,7 @@ # SET(LIB_CYNARA_ADMIN_VERSION_MAJOR 0) -SET(LIB_CYNARA_ADMIN_VERSION ${LIB_CYNARA_ADMIN_VERSION_MAJOR}.4.1) +SET(LIB_CYNARA_ADMIN_VERSION ${LIB_CYNARA_ADMIN_VERSION_MAJOR}.4.2) SET(CYNARA_LIB_CYNARA_ADMIN_PATH ${CYNARA_PATH}/admin) diff --git a/src/client-common/CMakeLists.txt b/src/client-common/CMakeLists.txt index 0c3c431..bb02eca 100644 --- a/src/client-common/CMakeLists.txt +++ b/src/client-common/CMakeLists.txt @@ -17,7 +17,7 @@ # SET(LIB_CYNARA_CLIENT_COMMON_VERSION_MAJOR 0) -SET(LIB_CYNARA_CLIENT_COMMON_VERSION ${LIB_CYNARA_CLIENT_COMMON_VERSION_MAJOR}.4.1) +SET(LIB_CYNARA_CLIENT_COMMON_VERSION ${LIB_CYNARA_CLIENT_COMMON_VERSION_MAJOR}.4.2) SET(LIB_CYNARA_COMMON_PATH ${CYNARA_PATH}/client-common) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index e20fd51..2d5c0a2 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -18,7 +18,7 @@ # SET(LIB_CYNARA_VERSION_MAJOR 0) -SET(LIB_CYNARA_VERSION ${LIB_CYNARA_VERSION_MAJOR}.4.1) +SET(LIB_CYNARA_VERSION ${LIB_CYNARA_VERSION_MAJOR}.4.2) SET(LIB_CYNARA_PATH ${CYNARA_PATH}/client) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 797e233..e8974cb 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -17,7 +17,7 @@ # SET(CYNARA_COMMON_VERSION_MAJOR 0) -SET(CYNARA_COMMON_VERSION ${CYNARA_COMMON_VERSION_MAJOR}.4.1) +SET(CYNARA_COMMON_VERSION ${CYNARA_COMMON_VERSION_MAJOR}.4.2) SET(COMMON_PATH ${CYNARA_PATH}/common) diff --git a/src/helpers/creds-commons/CMakeLists.txt b/src/helpers/creds-commons/CMakeLists.txt index 98ea56c..9ff7aa7 100644 --- a/src/helpers/creds-commons/CMakeLists.txt +++ b/src/helpers/creds-commons/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_CREDS_COMMONS_VERSION_MAJOR 0) -SET(LIB_CREDS_COMMONS_VERSION ${LIB_CREDS_COMMONS_VERSION_MAJOR}.4.1) +SET(LIB_CREDS_COMMONS_VERSION ${LIB_CREDS_COMMONS_VERSION_MAJOR}.4.2) SET(LIB_CREDS_COMMONS_PATH ${CYNARA_PATH}/helpers/creds-commons) diff --git a/src/helpers/creds-dbus/CMakeLists.txt b/src/helpers/creds-dbus/CMakeLists.txt index b3c9ee6..90f6cbe 100644 --- a/src/helpers/creds-dbus/CMakeLists.txt +++ b/src/helpers/creds-dbus/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_CREDS_DBUS_VERSION_MAJOR 0) -SET(LIB_CREDS_DBUS_VERSION ${LIB_CREDS_DBUS_VERSION_MAJOR}.4.1) +SET(LIB_CREDS_DBUS_VERSION ${LIB_CREDS_DBUS_VERSION_MAJOR}.4.2) SET(LIB_CREDS_DBUS_PATH ${CYNARA_PATH}/helpers/creds-dbus) diff --git a/src/helpers/creds-socket/CMakeLists.txt b/src/helpers/creds-socket/CMakeLists.txt index 847ffe5..27f9b0c 100644 --- a/src/helpers/creds-socket/CMakeLists.txt +++ b/src/helpers/creds-socket/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_CREDS_SOCKET_VERSION_MAJOR 0) -SET(LIB_CREDS_SOCKET_VERSION ${LIB_CREDS_SOCKET_VERSION_MAJOR}.4.1) +SET(LIB_CREDS_SOCKET_VERSION ${LIB_CREDS_SOCKET_VERSION_MAJOR}.4.2) SET(LIB_CREDS_SOCKET_PATH ${CYNARA_PATH}/helpers/creds-socket) diff --git a/src/helpers/session/CMakeLists.txt b/src/helpers/session/CMakeLists.txt index 8d3774c..b783ebc 100644 --- a/src/helpers/session/CMakeLists.txt +++ b/src/helpers/session/CMakeLists.txt @@ -19,7 +19,7 @@ # SET(LIB_SESSION_VERSION_MAJOR 0) -SET(LIB_SESSION_VERSION ${LIB_SESSION_VERSION_MAJOR}.4.1) +SET(LIB_SESSION_VERSION ${LIB_SESSION_VERSION_MAJOR}.4.2) SET(LIB_SESSION_PATH ${CYNARA_PATH}/helpers/session) -- 2.7.4 From 668a60a5339b3078540c6cabfa199271c8d816a4 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Fri, 21 Nov 2014 15:43:28 +0100 Subject: [PATCH 06/16] Fix uninitialized member Descriptor could return uninitialized BinaryQueuePtr. Change-Id: I53fbc739438e8316ca5c4b81eec5139b6732aea2 --- src/service/sockets/Descriptor.cpp | 5 +++++ src/service/sockets/Descriptor.h | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/service/sockets/Descriptor.cpp b/src/service/sockets/Descriptor.cpp index b2e9459..e247f7f 100644 --- a/src/service/sockets/Descriptor.cpp +++ b/src/service/sockets/Descriptor.cpp @@ -34,6 +34,11 @@ void Descriptor::checkQueues(void) { m_readQueue = std::make_shared(); } +BinaryQueuePtr Descriptor::writeQueue(void) { + checkQueues(); + return m_writeQueue; +} + bool Descriptor::hasDataToWrite(void) const { if (m_writeQueue) return !(m_writeQueue->empty() && m_writeBuffer.empty()); diff --git a/src/service/sockets/Descriptor.h b/src/service/sockets/Descriptor.h index 5d77028..a9a6c68 100644 --- a/src/service/sockets/Descriptor.h +++ b/src/service/sockets/Descriptor.h @@ -57,9 +57,7 @@ public: ResponseTakerPtr responseTaker(void) const; - BinaryQueuePtr writeQueue(void) { - return m_writeQueue; - } + BinaryQueuePtr writeQueue(void); void setProtocol(ProtocolPtr protocol) { m_protocol = protocol; -- 2.7.4 From e0d4ea8fe95d59f0d6e21376e8d16b2c05b0495c Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Mon, 17 Nov 2014 17:48:30 +0100 Subject: [PATCH 07/16] Optimize message() method of exceptions message() returned std::string through value, causing unnecessary copy. Changed it to return const std::string reference. Change-Id: I8d9631fb2468924d35ba4376b1821d0d01c7f70c --- src/common/exceptions/BucketDeserializationException.h | 11 +++++------ src/common/exceptions/BucketNotExistsException.h | 9 ++++++--- src/common/exceptions/BucketRecordCorruptedException.h | 14 +++++++------- src/common/exceptions/BucketSerializationException.h | 11 +++++------ src/common/exceptions/CannotCreateFileException.h | 11 +++++------ src/common/exceptions/ContextErrorException.h | 9 ++++++--- src/common/exceptions/DefaultBucketDeletionException.h | 10 +++++++--- src/common/exceptions/DefaultBucketSetNoneException.h | 10 +++++++--- src/common/exceptions/DescriptorNotExistsException.h | 10 ++++------ src/common/exceptions/Exception.h | 2 +- src/common/exceptions/FileNotFoundException.h | 13 ++++++------- src/common/exceptions/InitException.h | 9 ++++++--- src/common/exceptions/InvalidBucketIdException.h | 11 +++++------ src/common/exceptions/InvalidProtocolException.h | 12 ++++++------ src/common/exceptions/NoMemoryException.h | 8 ++++---- src/common/exceptions/NotImplementedException.h | 9 ++++++--- src/common/exceptions/NullPointerException.h | 10 ++++------ src/common/exceptions/OutOfDataException.h | 12 +++++------- src/common/exceptions/PluginErrorException.h | 2 +- src/common/exceptions/PluginNotFoundException.h | 14 ++++++-------- src/common/exceptions/UnexpectedErrorException.h | 17 ++++++----------- 21 files changed, 108 insertions(+), 106 deletions(-) diff --git a/src/common/exceptions/BucketDeserializationException.h b/src/common/exceptions/BucketDeserializationException.h index c5670c8..36ef8b0 100644 --- a/src/common/exceptions/BucketDeserializationException.h +++ b/src/common/exceptions/BucketDeserializationException.h @@ -29,13 +29,12 @@ namespace Cynara { class BucketDeserializationException : public DatabaseException { public: - BucketDeserializationException(const PolicyBucketId &bucketId) : m_bucketId(bucketId) {} + BucketDeserializationException(const PolicyBucketId &bucket) : m_bucketId(bucket) { + m_message = "Could not deserialize bucket " + bucketId(); + } virtual ~BucketDeserializationException() {}; - const std::string message(void) const { - if (m_message.empty()) { - m_message = "Could not deserialize bucket " + m_bucketId; - } + const std::string &message(void) const { return m_message; } @@ -44,7 +43,7 @@ public: } private: - mutable std::string m_message; + std::string m_message; PolicyBucketId m_bucketId; }; diff --git a/src/common/exceptions/BucketNotExistsException.h b/src/common/exceptions/BucketNotExistsException.h index 9ba9505..68d041b 100644 --- a/src/common/exceptions/BucketNotExistsException.h +++ b/src/common/exceptions/BucketNotExistsException.h @@ -33,11 +33,13 @@ namespace Cynara { class BucketNotExistsException : public Exception { public: BucketNotExistsException() = delete; - BucketNotExistsException(const PolicyBucketId &bucketId) : m_bucketId(bucketId) {} + BucketNotExistsException(const PolicyBucketId &bucketId) + : m_bucketId(bucketId), m_message("BucketNotExistsException") { + } virtual ~BucketNotExistsException() {}; - virtual const std::string message(void) const { - return "BucketNotExistsException"; + virtual const std::string &message(void) const { + return m_message; } const PolicyBucketId &bucketId(void) const { @@ -46,6 +48,7 @@ public: private: PolicyBucketId m_bucketId; + std::string m_message; }; } /* namespace Cynara */ diff --git a/src/common/exceptions/BucketRecordCorruptedException.h b/src/common/exceptions/BucketRecordCorruptedException.h index 92b29f7..a5ffb7d 100644 --- a/src/common/exceptions/BucketRecordCorruptedException.h +++ b/src/common/exceptions/BucketRecordCorruptedException.h @@ -39,25 +39,25 @@ public: BucketRecordCorruptedException withLineNumber(const size_t &lineNumber) const { BucketRecordCorruptedException copy(*this); copy.m_lineNumber = lineNumber; - copy.m_whatMsg.clear(); + copy.m_message.clear(); return copy; } BucketRecordCorruptedException withFilename(const std::string &filename) const { BucketRecordCorruptedException copy(*this); copy.m_filename = filename; - copy.m_whatMsg.clear(); + copy.m_message.clear(); return copy; } - virtual const std::string message(void) const { - if (m_whatMsg.empty()) { - m_whatMsg = "Bucket record corrupted at" + virtual const std::string &message(void) const { + if (m_message.empty()) { + m_message = "Bucket record corrupted at" + formatedFilename() + formatedLineNumber() + ": <" + slicedLine() + ">"; } - return m_whatMsg; + return m_message; } const std::string &filename(void) const { @@ -91,7 +91,7 @@ private: size_t m_lineNumber; std::string m_line; std::string m_filename; - mutable std::string m_whatMsg; + mutable std::string m_message; }; } /* namespace Cynara */ diff --git a/src/common/exceptions/BucketSerializationException.h b/src/common/exceptions/BucketSerializationException.h index 1e02823..23ff4cc 100644 --- a/src/common/exceptions/BucketSerializationException.h +++ b/src/common/exceptions/BucketSerializationException.h @@ -29,13 +29,12 @@ namespace Cynara { class BucketSerializationException : public DatabaseException { public: - BucketSerializationException(const PolicyBucketId &bucketId) : m_bucketId(bucketId) {} + BucketSerializationException(const PolicyBucketId &bucket) : m_bucketId(bucket) { + m_message = "Could not serialize bucket " + bucketId(); + } virtual ~BucketSerializationException() {}; - const std::string message(void) const { - if (m_message.empty()) { - m_message = "Could not serialize bucket " + m_bucketId; - } + const std::string &message(void) const { return m_message; } @@ -44,7 +43,7 @@ public: } private: - mutable std::string m_message; + std::string m_message; PolicyBucketId m_bucketId; }; diff --git a/src/common/exceptions/CannotCreateFileException.h b/src/common/exceptions/CannotCreateFileException.h index 67c1d67..f7b8d92 100644 --- a/src/common/exceptions/CannotCreateFileException.h +++ b/src/common/exceptions/CannotCreateFileException.h @@ -31,13 +31,12 @@ namespace Cynara { class CannotCreateFileException : public DatabaseException { public: - CannotCreateFileException(const std::string &filename) : m_filename(filename) {}; + CannotCreateFileException(const std::string &file) : m_filename(file) { + m_message = "File " + filename() + " cannot be created"; + }; virtual ~CannotCreateFileException() {}; - const std::string message(void) const { - if (m_message.empty()) { - m_message = "File " + filename() + " cannot be created"; - } + const std::string &message(void) const { return m_message; } @@ -46,7 +45,7 @@ public: } private: - mutable std::string m_message; + std::string m_message; std::string m_filename; }; diff --git a/src/common/exceptions/ContextErrorException.h b/src/common/exceptions/ContextErrorException.h index 771065a..692b26e 100644 --- a/src/common/exceptions/ContextErrorException.h +++ b/src/common/exceptions/ContextErrorException.h @@ -29,12 +29,15 @@ namespace Cynara { class ContextErrorException : public Exception { public: - ContextErrorException() = default; + ContextErrorException() : m_message("ContextErrorException") {} virtual ~ContextErrorException() {}; - virtual const std::string message(void) const { - return "ContextErrorException"; + virtual const std::string &message(void) const { + return m_message; } + +private: + std::string m_message; }; } /* namespace Cynara */ diff --git a/src/common/exceptions/DefaultBucketDeletionException.h b/src/common/exceptions/DefaultBucketDeletionException.h index a4742be..7982f90 100644 --- a/src/common/exceptions/DefaultBucketDeletionException.h +++ b/src/common/exceptions/DefaultBucketDeletionException.h @@ -31,12 +31,16 @@ namespace Cynara { class DefaultBucketDeletionException : public Exception { public: - DefaultBucketDeletionException() = default; + DefaultBucketDeletionException() : m_message("DefaultBucketDeletionException") { + } virtual ~DefaultBucketDeletionException() {}; - virtual const std::string message(void) const { - return "DefaultBucketDeletionException"; + virtual const std::string &message(void) const { + return m_message; } + +private: + std::string m_message; }; } /* namespace Cynara */ diff --git a/src/common/exceptions/DefaultBucketSetNoneException.h b/src/common/exceptions/DefaultBucketSetNoneException.h index 243c4d8..a7b2d4b 100644 --- a/src/common/exceptions/DefaultBucketSetNoneException.h +++ b/src/common/exceptions/DefaultBucketSetNoneException.h @@ -31,12 +31,16 @@ namespace Cynara { class DefaultBucketSetNoneException : public Exception { public: - DefaultBucketSetNoneException() = default; + DefaultBucketSetNoneException() : m_message("DefaultBucketSetNoneException") { + } virtual ~DefaultBucketSetNoneException() {}; - virtual const std::string message(void) const { - return "DefaultBucketSetNoneException"; + virtual const std::string &message(void) const { + return m_message; } + +private: + std::string m_message; }; } /* namespace Cynara */ diff --git a/src/common/exceptions/DescriptorNotExistsException.h b/src/common/exceptions/DescriptorNotExistsException.h index 3535b91..ffb6bba 100644 --- a/src/common/exceptions/DescriptorNotExistsException.h +++ b/src/common/exceptions/DescriptorNotExistsException.h @@ -35,19 +35,17 @@ class DescriptorNotExistsException : public Exception { public: DescriptorNotExistsException() = delete; DescriptorNotExistsException(int desc) { - std::ostringstream stream; - stream << "trying access not existing descriptor [" << desc << "]"; - m_whatMsg = stream.str(); + m_message = "trying access not existing descriptor [" + std::to_string(desc) + "]"; } virtual ~DescriptorNotExistsException() {}; - virtual const std::string message(void) const { - return m_whatMsg; + virtual const std::string &message(void) const { + return m_message; } private: - std::string m_whatMsg; + std::string m_message; }; } // namespace Cynara diff --git a/src/common/exceptions/Exception.h b/src/common/exceptions/Exception.h index c5eb709..5dbaa6b 100644 --- a/src/common/exceptions/Exception.h +++ b/src/common/exceptions/Exception.h @@ -46,7 +46,7 @@ public: return m_whatMessage.c_str(); } - virtual const std::string message(void) const = 0; + virtual const std::string &message(void) const = 0; private: std::string m_backtrace; diff --git a/src/common/exceptions/FileNotFoundException.h b/src/common/exceptions/FileNotFoundException.h index 4c446e2..2c43ca5 100644 --- a/src/common/exceptions/FileNotFoundException.h +++ b/src/common/exceptions/FileNotFoundException.h @@ -31,13 +31,12 @@ namespace Cynara { class FileNotFoundException : public DatabaseException { public: - FileNotFoundException(const std::string &filename) : m_filename(filename) {}; - virtual ~FileNotFoundException() {}; + FileNotFoundException(const std::string &file) : m_filename(file) { + m_message = "File " + filename() + " not found or corrupted badly"; + } + virtual ~FileNotFoundException() {} - const std::string message(void) const { - if (m_message.empty()) { - m_message = "File " + filename() + " not found or corrupted badly"; - } + const std::string &message(void) const { return m_message; } @@ -46,7 +45,7 @@ public: } private: - mutable std::string m_message; + std::string m_message; std::string m_filename; }; diff --git a/src/common/exceptions/InitException.h b/src/common/exceptions/InitException.h index cdb09a2..22f8615 100644 --- a/src/common/exceptions/InitException.h +++ b/src/common/exceptions/InitException.h @@ -31,12 +31,15 @@ namespace Cynara { class InitException : public Exception { public: - InitException() = default; + InitException() : m_message("InitException") {} virtual ~InitException() {}; - virtual const std::string message(void) const { - return "InitException"; + virtual const std::string &message(void) const { + return m_message; } + +private: + std::string m_message; }; } /* namespace Cynara */ diff --git a/src/common/exceptions/InvalidBucketIdException.h b/src/common/exceptions/InvalidBucketIdException.h index f8772e4..6fe40b0 100644 --- a/src/common/exceptions/InvalidBucketIdException.h +++ b/src/common/exceptions/InvalidBucketIdException.h @@ -31,13 +31,12 @@ namespace Cynara { class InvalidBucketIdException : public Exception { public: - InvalidBucketIdException(const std::string &bucketId) : m_bucketId(bucketId) {}; + InvalidBucketIdException(const std::string &bucket) : m_bucketId(bucket) { + m_message = "Bucket ID " + bucketId() + " contains forbidden characters"; + }; virtual ~InvalidBucketIdException() {}; - const std::string message(void) const { - if (m_message.empty()) { - m_message = "Bucket ID " + bucketId() + " contains forbidden characters"; - } + const std::string &message(void) const { return m_message; } @@ -46,7 +45,7 @@ public: } private: - mutable std::string m_message; + std::string m_message; std::string m_bucketId; }; diff --git a/src/common/exceptions/InvalidProtocolException.h b/src/common/exceptions/InvalidProtocolException.h index 9b6a740..65c9f77 100644 --- a/src/common/exceptions/InvalidProtocolException.h +++ b/src/common/exceptions/InvalidProtocolException.h @@ -42,21 +42,21 @@ public: m_exceptionType(exceptionType) { switch(m_exceptionType) { case InvalidSignature: - m_whatMessage = "No valid signature found"; + m_message = "No valid signature found"; break; case WrongOpCode: - m_whatMessage = "Wrong request code"; + m_message = "Wrong request code"; break; case Other: - m_whatMessage = "Unknown problem"; + m_message = "Unknown problem"; break; } } virtual ~InvalidProtocolException() {}; - virtual const std::string message(void) const { - return m_whatMessage; + virtual const std::string &message(void) const { + return m_message; } ExceptionType exceptionType(void) const { @@ -64,7 +64,7 @@ public: } private: - std::string m_whatMessage; + std::string m_message; ExceptionType m_exceptionType; }; diff --git a/src/common/exceptions/NoMemoryException.h b/src/common/exceptions/NoMemoryException.h index 2eca090..8c811f5 100644 --- a/src/common/exceptions/NoMemoryException.h +++ b/src/common/exceptions/NoMemoryException.h @@ -34,17 +34,17 @@ class NoMemoryException : public Exception { public: NoMemoryException() = delete; NoMemoryException(const std::string &errorMsg) { - m_whatMessage = "NoMemoryException with message <" + errorMsg + ">"; + m_message = "NoMemoryException with message <" + errorMsg + ">"; } virtual ~NoMemoryException() {}; - virtual const std::string message(void) const { - return m_whatMessage; + virtual const std::string &message(void) const { + return m_message; } private: - std::string m_whatMessage; + std::string m_message; }; } // namespace Cynara diff --git a/src/common/exceptions/NotImplementedException.h b/src/common/exceptions/NotImplementedException.h index 8ca3762..c29e616 100644 --- a/src/common/exceptions/NotImplementedException.h +++ b/src/common/exceptions/NotImplementedException.h @@ -31,12 +31,15 @@ namespace Cynara { class NotImplementedException : public Exception { public: - NotImplementedException() = default; + NotImplementedException() :m_message("NotImplementedException") {} virtual ~NotImplementedException() {}; - virtual const std::string message(void) const { - return "NotImplementedException"; + virtual const std::string &message(void) const { + return m_message; } + +private: + std::string m_message; }; } /* namespace Cynara */ diff --git a/src/common/exceptions/NullPointerException.h b/src/common/exceptions/NullPointerException.h index e735555..9336332 100644 --- a/src/common/exceptions/NullPointerException.h +++ b/src/common/exceptions/NullPointerException.h @@ -34,19 +34,17 @@ class NullPointerException : public Exception { public: NullPointerException() = delete; NullPointerException(const char *varName) { - m_whatMsg = std::string("unexpected null value in variable <") - + std::string(varName) - + std::string(">"); + m_message = "unexpected null value in variable <" + std::string(varName) + ">"; } virtual ~NullPointerException() {}; - virtual const std::string message(void) const { - return m_whatMsg; + virtual const std::string &message(void) const { + return m_message; } private: - std::string m_whatMsg; + std::string m_message; }; } // namespace Cynara diff --git a/src/common/exceptions/OutOfDataException.h b/src/common/exceptions/OutOfDataException.h index 6420819..776d2f4 100644 --- a/src/common/exceptions/OutOfDataException.h +++ b/src/common/exceptions/OutOfDataException.h @@ -35,20 +35,18 @@ class OutOfDataException : public Exception { public: OutOfDataException() = delete; OutOfDataException(size_t dataRange, size_t accessTry) { - std::ostringstream stream; - stream << "trying access [" << accessTry << "]"; - stream << " which exceeds data range [" << dataRange << "]"; - m_whatMsg = stream.str(); + m_message = "trying access [" + std::to_string(accessTry) + "]" + + " which exceeds data range [" + std::to_string(dataRange) + "]"; } virtual ~OutOfDataException() {}; - virtual const std::string message(void) const { - return m_whatMsg; + virtual const std::string &message(void) const { + return m_message; } private: - std::string m_whatMsg; + std::string m_message; }; } // namespace Cynara diff --git a/src/common/exceptions/PluginErrorException.h b/src/common/exceptions/PluginErrorException.h index a29eab5..1a6c7eb 100644 --- a/src/common/exceptions/PluginErrorException.h +++ b/src/common/exceptions/PluginErrorException.h @@ -35,7 +35,7 @@ public: "privilege <" + key.privilege().toString() + ">"; } - const std::string message(void) const { + const std::string &message(void) const { return m_message; } diff --git a/src/common/exceptions/PluginNotFoundException.h b/src/common/exceptions/PluginNotFoundException.h index 4492a53..010f2f5 100644 --- a/src/common/exceptions/PluginNotFoundException.h +++ b/src/common/exceptions/PluginNotFoundException.h @@ -35,21 +35,19 @@ class PluginNotFoundException : public Exception { public: PluginNotFoundException() = delete; PluginNotFoundException(const PolicyResult &result) { - std::ostringstream stream; - stream << "No proper plugin found to interprete PolicyResult {type = [" - << result.policyType() << "], metadata = <" - << result.metadata().substr(0, 20) << ">}"; - m_whatMessage = stream.str(); + m_message = "No proper plugin found to interprete PolicyResult {type = [" + + std::to_string(result.policyType()) + "], metadata = <" + + result.metadata().substr(0, 20) + ">}"; } virtual ~PluginNotFoundException() {}; - virtual const std::string message(void) const { - return m_whatMessage; + virtual const std::string &message(void) const { + return m_message; } private: - std::string m_whatMessage; + std::string m_message; }; } // namespace Cynara diff --git a/src/common/exceptions/UnexpectedErrorException.h b/src/common/exceptions/UnexpectedErrorException.h index 3080c0f..4e0261d 100644 --- a/src/common/exceptions/UnexpectedErrorException.h +++ b/src/common/exceptions/UnexpectedErrorException.h @@ -34,26 +34,21 @@ class UnexpectedErrorException : public Exception { public: UnexpectedErrorException() = delete; UnexpectedErrorException(int errorCode, const char *errorMsg) { - std::ostringstream stream; - stream << "UnexpectedErrorException with errorCode =[" << errorCode << "] and message <"; - stream << errorMsg << ">"; - m_whatMessage = stream.str(); + m_message = "UnexpectedErrorException with errorCode =[" + std::to_string(errorCode) + + "] and message <" + errorMsg + ">"; } UnexpectedErrorException(const char *errorMsg) { - std::ostringstream stream; - stream << "UnexpectedErrorException with message <"; - stream << errorMsg << ">"; - m_whatMessage = stream.str(); + m_message = "UnexpectedErrorException with message <" + std::string(errorMsg) + ">"; } virtual ~UnexpectedErrorException() {}; - virtual const std::string message(void) const { - return m_whatMessage; + virtual const std::string &message(void) const { + return m_message; } private: - std::string m_whatMessage; + std::string m_message; }; } // namespace Cynara -- 2.7.4 From d3bdd0f9b37d8050b6b348294d353b7981f6f9c5 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Tue, 18 Nov 2014 17:04:33 +0100 Subject: [PATCH 08/16] Add invalidation mechanism for plugins Every time the cynara storage is changed all data stored in service and client plugins should be invalidated. Change-Id: I7537aa8a6d3ea28efed0f3e0f986ae51d7f9d344 --- src/client-common/cache/CapacityCache.cpp | 4 ++++ src/client-common/plugins/NaiveInterpreter.h | 2 ++ src/common/plugin/ExternalPluginInterface.h | 7 +++++++ src/common/plugin/PluginManager.cpp | 6 ++++++ src/common/plugin/PluginManager.h | 1 + src/service/logic/Logic.cpp | 1 + 6 files changed, 21 insertions(+) diff --git a/src/client-common/cache/CapacityCache.cpp b/src/client-common/cache/CapacityCache.cpp index 3174744..25ae6ad 100644 --- a/src/client-common/cache/CapacityCache.cpp +++ b/src/client-common/cache/CapacityCache.cpp @@ -87,6 +87,10 @@ int CapacityCache::get(const ClientSession &session, const PolicyKey &key) { void CapacityCache::clear(void) { m_keyUsage.clear(); m_keyValue.clear(); + m_pluginManager.invalidateAll(); + for (auto &plugin : m_plugins) { + plugin.second->invalidate(); + } } std::string CapacityCache::keyToString(const PolicyKey &key) { diff --git a/src/client-common/plugins/NaiveInterpreter.h b/src/client-common/plugins/NaiveInterpreter.h index 8099362..059554d 100644 --- a/src/client-common/plugins/NaiveInterpreter.h +++ b/src/client-common/plugins/NaiveInterpreter.h @@ -48,6 +48,8 @@ public: const std::vector &getSupportedPolicyTypes(void) { return s_supportedTypes; } + + void invalidate(void) {} private: static const std::vector s_supportedTypes; }; diff --git a/src/common/plugin/ExternalPluginInterface.h b/src/common/plugin/ExternalPluginInterface.h index bf3c7fe..ddd8363 100644 --- a/src/common/plugin/ExternalPluginInterface.h +++ b/src/common/plugin/ExternalPluginInterface.h @@ -52,6 +52,13 @@ public: * Policy type supported by plugin. */ virtual const std::vector &getSupportedPolicyTypes(void) = 0; + + /** + * Informs, that every data stored based on previously given input + * should be invalidated. + */ + virtual void invalidate(void) = 0; + virtual ~ExternalPluginInterface() {} }; diff --git a/src/common/plugin/PluginManager.cpp b/src/common/plugin/PluginManager.cpp index 8062683..c8a38c5 100644 --- a/src/common/plugin/PluginManager.cpp +++ b/src/common/plugin/PluginManager.cpp @@ -65,6 +65,12 @@ ExternalPluginPtr PluginManager::getPlugin(PolicyType pType) { return m_plugins[pType]; } +void PluginManager::invalidateAll(void) { + for (auto &plugin : m_plugins) { + plugin.second->invalidate(); + } +} + void PluginManager::loadPlugins(void) { struct dirent **nameList = NULL; int fileAmount = scandir(m_dir.c_str(), &nameList, pluginFilter, alphasort); diff --git a/src/common/plugin/PluginManager.h b/src/common/plugin/PluginManager.h index c2372e6..8de33ae 100644 --- a/src/common/plugin/PluginManager.h +++ b/src/common/plugin/PluginManager.h @@ -38,6 +38,7 @@ class PluginManager { public: PluginManager(const std::string &pluginDir); ExternalPluginPtr getPlugin(PolicyType pType); + void invalidateAll(void); ~PluginManager(); private: diff --git a/src/service/logic/Logic.cpp b/src/service/logic/Logic.cpp index 8f51af5..684eac3 100644 --- a/src/service/logic/Logic.cpp +++ b/src/service/logic/Logic.cpp @@ -324,6 +324,7 @@ void Logic::contextClosed(RequestContextPtr context) { void Logic::onPoliciesChanged(void) { m_storage->save(); m_socketManager->disconnectAllClients(); + m_pluginManager->invalidateAll(); //todo remove all saved contexts (if there will be any saved contexts) } -- 2.7.4 From 5476b76bdebd6647e1067a88a95f66f159d4875b Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 25 Nov 2014 20:44:14 +0100 Subject: [PATCH 09/16] Update documentation of cynara-admin.h Remove out of date information. Since database integrity is fixed database cannot be in partialy changed state. If changing database fails it is rolled back to the before operation state. Change-Id: Idd815cb89a4e49cd75d52abe73a4c7517adaa7fd --- src/include/cynara-admin.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/include/cynara-admin.h b/src/include/cynara-admin.h index cd51465..3b737d8 100644 --- a/src/include/cynara-admin.h +++ b/src/include/cynara-admin.h @@ -139,9 +139,6 @@ int cynara_admin_finish(struct cynara_admin *p_cynara_admin); * Numerical values of defines CYNARA_ADMIN_... may change, so usage of defines names is strongly * recommended. * - * In case of error, database may end up in a state, where changes are partially applied. This is - * going to be fixed along with introduction of transactions in future releases. - * * \param[in] p_cynara_admin cynara admin structure. * \param[in] policies NULL terminated array of pointers to policy structures. * -- 2.7.4 From fab54adac57dd1fcdf1b304603600599b7e1e5f9 Mon Sep 17 00:00:00 2001 From: Aleksander Zdyb Date: Wed, 29 Oct 2014 09:42:33 +0100 Subject: [PATCH 10/16] Add convenient typedefs in admin ApiInterface Change-Id: I9cd8b674a00aba90432609a4cf351e4c8fae3e66 --- src/admin/api/ApiInterface.h | 9 ++++++--- src/admin/logic/Logic.cpp | 4 ++-- src/admin/logic/Logic.h | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/admin/api/ApiInterface.h b/src/admin/api/ApiInterface.h index 62c40e5..4f7eed0 100644 --- a/src/admin/api/ApiInterface.h +++ b/src/admin/api/ApiInterface.h @@ -38,15 +38,18 @@ namespace Cynara { class ApiInterface { public: + + typedef std::map> PoliciesByBucket; + typedef std::map> KeysByBucket; + ApiInterface() = default; virtual ~ApiInterface() {}; - virtual int setPolicies(const std::map> &insertOrUpdate, - const std::map> &remove) = 0; + virtual int setPolicies(const PoliciesByBucket &insertOrUpdate, + const KeysByBucket &remove) = 0; virtual int insertOrUpdateBucket(const PolicyBucketId &bucket, const PolicyResult &policyResult) = 0; virtual int removeBucket(const PolicyBucketId &bucket) = 0; - virtual int adminCheck(const PolicyBucketId &startBucket, bool recursive, const PolicyKey &key, PolicyResult &result) = 0; diff --git a/src/admin/logic/Logic.cpp b/src/admin/logic/Logic.cpp index 506ecbf..67f7172 100644 --- a/src/admin/logic/Logic.cpp +++ b/src/admin/logic/Logic.cpp @@ -106,8 +106,8 @@ int Logic::askCynaraAndInterpreteCodeResponse(Args... args) { } } -int Logic::setPolicies(const std::map> &insertOrUpdate, - const std::map> &remove) { +int Logic::setPolicies(const ApiInterface::PoliciesByBucket &insertOrUpdate, + const ApiInterface::KeysByBucket &remove) { return askCynaraAndInterpreteCodeResponse(insertOrUpdate, remove); } diff --git a/src/admin/logic/Logic.h b/src/admin/logic/Logic.h index a8688c2..c0b3999 100644 --- a/src/admin/logic/Logic.h +++ b/src/admin/logic/Logic.h @@ -43,8 +43,8 @@ public: Logic(); virtual ~Logic() {}; - virtual int setPolicies(const std::map> &insertOrUpdate, - const std::map> &remove); + virtual int setPolicies(const ApiInterface::PoliciesByBucket &insertOrUpdate, + const ApiInterface::KeysByBucket &remove); virtual int insertOrUpdateBucket(const PolicyBucketId &bucket, const PolicyResult &policyResult); virtual int removeBucket(const PolicyBucketId &bucket); -- 2.7.4 From 6fc739e0eeacb82e9ace84c793f365fdcb529b88 Mon Sep 17 00:00:00 2001 From: Aleksander Zdyb Date: Wed, 26 Nov 2014 09:23:06 +0100 Subject: [PATCH 11/16] Add FileLock class A class creating advisory lock on provided file. The file must exist and be openable by the process. Change-Id: Ia5fa4ef51e1a413beb81efd56f807e1434145691 --- src/common/CMakeLists.txt | 1 + src/common/exceptions/DatabaseBusyException.h | 47 +++++++++++++ src/common/exceptions/FileLockAcquiringException.h | 60 +++++++++++++++++ src/common/lock/FileLock.cpp | 77 ++++++++++++++++++++++ src/common/lock/FileLock.h | 44 +++++++++++++ src/service/main/pointers.h | 3 + 6 files changed, 232 insertions(+) create mode 100644 src/common/exceptions/DatabaseBusyException.h create mode 100644 src/common/exceptions/FileLockAcquiringException.h create mode 100644 src/common/lock/FileLock.cpp create mode 100644 src/common/lock/FileLock.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index e8974cb..a8e0632 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -28,6 +28,7 @@ INCLUDE_DIRECTORIES( SET(COMMON_SOURCES ${COMMON_PATH}/config/PathConfig.cpp ${COMMON_PATH}/containers/BinaryQueue.cpp + ${COMMON_PATH}/lock/FileLock.cpp ${COMMON_PATH}/log/log.cpp ${COMMON_PATH}/plugin/PluginManager.cpp ${COMMON_PATH}/protocol/ProtocolAdmin.cpp diff --git a/src/common/exceptions/DatabaseBusyException.h b/src/common/exceptions/DatabaseBusyException.h new file mode 100644 index 0000000..78c90cb --- /dev/null +++ b/src/common/exceptions/DatabaseBusyException.h @@ -0,0 +1,47 @@ +/* + * 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/common/exceptions/DatabaseBusyException.h + * @author Aleksander Zdyb + * @version 1.0 + * @brief This file defines exception thrown when database is busy + */ + +#ifndef SRC_COMMON_EXCEPTIONS_DATABASEBUSYEXCEPTION_H_ +#define SRC_COMMON_EXCEPTIONS_DATABASEBUSYEXCEPTION_H_ + +#include + +#include + +namespace Cynara { + +class DatabaseBusyException : public DatabaseException { +public: + DatabaseBusyException() : m_message("Database busy") {}; + virtual ~DatabaseBusyException() {}; + + const std::string &message(void) const { + return m_message; + } + +private: + std::string m_message; +}; + +} /* namespace Cynara */ + +#endif /* SRC_COMMON_EXCEPTIONS_DATABASEBUSYEXCEPTION_H_ */ diff --git a/src/common/exceptions/FileLockAcquiringException.h b/src/common/exceptions/FileLockAcquiringException.h new file mode 100644 index 0000000..44bc54a --- /dev/null +++ b/src/common/exceptions/FileLockAcquiringException.h @@ -0,0 +1,60 @@ +/* + * 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/common/exceptions/FileLockAcquiringException.h + * @author Aleksander Zdyb + * @version 1.0 + * @brief This file defines exception thrown when file lock cannot be acquired + */ + +#ifndef SRC_COMMON_EXCEPTIONS_FILELOCKACQUIRINGEXCEPTION_H_ +#define SRC_COMMON_EXCEPTIONS_FILELOCKACQUIRINGEXCEPTION_H_ + +#include +#include + +#include + +namespace Cynara { + +class FileLockAcquiringException { +public: + FileLockAcquiringException(const int errNumber) : m_errno(errNumber) { + m_message = "File lock acquiring error [" + std::to_string(errorNumber()) + "]" + + " <" + errorString() + ">"; + }; + virtual ~FileLockAcquiringException() {}; + + const std::string &message(void) const { + return m_message; + } + + int errorNumber(void) const { + return m_errno; + } + + const std::string errorString(void) const { + return strerror(m_errno); + } + +private: + std::string m_message; + int m_errno; +}; + +} /* namespace Cynara */ + +#endif /* SRC_COMMON_EXCEPTIONS_FILELOCKACQUIRINGEXCEPTION_H_ */ diff --git a/src/common/lock/FileLock.cpp b/src/common/lock/FileLock.cpp new file mode 100644 index 0000000..b8bd34a --- /dev/null +++ b/src/common/lock/FileLock.cpp @@ -0,0 +1,77 @@ +/* + * 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/common/lock/FileLock.cpp + * @author Aleksander Zdyb + * @version 1.0 + * @brief A class for acquiring and holding file lock + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "FileLock.h" + +namespace Cynara { + +FileLock::FileLock(const std::string &lockFilename) : m_lockFilename(lockFilename) { + m_fd = ::open(m_lockFilename.c_str(), O_RDONLY); + + if (m_fd < 0) { + LOGE("Could not open lock file <%s>", lockFilename.c_str()); + throw FileLockAcquiringException(errno); + } + + LOGD("File lock file opened"); +} + +FileLock::~FileLock() { + ::close(m_fd); +} + +bool FileLock::tryLock(void) { + int lock = TEMP_FAILURE_RETRY(::flock(m_fd, LOCK_EX | LOCK_NB)); + + if (lock == 0) { + LOGI("File lock acquired"); + return true; + } else if (errno == EWOULDBLOCK) { + LOGI("File lock NOT acquired"); + return false; + } + + throw FileLockAcquiringException(errno); +} + +void FileLock::lock(void) { + int lock = TEMP_FAILURE_RETRY(::flock(m_fd, LOCK_EX)); + + if (lock == -1) + throw FileLockAcquiringException(errno); + + LOGI("File lock acquired"); +} + +} /* namespace Cynara */ diff --git a/src/common/lock/FileLock.h b/src/common/lock/FileLock.h new file mode 100644 index 0000000..53f048f --- /dev/null +++ b/src/common/lock/FileLock.h @@ -0,0 +1,44 @@ +/* + * 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/common/lock/FileLock.h + * @author Aleksander Zdyb + * @version 1.0 + * @brief A class for acquiring and holding file lock + */ + +#ifndef SRC_COMMON_LOCK_FILELOCK_H_ +#define SRC_COMMON_LOCK_FILELOCK_H_ + +#include + +namespace Cynara { + +class FileLock { +public: + explicit FileLock(const std::string &lockFilename); + ~FileLock(); + bool tryLock(void); + void lock(void); + +private: + std::string m_lockFilename; + int m_fd; +}; + +} /* namespace Cynara */ + +#endif /* SRC_COMMON_LOCK_FILELOCK_H_ */ diff --git a/src/service/main/pointers.h b/src/service/main/pointers.h index f32c4ab..db734ae 100644 --- a/src/service/main/pointers.h +++ b/src/service/main/pointers.h @@ -45,6 +45,9 @@ typedef std::shared_ptr StoragePtr; class StorageBackend; typedef std::shared_ptr StorageBackendPtr; +class FileLock; +typedef std::unique_ptr FileLockUniquePtr; + } // namespace Cynara #endif /* SRC_SERVICE_MAIN_POINTERS_H_ */ -- 2.7.4 From 957d586061fc56ddcb661a61cb934f78ef502322 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 25 Nov 2014 17:37:59 +0100 Subject: [PATCH 12/16] Introduce cynara_admin_list_policies() admin function Introduce new administrative API function: cynara_admin_list_policies() New function allows listing with filter policies from a single bucket. New admin define CYNARA_ADMIN_ANY is also introduced. It is a wildcard for policy listing and removal. It can be used as client, user or privilege name and matches any policy (even CYNARA_ADMIN_WILDCARD). Change-Id: I9d014ebc8018e3fa6ad897c4de768471e672ac40 --- src/include/cynara-admin-types.h | 11 +++++++ src/include/cynara-admin.h | 63 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/include/cynara-admin-types.h b/src/include/cynara-admin-types.h index 8dd3c66..5978c80 100644 --- a/src/include/cynara-admin-types.h +++ b/src/include/cynara-admin-types.h @@ -63,6 +63,17 @@ struct cynara_admin_policy { */ #define CYNARA_ADMIN_DEFAULT_BUCKET "" +/** + * \name Any + * definition of ANY, that can replace client, user or privilege name. + * ANY matches any string (including WILDCARD) during: + * * policy removal (setPolicies with CYNARA_ADMIN_DELETE) + * * listing policies from a single bucket. + * Using ANY as default policy for bucket or as policy type of inserted policy record + * is forbidden and will cause CYNARA_API_INVALID_PARAM error. + */ +#define CYNARA_ADMIN_ANY "#" + #ifdef __cplusplus } #endif diff --git a/src/include/cynara-admin.h b/src/include/cynara-admin.h index 3b737d8..595ad6a 100644 --- a/src/include/cynara-admin.h +++ b/src/include/cynara-admin.h @@ -85,7 +85,7 @@ int cynara_admin_initialize(struct cynara_admin **pp_cynara_admin); * This API releases inner library structures and destroys cynara_admin structure. * * \par Sync (or) Async: - * This is a Synchronous API. + * This is a synchronous API. * * \par Important notes: * No invocations of cynara-admin library API functions are allowed after call to @@ -132,7 +132,7 @@ int cynara_admin_finish(struct cynara_admin *p_cynara_admin); * However, considered buckets must exist before referring to them in policies. * * \par Sync (or) Async: - * This is a Synchronous API. + * This is a synchronous API. * * \par Important notes: * When plugin API will be specified, there will be more valid types to pass as result. @@ -171,7 +171,7 @@ int cynara_admin_set_policies(struct cynara_admin *p_cynara_admin, * CYNARA_ADMIN_DELETE, a bucket is removed with all policies that were kept in it. * * \par Sync (or) Async: - * This is a Synchronous API. + * This is a synchronous API. * * \par Important notes: * When plugin API will be specified, there will be more valid types to pass as operation / default @@ -245,6 +245,63 @@ int cynara_admin_check(struct cynara_admin *p_cynara_admin, const char *client, const char *user, const char *privilege, int *result, char **result_extra); +/** + * \par Description: + * Lists filtered cynara policies from single bucket. + * + * \par Purpose: + * This API should be used to list policies from single bucket. + * + * \par Typical use case: + * List all policies matching defined filter. + * + * \par Method of function operation: + * Policies are arranged into buckets. Every bucket contains set of policies. Each of policies are + * identified with tripple {client, user, privilege}. Function lists all policies from single bucket + * with matching client, user and privilege names. + * + * CYNARA_ADMIN_ANY can be used to match any client, user or privilege, e.g. + * + * List with paramaters: {client = CYNARA_ADMIN_ANY, user = "alice", privilege = CYNARA_ADMIN_ANY} + * will match all policies related to "alice", so will match {"app1", "alice", "gps"} and + * {CYNARA_ADMIN_WILDCARD, "alice", "sms"}, but won't match {"app3", CYNARA_ADMIN_WILDCARD, "call"}. + * + * List with paramaters: {client = "calculator", user = CYNARA_ADMIN_WILDCARD, + * privilege = CYNARA_ADMIN_ANY} will match {"calculator", CYNARA_ADMIN_WILDCARD, "sms"} but won't + * match {CYNARA_ADMIN_WILDCARD, CYNARA_ADMIN_WILDCARD, "sms"} nor {"calculator", "bob", "sms"} + * + * Matching policies are returned as NULL terminated array of pointers to cynara_admin_policy + * structures. + * + * If any of: bucket, client, user, privilege, policies is NULL then CYNARA_API_INVALID_PARAM + * is returned. + * If there is no bucket with given name CYNARA_API_BUCKET_NOT_FOUND is returned. + * + * In case of successful call CYNARA_API_SUCCESS is returned and *policies points to newly created + * array of pointers to struct cynara_admin_policy. It is responsibility of caller to release: + * * all non-NULL const char* pointers in all cynara_admin_policy structures; + * * all pointers to cynara_admin_policy structures kept in *policies array; + * * *policies array itself. + * All allocation made by cynara admin library are done with malloc(3) function and must be released + * with free(3) function. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \param[in] p_cynara_admin cynara admin structure. + * \param[in] bucket name. + * \param[in] client filter for client name. + * \param[in] user filter for user name. + * \param[in] privilege filter for privilege. + * \param[out] policies placeholder for NULL terminated array of pointers to policy structures. + * + * \return CYNARA_API_SUCCESS on success, or error code otherwise. + * + * \brief Lists policies from single bucket in cynara database. + */ +int cynara_admin_list_policies(struct cynara_admin *p_cynara_admin, const char *bucket, + const char *client, const char *user, const char *privilege, + struct cynara_admin_policy ***policies); #ifdef __cplusplus } #endif -- 2.7.4 From 6dcb8e5566a250f4c6b2850afb6cf9a2db640bd4 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 25 Nov 2014 18:15:09 +0100 Subject: [PATCH 13/16] Enhance PolicyKey and PolicyKeyFeature by ANY wildcard Enhance PolicyKey and PolicyKeyFeature classes, so they can hold new ANY wildcard as user, client or privilege. New wildcard can be used for listing and removal of many policies. It matches any PolicyKeyFeature. Minor cleanup in class: missing voids added, public section reordered Change-Id: Icad8e06b87a014fc2fbab32e0553ddd76e5bb06d --- src/common/types/PolicyKey.cpp | 11 +++-- src/common/types/PolicyKey.h | 95 +++++++++++++++++++++++++++--------------- test/types/policykey.cpp | 16 ++++--- 3 files changed, 80 insertions(+), 42 deletions(-) diff --git a/src/common/types/PolicyKey.cpp b/src/common/types/PolicyKey.cpp index 14b3bc6..ffb1400 100644 --- a/src/common/types/PolicyKey.cpp +++ b/src/common/types/PolicyKey.cpp @@ -25,15 +25,18 @@ #include +#include + namespace Cynara { -std::string PolicyKeyFeature::m_wildcardValue = "*"; +const std::string PolicyKeyFeature::m_wildcardValue = CYNARA_ADMIN_WILDCARD; +const std::string PolicyKeyFeature::m_anyValue = CYNARA_ADMIN_ANY; -const std::string &PolicyKeyFeature::toString() const { - return isWildcard() ? m_wildcardValue : value(); +const std::string &PolicyKeyFeature::toString(void) const { + return value(); } -std::string PolicyKey::toString() const { +std::string PolicyKey::toString(void) const { std::stringstream ss; ss << client().toString() << "\t" << user().toString() << "\t" diff --git a/src/common/types/PolicyKey.h b/src/common/types/PolicyKey.h index 3f65c58..4fed189 100644 --- a/src/common/types/PolicyKey.h +++ b/src/common/types/PolicyKey.h @@ -22,8 +22,8 @@ policy rule */ -#ifndef CYNARA_COMMON_TYPES_POLICYKEY_H -#define CYNARA_COMMON_TYPES_POLICYKEY_H +#ifndef CYNARA_COMMON_TYPES_POLICYKEY_H_ +#define CYNARA_COMMON_TYPES_POLICYKEY_H_ #include #include @@ -39,32 +39,59 @@ public: PolicyKeyFeature(const PolicyKeyFeature &) = default; PolicyKeyFeature(PolicyKeyFeature &&) = default; + PolicyKeyFeature& operator=(const PolicyKeyFeature &) = default; + PolicyKeyFeature& operator=(PolicyKeyFeature &&) = default; + typedef std::string ValueType; static PolicyKeyFeature create(ValueType value) { return PolicyKeyFeature(value); } - static PolicyKeyFeature createWildcard() { - return PolicyKeyFeature(); + static PolicyKeyFeature createWildcard(void) { + return PolicyKeyFeature(m_wildcardValue); + } + + static PolicyKeyFeature createAny(void) { + return PolicyKeyFeature(m_anyValue); } // TODO: Different features (client, user, privilege) // shouldn't be comparable bool operator==(const PolicyKeyFeature &other) const { - return anyWildcard(*this, other) || valuesMatch(*this, other); + return valuesMatch(*this, other); } bool operator==(const PolicyKeyFeature::ValueType &other) const { - return anyWildcard(*this, other) || valuesMatch(*this, other); + return valuesMatch(*this, PolicyKeyFeature(other)); } - const std::string &toString() const; + const std::string &toString(void) const; + + const ValueType &value(void) const { + return m_value; + } + + bool isWildcard(void) const { + return m_isWildcard; + } + + bool isAny(void) const { + return m_isAny; + } + + bool matchFilter(const PolicyKeyFeature &filter) const { + return filter.isAny() || valuesMatch(*this, filter); + } protected: - PolicyKeyFeature(const ValueType &value) : m_value(value), - m_isWildcard(value == PolicyKeyFeature::m_wildcardValue) {} - PolicyKeyFeature() : m_value(m_wildcardValue), m_isWildcard(true) {} + explicit PolicyKeyFeature(const ValueType &value) : m_value(value), + m_isWildcard(value == PolicyKeyFeature::m_wildcardValue), + m_isAny(value == PolicyKeyFeature::m_anyValue) {} + + static bool anyAny(const PolicyKeyFeature &pkf1, const PolicyKeyFeature &pkf2) { + return pkf1.isAny() || pkf2.isAny(); + } static bool anyWildcard(const PolicyKeyFeature &pkf1, const PolicyKeyFeature &pkf2) { return pkf1.isWildcard() || pkf2.isWildcard(); @@ -77,15 +104,10 @@ protected: private: ValueType m_value; bool m_isWildcard; - static std::string m_wildcardValue; + bool m_isAny; -public: - bool isWildcard() const { - return m_isWildcard; - } - const ValueType& value() const { - return m_value; - } + const static std::string m_wildcardValue; + const static std::string m_anyValue; }; class PolicyKey @@ -93,41 +115,48 @@ class PolicyKey public: PolicyKey(const PolicyKeyFeature &clientId, const PolicyKeyFeature &userId, - const PolicyKeyFeature &privilegeId) + const PolicyKeyFeature &privilegeId) : m_client(clientId), m_user(userId), m_privilege(privilegeId) {}; PolicyKey(const PolicyKeyFeature::ValueType &clientId, - const PolicyKeyFeature::ValueType &userId, - const PolicyKeyFeature::ValueType &privilegeId) + const PolicyKeyFeature::ValueType &userId, + const PolicyKeyFeature::ValueType &privilegeId) : m_client(clientId), m_user(userId), m_privilege(privilegeId) {}; PolicyKey(const PolicyKey &) = default; PolicyKey(PolicyKey &&) = default; + PolicyKey& operator=(const PolicyKey &) = default; + PolicyKey& operator=(PolicyKey &&) = default; + bool operator==(const PolicyKey &other) const { return std::tie(m_client, m_user, m_privilege) - == std::tie(other.m_client, other.m_user, other.m_privilege); + == std::tie(other.m_client, other.m_user, other.m_privilege); } - std::string toString() const; - -private: - PolicyKeyFeature m_client; - PolicyKeyFeature m_user; - PolicyKeyFeature m_privilege; + std::string toString(void) const; -public: - const PolicyKeyFeature &client() const { + const PolicyKeyFeature &client(void) const { return m_client; } - const PolicyKeyFeature &user() const { + const PolicyKeyFeature &user(void) const { return m_user; } - const PolicyKeyFeature &privilege() const { + const PolicyKeyFeature &privilege(void) const { return m_privilege; } + + bool matchFilter(const PolicyKey &filter) const { + return m_client.matchFilter(filter.m_client) && m_user.matchFilter(filter.m_user) + && m_privilege.matchFilter(filter.m_privilege); + } + +private: + PolicyKeyFeature m_client; + PolicyKeyFeature m_user; + PolicyKeyFeature m_privilege; }; bool operator ==(const PolicyKeyFeature::ValueType &pkf1, const PolicyKeyFeature &pkf2); @@ -135,4 +164,4 @@ bool operator ==(const PolicyKeyFeature::ValueType &pkf1, const PolicyKeyFeature } /* namespace Cynara */ -#endif /* CYNARA_COMMON_TYPES_POLICYKEY_H */ +#endif /* CYNARA_COMMON_TYPES_POLICYKEY_H_ */ diff --git a/test/types/policykey.cpp b/test/types/policykey.cpp index 228cb98..5556065 100644 --- a/test/types/policykey.cpp +++ b/test/types/policykey.cpp @@ -20,14 +20,13 @@ * @brief Tests for Cynara::PolicyKey */ - - #include #include #include "../helpers.h" -#include "types/PolicyKey.h" +#include +#include using namespace Cynara; @@ -38,8 +37,15 @@ TEST(PolicyKey, to_string) { ASSERT_EQ("c\tu\tp", pk1.toString()); PolicyKey pk2(PKF::createWildcard(), PKF::createWildcard(), PKF::createWildcard()); - ASSERT_EQ("*\t*\t*", pk2.toString()); + ASSERT_EQ(CYNARA_ADMIN_WILDCARD "\t" CYNARA_ADMIN_WILDCARD "\t" CYNARA_ADMIN_WILDCARD, + pk2.toString()); PolicyKey pk3(PKF::createWildcard(), PKF::create("u"), PKF::createWildcard()); - ASSERT_EQ("*\tu\t*", pk3.toString()); + ASSERT_EQ(CYNARA_ADMIN_WILDCARD "\tu\t" CYNARA_ADMIN_WILDCARD, pk3.toString()); + + PolicyKey pk4(PKF::createAny(), PKF::createAny(), PKF::createAny()); + ASSERT_EQ(CYNARA_ADMIN_ANY "\t" CYNARA_ADMIN_ANY "\t" CYNARA_ADMIN_ANY, pk4.toString()); + + PolicyKey pk5(PKF::createWildcard(), PKF::create("u"), PKF::createAny()); + ASSERT_EQ(CYNARA_ADMIN_WILDCARD "\tu\t" CYNARA_ADMIN_ANY, pk5.toString()); } -- 2.7.4 From b03a7e8501c39019e62de3f198f2b09ea751c405 Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Tue, 25 Nov 2014 20:39:41 +0100 Subject: [PATCH 14/16] Implement cynara_admin_list_policies in admin-api layer Implementation is complete on admin-api layer. ApiInterface of libcynara-admin is enhanced by listPolicies method. Its implementation in Logic layer of admin library is stubbed. Change-Id: I25f2d4dbc8616717c7e19835c676b218615df9eb --- src/admin/api/ApiInterface.h | 2 + src/admin/api/admin-api.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++ src/admin/logic/Logic.cpp | 6 +++ src/admin/logic/Logic.h | 3 +- 4 files changed, 102 insertions(+), 1 deletion(-) diff --git a/src/admin/api/ApiInterface.h b/src/admin/api/ApiInterface.h index 4f7eed0..6628b2c 100644 --- a/src/admin/api/ApiInterface.h +++ b/src/admin/api/ApiInterface.h @@ -52,6 +52,8 @@ public: virtual int removeBucket(const PolicyBucketId &bucket) = 0; virtual int adminCheck(const PolicyBucketId &startBucket, bool recursive, const PolicyKey &key, PolicyResult &result) = 0; + virtual int listPolicies(const PolicyBucketId &bucket, const PolicyKey &filter, + std::vector &policies) = 0; }; diff --git a/src/admin/api/admin-api.cpp b/src/admin/api/admin-api.cpp index 1e73ff7..c2a5212 100644 --- a/src/admin/api/admin-api.cpp +++ b/src/admin/api/admin-api.cpp @@ -20,7 +20,9 @@ * @brief Implementation of external libcynara-admin API */ +#include #include +#include #include #include #include @@ -219,3 +221,93 @@ int cynara_admin_check(struct cynara_admin *p_cynara_admin, return CYNARA_API_SUCCESS; }); } + +static int createPoliciesArray(const char *bucket, + const std::vector &policiesVector, + struct cynara_admin_policy ***policies) { + typedef struct cynara_admin_policy Elem; + size_t elems = policiesVector.size(); + + Elem **tab = reinterpret_cast(calloc(elems + 1U, sizeof(Elem*))); + if (!tab) + return CYNARA_API_OUT_OF_MEMORY; + std::unique_ptr> plumber(tab, + [](Elem **tab) { + Elem *elem = *tab; + while (elem) { + free(elem->bucket); + free(elem->client); + free(elem->user); + free(elem->privilege); + free(elem->result_extra); + free(elem++); + } + free(tab); + }); + + for (size_t i = 0U; i < elems; ++i) { + tab[i] = reinterpret_cast(calloc(1U, sizeof(Elem))); + if (!tab[i]) + return CYNARA_API_OUT_OF_MEMORY; + + tab[i]->bucket = strdup(bucket); + if (!tab[i]->bucket) + return CYNARA_API_OUT_OF_MEMORY; + + tab[i]->client = strdup(policiesVector[i].key().client().value().c_str()); + if (!tab[i]->client) + return CYNARA_API_OUT_OF_MEMORY; + tab[i]->user = strdup(policiesVector[i].key().user().value().c_str()); + if (!tab[i]->user) + return CYNARA_API_OUT_OF_MEMORY; + tab[i]->privilege = strdup(policiesVector[i].key().privilege().value().c_str()); + if (!tab[i]->privilege) + return CYNARA_API_OUT_OF_MEMORY; + + tab[i]->result = static_cast(policiesVector[i].result().policyType()); + if (!policiesVector[i].result().metadata().empty()) { + tab[i]->result_extra = strdup(policiesVector[i].result().metadata().c_str()); + if (!tab[i]->result_extra) + return CYNARA_API_OUT_OF_MEMORY; + } + } + *policies = tab; + plumber.release(); + return CYNARA_API_SUCCESS; +} + +CYNARA_API +int cynara_admin_list_policies(struct cynara_admin *p_cynara_admin, const char *bucket, + const char *client, const char *user, const char *privilege, + struct cynara_admin_policy ***policies) { + if (!p_cynara_admin || !p_cynara_admin->impl) + return CYNARA_API_INVALID_PARAM; + if (!bucket || !client || !user || !privilege) + return CYNARA_API_INVALID_PARAM; + if (!policies) + return CYNARA_API_INVALID_PARAM; + + return Cynara::tryCatch([&]() { + Cynara::PolicyKeyFeature::ValueType clientStr; + Cynara::PolicyKeyFeature::ValueType userStr; + Cynara::PolicyKeyFeature::ValueType privilegeStr; + Cynara::PolicyBucketId bucketId; + try { + clientStr = client; + userStr = user; + privilegeStr = privilege; + bucketId = bucket; + } catch (const std::length_error &e) { + LOGE("%s", e.what()); + return CYNARA_API_INVALID_PARAM; + } + + std::vector policiesVector; + int ret = p_cynara_admin->impl->listPolicies(bucket, Cynara::PolicyKey(clientStr, userStr, + privilegeStr), policiesVector); + if (ret != CYNARA_API_SUCCESS) + return ret; + + return createPoliciesArray(bucket, policiesVector, policies); + }); +} diff --git a/src/admin/logic/Logic.cpp b/src/admin/logic/Logic.cpp index 67f7172..1bf8a8a 100644 --- a/src/admin/logic/Logic.cpp +++ b/src/admin/logic/Logic.cpp @@ -154,4 +154,10 @@ int Logic::adminCheck(const PolicyBucketId &startBucket, bool recursive, const P return CYNARA_API_SUCCESS; } +int Logic::listPolicies(const PolicyBucketId &bucket UNUSED, const PolicyKey &filter UNUSED, + std::vector &policies UNUSED) { + //stub + return CYNARA_API_SUCCESS; +} + } // namespace Cynara diff --git a/src/admin/logic/Logic.h b/src/admin/logic/Logic.h index c0b3999..3469593 100644 --- a/src/admin/logic/Logic.h +++ b/src/admin/logic/Logic.h @@ -48,9 +48,10 @@ public: virtual int insertOrUpdateBucket(const PolicyBucketId &bucket, const PolicyResult &policyResult); virtual int removeBucket(const PolicyBucketId &bucket); - virtual int adminCheck(const PolicyBucketId &startBucket, bool recursive, const PolicyKey &key, PolicyResult &result); + virtual int listPolicies(const PolicyBucketId &bucket, const PolicyKey &filter, + std::vector &policies); }; } // namespace Cynara -- 2.7.4 From 3b75361a78f41f40d14d81ca9997167e22f2ae8d Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Sat, 29 Nov 2014 15:40:09 +0100 Subject: [PATCH 15/16] Add ListRequest - new class for listing policies Introduced class wraps a request for policies list that can be sent by admin of cynara. Request contains name of bucket that should be searched and a policy key filter. Change-Id: Ie12b8e5d3d997655bf5c4b8356d71ac5817dbb7f --- src/common/CMakeLists.txt | 1 + src/common/request/ListRequest.cpp | 35 ++++++++++++++++++++++ src/common/request/ListRequest.h | 60 +++++++++++++++++++++++++++++++++++++ src/common/request/RequestTaker.cpp | 4 +++ src/common/request/RequestTaker.h | 1 + src/common/request/pointers.h | 3 ++ 6 files changed, 104 insertions(+) create mode 100644 src/common/request/ListRequest.cpp create mode 100644 src/common/request/ListRequest.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index a8e0632..893d146 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -45,6 +45,7 @@ SET(COMMON_SOURCES ${COMMON_PATH}/request/CancelRequest.cpp ${COMMON_PATH}/request/CheckRequest.cpp ${COMMON_PATH}/request/InsertOrUpdateBucketRequest.cpp + ${COMMON_PATH}/request/ListRequest.cpp ${COMMON_PATH}/request/RemoveBucketRequest.cpp ${COMMON_PATH}/request/RequestTaker.cpp ${COMMON_PATH}/request/SetPoliciesRequest.cpp diff --git a/src/common/request/ListRequest.cpp b/src/common/request/ListRequest.cpp new file mode 100644 index 0000000..f8e261e --- /dev/null +++ b/src/common/request/ListRequest.cpp @@ -0,0 +1,35 @@ +/* + * 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/common/list/ListRequest.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file implements policies list request class + */ + +#include + +#include + +#include "ListRequest.h" + +namespace Cynara { + +void ListRequest::execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const { + taker->execute(context, std::dynamic_pointer_cast(self)); +} + +} // namespace Cynara diff --git a/src/common/request/ListRequest.h b/src/common/request/ListRequest.h new file mode 100644 index 0000000..069ea4a --- /dev/null +++ b/src/common/request/ListRequest.h @@ -0,0 +1,60 @@ +/* + * 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/common/list/ListRequest.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file defines policies list request class + */ + +#ifndef SRC_COMMON_REQUEST_LISTREQUEST_H_ +#define SRC_COMMON_REQUEST_LISTREQUEST_H_ + +#include +#include + +#include +#include + +namespace Cynara { + +class ListRequest : public Request { +private: + PolicyBucketId m_bucket; + PolicyKey m_filter; + +public: + ListRequest(const PolicyBucketId &bucket, const PolicyKey &filter, + ProtocolFrameSequenceNumber sequenceNumber) : + Request(sequenceNumber), m_bucket(bucket), m_filter(filter) { + } + + virtual ~ListRequest() {}; + + const PolicyBucketId &bucket(void) const { + return m_bucket; + } + + const PolicyKey &filter(void) const { + return m_filter; + } + + virtual void execute(RequestPtr self, RequestTakerPtr taker, RequestContextPtr context) const; +}; + +} // namespace Cynara + +#endif /* SRC_COMMON_REQUEST_LISTREQUEST_H_ */ diff --git a/src/common/request/RequestTaker.cpp b/src/common/request/RequestTaker.cpp index f46d428..bc6c7a1 100644 --- a/src/common/request/RequestTaker.cpp +++ b/src/common/request/RequestTaker.cpp @@ -54,6 +54,10 @@ void RequestTaker::execute(RequestContextPtr context UNUSED, throw NotImplementedException(); } +void RequestTaker::execute(RequestContextPtr context UNUSED, ListRequestPtr request UNUSED) { + throw NotImplementedException(); +} + void RequestTaker::execute(RequestContextPtr context UNUSED, RemoveBucketRequestPtr request UNUSED) { throw NotImplementedException(); diff --git a/src/common/request/RequestTaker.h b/src/common/request/RequestTaker.h index f190e69..c36b5c9 100644 --- a/src/common/request/RequestTaker.h +++ b/src/common/request/RequestTaker.h @@ -37,6 +37,7 @@ public: virtual void execute(RequestContextPtr context, AgentRegisterRequestPtr request); virtual void execute(RequestContextPtr context, CancelRequestPtr request); virtual void execute(RequestContextPtr context, CheckRequestPtr request); + virtual void execute(RequestContextPtr context, ListRequestPtr request); virtual void execute(RequestContextPtr context, InsertOrUpdateBucketRequestPtr request); virtual void execute(RequestContextPtr context, RemoveBucketRequestPtr request); virtual void execute(RequestContextPtr context, SetPoliciesRequestPtr request); diff --git a/src/common/request/pointers.h b/src/common/request/pointers.h index 19429a9..d984c99 100644 --- a/src/common/request/pointers.h +++ b/src/common/request/pointers.h @@ -45,6 +45,9 @@ typedef std::shared_ptr CheckRequestPtr; class InsertOrUpdateBucketRequest; typedef std::shared_ptr InsertOrUpdateBucketRequestPtr; +class ListRequest; +typedef std::shared_ptr ListRequestPtr; + class RemoveBucketRequest; typedef std::shared_ptr RemoveBucketRequestPtr; -- 2.7.4 From 55e12b580b4e0c66edcec6765dc8bc809b8d258e Mon Sep 17 00:00:00 2001 From: Lukasz Wojciechowski Date: Sat, 29 Nov 2014 16:02:20 +0100 Subject: [PATCH 16/16] Add ListResponse - response class for ListRequest Introduced class wraps a response for policies list that can be sent by admin of cynara. Response contains vector of matched policies and boolean information about bucket validity. If there is no bucket with name that was passed in request - returned vector is empty and bucket validity is false. Change-Id: I208555f7a991e0dc4a531312ebbbef658c95f22b --- src/common/CMakeLists.txt | 1 + src/common/response/ListResponse.cpp | 35 ++++++++++++++++++++ src/common/response/ListResponse.h | 62 +++++++++++++++++++++++++++++++++++ src/common/response/ResponseTaker.cpp | 4 +++ src/common/response/ResponseTaker.h | 1 + src/common/response/pointers.h | 3 ++ 6 files changed, 106 insertions(+) create mode 100644 src/common/response/ListResponse.cpp create mode 100644 src/common/response/ListResponse.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 893d146..f30d335 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -55,6 +55,7 @@ SET(COMMON_SOURCES ${COMMON_PATH}/response/CancelResponse.cpp ${COMMON_PATH}/response/CheckResponse.cpp ${COMMON_PATH}/response/CodeResponse.cpp + ${COMMON_PATH}/response/ListResponse.cpp ${COMMON_PATH}/response/ResponseTaker.cpp ${COMMON_PATH}/sockets/Socket.cpp ${COMMON_PATH}/sockets/SocketClient.cpp diff --git a/src/common/response/ListResponse.cpp b/src/common/response/ListResponse.cpp new file mode 100644 index 0000000..8931ee1 --- /dev/null +++ b/src/common/response/ListResponse.cpp @@ -0,0 +1,35 @@ +/* + * 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/common/response/ListResponse.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file implements policies list response class + */ + +#include + +#include "ListResponse.h" +#include "ResponseTaker.h" + +namespace Cynara { + +void ListResponse::execute(ResponsePtr self, ResponseTakerPtr taker, + RequestContextPtr context) const { + taker->execute(context, std::dynamic_pointer_cast(self)); +} + +} // namespace Cynara diff --git a/src/common/response/ListResponse.h b/src/common/response/ListResponse.h new file mode 100644 index 0000000..ec52736 --- /dev/null +++ b/src/common/response/ListResponse.h @@ -0,0 +1,62 @@ +/* + * 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/common/response/ListResponse.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file defines response class for policies list request + */ + +#ifndef SRC_COMMON_RESPONSE_LISTRESPONSE_H_ +#define SRC_COMMON_RESPONSE_LISTRESPONSE_H_ + +#include + +#include + +#include +#include +#include + +namespace Cynara { + +class ListResponse : public Response { +public: + ListResponse(const std::vector &policies, bool bucketValid, + ProtocolFrameSequenceNumber sequenceNumber) : + Response(sequenceNumber), m_policies(policies), m_bucketValid(bucketValid) { + } + + virtual ~ListResponse() {}; + + virtual void execute(ResponsePtr self, ResponseTakerPtr taker, RequestContextPtr context) const; + + bool isBucketValid(void) const { + return m_bucketValid; + } + + const std::vector &policies(void) const { + return m_policies; + } + +private: + std::vector m_policies; + bool m_bucketValid; +}; + +} // namespace Cynara + +#endif /* SRC_COMMON_RESPONSE_LISTRESPONSE_H_ */ diff --git a/src/common/response/ResponseTaker.cpp b/src/common/response/ResponseTaker.cpp index cf5ae40..0de4371 100644 --- a/src/common/response/ResponseTaker.cpp +++ b/src/common/response/ResponseTaker.cpp @@ -48,4 +48,8 @@ void ResponseTaker::execute(RequestContextPtr context UNUSED, CodeResponsePtr re throw NotImplementedException(); } +void ResponseTaker::execute(RequestContextPtr context UNUSED, ListResponsePtr response UNUSED) { + throw NotImplementedException(); +} + } // namespace Cynara diff --git a/src/common/response/ResponseTaker.h b/src/common/response/ResponseTaker.h index 6256e73..721dc2a 100644 --- a/src/common/response/ResponseTaker.h +++ b/src/common/response/ResponseTaker.h @@ -38,6 +38,7 @@ public: virtual void execute(RequestContextPtr context, CancelResponsePtr response); virtual void execute(RequestContextPtr context, CheckResponsePtr response); virtual void execute(RequestContextPtr context, CodeResponsePtr response); + virtual void execute(RequestContextPtr context, ListResponsePtr response); }; } // namespace Cynara diff --git a/src/common/response/pointers.h b/src/common/response/pointers.h index 378fed4..c5fdb1d 100644 --- a/src/common/response/pointers.h +++ b/src/common/response/pointers.h @@ -42,6 +42,9 @@ typedef std::shared_ptr CheckResponsePtr; class CodeResponse; typedef std::shared_ptr CodeResponsePtr; +class ListResponse; +typedef std::shared_ptr ListResponsePtr; + class Response; typedef std::shared_ptr ResponsePtr; -- 2.7.4