From def3b0096e1e90ba3541037ca668fb5884cae432 Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Mon, 1 Sep 2014 18:38:08 +0200 Subject: [PATCH 01/16] build: install systemd files under CMAKE_INSTALL_PREFIX Don't use absolute path for installation of systemd config files. Change-Id: If796cad7a0fdcd32d8179a0de7bc0958f173e35b Signed-off-by: Rafal Krypa --- systemd/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemd/CMakeLists.txt b/systemd/CMakeLists.txt index 4076688..8fc27e7 100644 --- a/systemd/CMakeLists.txt +++ b/systemd/CMakeLists.txt @@ -22,6 +22,6 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/systemd/cynara.socket ${CMAKE_SOURCE_DIR}/systemd/cynara-admin.socket DESTINATION - /usr/lib/systemd/system + lib/systemd/system ) -- 2.7.4 From b8e1998ecd034e8bf2b028ede186d6a32d7758f9 Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Wed, 3 Sep 2014 14:03:02 +0200 Subject: [PATCH 02/16] build: drop D_GNU_SOURCE flag, refactor symbol visibility setting Cynara code doesn't use GNU specific features. There is no need to define _GNU_SOURCE. Also set -fvisibility=hidden by default for all targets and change it only where needed (for building common library). Change-Id: Ie8f46522866b4f475c09b4e6e57f824defed0e5c Signed-off-by: Rafal Krypa --- CMakeLists.txt | 3 +++ src/admin/CMakeLists.txt | 1 - src/client-common/CMakeLists.txt | 3 ++- src/client/CMakeLists.txt | 1 - src/common/CMakeLists.txt | 3 ++- src/service/CMakeLists.txt | 5 ----- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4da838..98ae1ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,9 @@ ADD_DEFINITIONS("-Werror") # Make all warnings into errors. ADD_DEFINITIONS("-Wall") # Generate all warnings ADD_DEFINITIONS("-Wextra") # Generate even more extra warnings +# Don't export symbols by default +ADD_DEFINITIONS("-fvisibility=hidden") + STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}") ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"") diff --git a/src/admin/CMakeLists.txt b/src/admin/CMakeLists.txt index e435d29..cc3d7ac 100644 --- a/src/admin/CMakeLists.txt +++ b/src/admin/CMakeLists.txt @@ -36,7 +36,6 @@ ADD_LIBRARY(${TARGET_LIB_CYNARA_ADMIN} SHARED ${LIB_CYNARA_ADMIN_SOURCES}) SET_TARGET_PROPERTIES( ${TARGET_LIB_CYNARA_ADMIN} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden" SOVERSION ${LIB_CYNARA_ADMIN_VERSION_MAJOR} VERSION ${LIB_CYNARA_ADMIN_VERSION} ) diff --git a/src/client-common/CMakeLists.txt b/src/client-common/CMakeLists.txt index fdc41c6..dd05c79 100644 --- a/src/client-common/CMakeLists.txt +++ b/src/client-common/CMakeLists.txt @@ -30,12 +30,13 @@ SET(LIB_CYNARA_COMMON_SOURCES ${LIB_CYNARA_COMMON_PATH}/cache/CapacityCache.cpp ) +ADD_DEFINITIONS("-fvisibility=default") + ADD_LIBRARY(${TARGET_LIB_CYNARA_COMMON} SHARED ${LIB_CYNARA_COMMON_SOURCES}) SET_TARGET_PROPERTIES( ${TARGET_LIB_CYNARA_COMMON} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE" SOVERSION ${LIB_CYNARA_CLIENT_COMMON_VERSION_MAJOR} VERSION ${LIB_CYNARA_CLIENT_COMMON_VERSION} ) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 09a023e..d364e2d 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -38,7 +38,6 @@ ADD_LIBRARY(${TARGET_LIB_CYNARA} SHARED ${LIB_CYNARA_SOURCES}) SET_TARGET_PROPERTIES( ${TARGET_LIB_CYNARA} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden" SOVERSION ${LIB_CYNARA_VERSION_MAJOR} VERSION ${LIB_CYNARA_VERSION} ) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 3113784..f489b44 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -53,12 +53,13 @@ SET(COMMON_SOURCES ${COMMON_SOURCES} ) ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG") +ADD_DEFINITIONS("-fvisibility=default") + ADD_LIBRARY(${TARGET_CYNARA_COMMON} SHARED ${COMMON_SOURCES}) SET_TARGET_PROPERTIES( ${TARGET_CYNARA_COMMON} PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=default" SOVERSION ${CYNARA_COMMON_VERSION_MAJOR} VERSION ${CYNARA_COMMON_VERSION} ) diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt index 9f11ab8..47482eb 100644 --- a/src/service/CMakeLists.txt +++ b/src/service/CMakeLists.txt @@ -31,11 +31,6 @@ SET(CYNARA_SOURCES ${CYNARA_SERVICE_PATH}/storage/StorageSerializer.cpp ) -SET_SOURCE_FILES_PROPERTIES( - ${CYNARA_SOURCES} - PROPERTIES - COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden") - INCLUDE_DIRECTORIES( ${CYNARA_SERVICE_PATH} ) -- 2.7.4 From 7b0c554437300f2e836270324786ef54a9d06d94 Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Mon, 1 Sep 2014 18:31:04 +0200 Subject: [PATCH 03/16] build: drop unused definition of API_VERSION This is probably copied from some template, but never used. Change-Id: I455bb316b65121ff9ed509884d40c0c14668efce Signed-off-by: Rafal Krypa --- CMakeLists.txt | 2 -- packaging/cynara.spec | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98ae1ae..c8f1482 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,6 @@ ADD_DEFINITIONS("-Wextra") # Generate even more extra warni # Don't export symbols by default ADD_DEFINITIONS("-fvisibility=hidden") -STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}") -ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"") IF (CMAKE_BUILD_TYPE MATCHES "DEBUG") ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG") diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 77759cb..5890e9b 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -135,7 +135,7 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" export CXXFLAGS="$CXXFLAGS -DCYNARA_STATE_PATH=\\\"%{state_path}\\\"" export LDFLAGS+="-Wl,--rpath=%{_libdir}" -%cmake . -DVERSION=%{version} \ +%cmake . \ -DCMAKE_BUILD_TYPE=%{?build_type} \ -DCMAKE_VERBOSE_MAKEFILE=ON make %{?jobs:-j%jobs} -- 2.7.4 From 2298a060e825301181c7c865424fa1f4ea0abb46 Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Tue, 2 Sep 2014 10:48:12 +0200 Subject: [PATCH 04/16] build: clean up settings of compiler flags Compiler flags are set in main CMakeLists.txt. This part of the file looks like a template inherited from other projects and requires some clean up: - drop C flags, there are no C source files. - move fortify flags to spec, they are specific to Tizen build system. - use Cmake built-in features for detection of compiler support for C++11 Change-Id: I40cb76934334c31d7ac59328eed217e08902b187 Signed-off-by: Rafal Krypa --- CMakeLists.txt | 24 ++++++++++++++++-------- packaging/cynara.spec | 6 ++++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8f1482..ab478f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,17 +24,25 @@ PROJECT("cynara") ############################# cmake packages ################################## INCLUDE(FindPkgConfig) +INCLUDE(CheckCXXCompilerFlag) ############################# compiler flags ################################## -SET(CMAKE_C_FLAGS_PROFILING "-g -O0 -pg") -SET(CMAKE_CXX_FLAGS_PROFILING "-g -std=c++0x -O0 -pg -Wp,-U_FORTIFY_SOURCE") -SET(CMAKE_C_FLAGS_DEBUG "-g -O0 -ggdb") -SET(CMAKE_CXX_FLAGS_DEBUG "-g -std=c++0x -O0 -ggdb -Wp,-U_FORTIFY_SOURCE") -SET(CMAKE_C_FLAGS_RELEASE "-g -O2") -SET(CMAKE_CXX_FLAGS_RELEASE "-g -std=c++0x -O2") -SET(CMAKE_C_FLAGS_CCOV "-g -O2 --coverage") -SET(CMAKE_CXX_FLAGS_CCOV "-g -std=c++0x -O2 --coverage") +SET(CMAKE_CXX_FLAGS_PROFILING "-O0 -g -pg") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -ggdb") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -g") +SET(CMAKE_CXX_FLAGS_CCOV "-O2 -g --coverage") + +# Check for C++11 support and enable proper compilation flags +CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) +CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) +IF(COMPILER_SUPPORTS_CXX11) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +ELSEIF(COMPILER_SUPPORTS_CXX0X) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +ELSE() + MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") +ENDIF() # Set compiler warning flags ADD_DEFINITIONS("-Werror") # Make all warnings into errors. diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 5890e9b..f2a8d72 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -127,9 +127,11 @@ cp -a %{SOURCE1006} . %build %if 0%{?sec_build_binary_debug_enable} -export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" -export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" +%endif + +%if %{?build_type} == "DEBUG" +export CXXFLAGS="$CXXFLAGS -Wp,-U_FORTIFY_SOURCE" %endif export CXXFLAGS="$CXXFLAGS -DCYNARA_STATE_PATH=\\\"%{state_path}\\\"" -- 2.7.4 From 274687f9228b4395c48a359babb73c83a85ba4ca Mon Sep 17 00:00:00 2001 From: Rafal Krypa Date: Mon, 1 Sep 2014 18:49:40 +0200 Subject: [PATCH 05/16] Fix inclusion of libunwind when not building for debug Conditional inclusion of libunwind.h didn't properly depend on definition of BUILD_TYPE_DEBUG. But only debug build checks for libunwind dependency. Change-Id: I2158d09ae2880e9869246d75049aa1f23b8c4bcc Signed-off-by: Rafal Krypa --- src/common/log/Backtrace.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/log/Backtrace.h b/src/common/log/Backtrace.h index df023ba..c96f29d 100644 --- a/src/common/log/Backtrace.h +++ b/src/common/log/Backtrace.h @@ -25,7 +25,7 @@ #ifndef SRC_COMMON_LOG_BACKTRACE_H_ #define SRC_COMMON_LOG_BACKTRACE_H_ -#ifndef CYNARA_NO_LOGS +#if defined(BUILD_TYPE_DEBUG) && !defined(CYNARA_NO_LOGS) #define UNW_LOCAL_ONLY #include #endif @@ -53,7 +53,7 @@ private: void operator=(Backtrace const &) = delete; const std::string buildBacktrace(void); -#ifndef CYNARA_NO_LOGS +#if defined(BUILD_TYPE_DEBUG) && !defined(CYNARA_NO_LOGS) void getSourceInfo(unw_word_t proc_address); #endif -- 2.7.4 From aeb36e1cca424466b6e56a38c7b12c71d260d3d9 Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Thu, 14 Aug 2014 13:53:16 +0200 Subject: [PATCH 06/16] Add credential and session helper libraries This change introduces libraries with following functionalities: a) simple session id generation b) user_id and client_id retrieval This patch adds libraries to build and packaging files. There is no code yet - libraries are empty. Change-Id: I4c5c8b75eb5ea4867ba111d936bacbcd41fc5098 --- CMakeLists.txt | 5 + packaging/cynara.spec | 143 ++++++++++++++++++++- packaging/libcynara-creds-commons.manifest | 5 + packaging/libcynara-creds-dbus.manifest | 5 + packaging/libcynara-creds-socket.manifest | 5 + packaging/libcynara-session.manifest | 5 + pkgconfig/CMakeLists.txt | 5 + pkgconfig/cynara-creds-commons/CMakeLists.txt | 26 ++++ .../cynara-creds-commons.pc.in | 11 ++ pkgconfig/cynara-creds-dbus/CMakeLists.txt | 26 ++++ .../cynara-creds-dbus/cynara-creds-dbus.pc.in | 11 ++ pkgconfig/cynara-creds-socket/CMakeLists.txt | 26 ++++ .../cynara-creds-socket/cynara-creds-socket.pc.in | 11 ++ pkgconfig/cynara-session/CMakeLists.txt | 26 ++++ pkgconfig/cynara-session/cynara-session.pc.in | 11 ++ src/CMakeLists.txt | 4 + src/helpers/creds-commons/CMakeLists.txt | 44 +++++++ src/helpers/creds-commons/creds-commons.cpp | 23 ++++ src/helpers/creds-dbus/CMakeLists.txt | 54 ++++++++ src/helpers/creds-dbus/creds-dbus.cpp | 23 ++++ src/helpers/creds-socket/CMakeLists.txt | 44 +++++++ src/helpers/creds-socket/creds-socket.cpp | 23 ++++ src/helpers/session/CMakeLists.txt | 44 +++++++ src/helpers/session/session.cpp | 23 ++++ src/include/CMakeLists.txt | 12 +- src/include/cynara-creds-commons.h | 37 ++++++ src/include/cynara-creds-dbus.h | 37 ++++++ src/include/cynara-creds-socket.h | 37 ++++++ src/include/cynara-session.h | 37 ++++++ 29 files changed, 756 insertions(+), 7 deletions(-) create mode 100644 packaging/libcynara-creds-commons.manifest create mode 100644 packaging/libcynara-creds-dbus.manifest create mode 100644 packaging/libcynara-creds-socket.manifest create mode 100644 packaging/libcynara-session.manifest create mode 100644 pkgconfig/cynara-creds-commons/CMakeLists.txt create mode 100644 pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in create mode 100644 pkgconfig/cynara-creds-dbus/CMakeLists.txt create mode 100644 pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in create mode 100644 pkgconfig/cynara-creds-socket/CMakeLists.txt create mode 100644 pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in create mode 100644 pkgconfig/cynara-session/CMakeLists.txt create mode 100644 pkgconfig/cynara-session/cynara-session.pc.in create mode 100644 src/helpers/creds-commons/CMakeLists.txt create mode 100644 src/helpers/creds-commons/creds-commons.cpp create mode 100644 src/helpers/creds-dbus/CMakeLists.txt create mode 100644 src/helpers/creds-dbus/creds-dbus.cpp create mode 100644 src/helpers/creds-socket/CMakeLists.txt create mode 100644 src/helpers/creds-socket/creds-socket.cpp create mode 100644 src/helpers/session/CMakeLists.txt create mode 100644 src/helpers/session/session.cpp create mode 100644 src/include/cynara-creds-commons.h create mode 100644 src/include/cynara-creds-dbus.h create mode 100644 src/include/cynara-creds-socket.h create mode 100644 src/include/cynara-session.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ab478f9..c4f80a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ # # @file CMakeLists.txt # @author Lukasz Wojciechowski +# @author Radoslaw Bartosiak # ############################# Check minimum CMake version ##################### @@ -63,6 +64,10 @@ SET(TARGET_LIB_CYNARA_COMMON "cynara-client-commons") SET(TARGET_LIB_CYNARA_ADMIN "cynara-admin") SET(TARGET_CYNARA_COMMON "cynara-commons") SET(TARGET_CYNARA_TESTS "cynara-tests") +SET(TARGET_LIB_CREDS_COMMONS "cynara-creds-commons") +SET(TARGET_LIB_CREDS_DBUS "cynara-creds-dbus") +SET(TARGET_LIB_CREDS_SOCKET "cynara-creds-socket") +SET(TARGET_LIB_SESSION "cynara-session") ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(test) diff --git a/packaging/cynara.spec b/packaging/cynara.spec index f2a8d72..2036d61 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -11,6 +11,10 @@ Source1003: libcynara-admin.manifest Source1004: cynara-tests.manifest Source1005: libcynara-client-commons.manifest Source1006: libcynara-commons.manifest +Source1007: libcynara-creds-commons.manifest +Source1008: libcynara-creds-dbus.manifest +Source1009: libcynara-creds-socket.manifest +Source1010: libcynara-session.manifest Requires: default-ac-domains Requires(pre): pwdutils Requires(post): smack @@ -35,7 +39,9 @@ BuildRequires: pkgconfig(libunwind) %endif %description -service, client libraries (libcynara-client, libcynara-admin) +service, client libraries (libcynara-client, libcynara-admin), +helper libraries (libcynara-session, libcynara-creds-common, libcynara-creds-dbus, +libcynara-creds-socket) and tests (cynara-tests) ####################################################### @@ -100,6 +106,65 @@ Requires: libcynara-commons = %{version}-%{release} cynara common library (devel) with common functionalities ####################################################### +%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) +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} + +%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} + +%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) @@ -124,6 +189,10 @@ cp -a %{SOURCE1003} . cp -a %{SOURCE1004} . cp -a %{SOURCE1005} . cp -a %{SOURCE1006} . +cp -a %{SOURCE1007} . +cp -a %{SOURCE1008} . +cp -a %{SOURCE1009} . +cp -a %{SOURCE1010} . %build %if 0%{?sec_build_binary_debug_enable} @@ -223,6 +292,38 @@ fi %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 %manifest cynara.manifest %license LICENSE @@ -276,3 +377,43 @@ fi %files -n cynara-tests %manifest cynara-tests.manifest %attr(755,root,root) /usr/bin/cynara-tests + +%files -n libcynara-creds-commons +%manifest libcynara-creds-commons.manifest +%license LICENSE +%{_libdir}/libcynara-creds-commons.so.* + +%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 diff --git a/packaging/libcynara-creds-commons.manifest b/packaging/libcynara-creds-commons.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libcynara-creds-commons.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libcynara-creds-dbus.manifest b/packaging/libcynara-creds-dbus.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libcynara-creds-dbus.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libcynara-creds-socket.manifest b/packaging/libcynara-creds-socket.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libcynara-creds-socket.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libcynara-session.manifest b/packaging/libcynara-session.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libcynara-session.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/pkgconfig/CMakeLists.txt b/pkgconfig/CMakeLists.txt index 269b258..0c11631 100644 --- a/pkgconfig/CMakeLists.txt +++ b/pkgconfig/CMakeLists.txt @@ -14,7 +14,12 @@ # # @file CMakeLists.txt # @author Lukasz Wojciechowski +# @author Radoslaw Bartosiak # ADD_SUBDIRECTORY(cynara-client) ADD_SUBDIRECTORY(cynara-admin) +ADD_SUBDIRECTORY(cynara-creds-commons) +ADD_SUBDIRECTORY(cynara-creds-dbus) +ADD_SUBDIRECTORY(cynara-creds-socket) +ADD_SUBDIRECTORY(cynara-session) diff --git a/pkgconfig/cynara-creds-commons/CMakeLists.txt b/pkgconfig/cynara-creds-commons/CMakeLists.txt new file mode 100644 index 0000000..654df6c --- /dev/null +++ b/pkgconfig/cynara-creds-commons/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# + +CONFIGURE_FILE(cynara-creds-commons.pc.in cynara-creds-commons.pc @ONLY) + +INSTALL(FILES + ${CMAKE_BINARY_DIR}/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc + DESTINATION + ${LIB_INSTALL_DIR}/pkgconfig + ) diff --git a/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in b/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in new file mode 100644 index 0000000..cb87e5f --- /dev/null +++ b/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@LIB_INSTALL_DIR@ +includedir=${prefix}/include + +Name: cynara-creds-commons +Description: Base package for all cynara-creds packages +Version: 0.0.1 +Requires: +Libs: -L${libdir} -lcynara-creds-commons +Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-creds-dbus/CMakeLists.txt b/pkgconfig/cynara-creds-dbus/CMakeLists.txt new file mode 100644 index 0000000..57c59c9 --- /dev/null +++ b/pkgconfig/cynara-creds-dbus/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# + +CONFIGURE_FILE(cynara-creds-dbus.pc.in cynara-creds-dbus.pc @ONLY) + +INSTALL(FILES + ${CMAKE_BINARY_DIR}/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc + DESTINATION + ${LIB_INSTALL_DIR}/pkgconfig + ) diff --git a/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in b/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in new file mode 100644 index 0000000..296ce6c --- /dev/null +++ b/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@LIB_INSTALL_DIR@ +includedir=${prefix}/include + +Name: cynara-creds-dbus +Description: cynara-creds package for dbus clients +Version: 0.0.1 +Requires: dbus-1 +Libs: -L${libdir} -lcynara-creds-dbus +Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-creds-socket/CMakeLists.txt b/pkgconfig/cynara-creds-socket/CMakeLists.txt new file mode 100644 index 0000000..504c58c --- /dev/null +++ b/pkgconfig/cynara-creds-socket/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# + +CONFIGURE_FILE(cynara-creds-socket.pc.in cynara-creds-socket.pc @ONLY) + +INSTALL(FILES + ${CMAKE_BINARY_DIR}/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc + DESTINATION + ${LIB_INSTALL_DIR}/pkgconfig + ) diff --git a/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in b/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in new file mode 100644 index 0000000..b81cf68 --- /dev/null +++ b/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@LIB_INSTALL_DIR@ +includedir=${prefix}/include + +Name: cynara-creds-socket +Description: cynara-creds package for socket clients +Version: 0.0.1 +Requires: +Libs: -L${libdir} -lcynara-creds-socket +Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-session/CMakeLists.txt b/pkgconfig/cynara-session/CMakeLists.txt new file mode 100644 index 0000000..79ee80d --- /dev/null +++ b/pkgconfig/cynara-session/CMakeLists.txt @@ -0,0 +1,26 @@ +# 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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# + +CONFIGURE_FILE(cynara-session.pc.in cynara-session.pc @ONLY) + +INSTALL(FILES + ${CMAKE_BINARY_DIR}/pkgconfig/cynara-session/cynara-session.pc + DESTINATION + ${LIB_INSTALL_DIR}/pkgconfig + ) diff --git a/pkgconfig/cynara-session/cynara-session.pc.in b/pkgconfig/cynara-session/cynara-session.pc.in new file mode 100644 index 0000000..fa6e763 --- /dev/null +++ b/pkgconfig/cynara-session/cynara-session.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@LIB_INSTALL_DIR@ +includedir=${prefix}/include + +Name: cynara-session +Description: cynara-session package +Version: 0.0.1 +Requires: +Libs: -L${libdir} -lcynara-session +Cflags: -I${includedir}/cynara diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 596e84a..2e3e7bf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,3 +49,7 @@ ADD_SUBDIRECTORY(client) ADD_SUBDIRECTORY(client-common) ADD_SUBDIRECTORY(admin) ADD_SUBDIRECTORY(service) +ADD_SUBDIRECTORY(helpers/creds-commons) +ADD_SUBDIRECTORY(helpers/creds-dbus) +ADD_SUBDIRECTORY(helpers/creds-socket) +ADD_SUBDIRECTORY(helpers/session) diff --git a/src/helpers/creds-commons/CMakeLists.txt b/src/helpers/creds-commons/CMakeLists.txt new file mode 100644 index 0000000..00484b7 --- /dev/null +++ b/src/helpers/creds-commons/CMakeLists.txt @@ -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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# @author Lukasz Wojciechowski +# + +SET(LIB_CREDS_COMMONS_VERSION_MAJOR 0) +SET(LIB_CREDS_COMMONS_VERSION ${LIB_CREDS_COMMONS_VERSION_MAJOR}.0.1) + +SET(LIB_CREDS_COMMONS_PATH ${CYNARA_PATH}/helpers/creds-commons) + +SET(LIB_CREDS_COMMONS_SOURCES + ${LIB_CREDS_COMMONS_PATH}/creds-commons.cpp + ) + +INCLUDE_DIRECTORIES( + ${CYNARA_PATH}/include + ${LIB_CREDS_COMMONS_PATH} + ) + +ADD_LIBRARY(${TARGET_LIB_CREDS_COMMONS} SHARED ${LIB_CREDS_COMMONS_SOURCES}) + +SET_TARGET_PROPERTIES( + ${TARGET_LIB_CREDS_COMMONS} + PROPERTIES + SOVERSION ${LIB_CREDS_COMMONS_VERSION_MAJOR} + VERSION ${LIB_CREDS_COMMONS_VERSION} + ) + +INSTALL(TARGETS ${TARGET_LIB_CREDS_COMMONS} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/src/helpers/creds-commons/creds-commons.cpp b/src/helpers/creds-commons/creds-commons.cpp new file mode 100644 index 0000000..4cb7897 --- /dev/null +++ b/src/helpers/creds-commons/creds-commons.cpp @@ -0,0 +1,23 @@ +/* + * 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 creds-commons.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Implementation of external libcynara-creds-commons API + */ + +// Empty initial file diff --git a/src/helpers/creds-dbus/CMakeLists.txt b/src/helpers/creds-dbus/CMakeLists.txt new file mode 100644 index 0000000..4e19a8b --- /dev/null +++ b/src/helpers/creds-dbus/CMakeLists.txt @@ -0,0 +1,54 @@ +# 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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# @author Lukasz Wojciechowski +# + +SET(LIB_CREDS_DBUS_VERSION_MAJOR 0) +SET(LIB_CREDS_DBUS_VERSION ${LIB_CREDS_DBUS_VERSION_MAJOR}.0.1) + +SET(LIB_CREDS_DBUS_PATH ${CYNARA_PATH}/helpers/creds-dbus) + +SET(LIB_CREDS_DBUS_SOURCES + ${LIB_CREDS_DBUS_PATH}/creds-dbus.cpp + ) + +PKG_CHECK_MODULES(LIB_CREDS_DBUS_DEP + REQUIRED + dbus-1 + ) + +INCLUDE_DIRECTORIES( + ${CYNARA_PATH}/include + ${LIB_CREDS_DBUS_PATH} + ${LIB_CREDS_DBUS_DEP_INCLUDE_DIRS} + ) + +ADD_LIBRARY(${TARGET_LIB_CREDS_DBUS} SHARED ${LIB_CREDS_DBUS_SOURCES}) + +SET_TARGET_PROPERTIES( + ${TARGET_LIB_CREDS_DBUS} + PROPERTIES + SOVERSION ${LIB_CREDS_DBUS_VERSION_MAJOR} + VERSION ${LIB_CREDS_DBUS_VERSION} + ) + +TARGET_LINK_LIBRARIES(${TARGET_LIB_CREDS_DBUS} + ${LIB_CREDS_DBUS_DEP_LIBRARIES} + ) + +INSTALL(TARGETS ${TARGET_LIB_CREDS_DBUS} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/src/helpers/creds-dbus/creds-dbus.cpp b/src/helpers/creds-dbus/creds-dbus.cpp new file mode 100644 index 0000000..535ca84 --- /dev/null +++ b/src/helpers/creds-dbus/creds-dbus.cpp @@ -0,0 +1,23 @@ +/* + * 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 creds-dbus.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Implementation of external libcynara-creds-dbus API + */ + +// Empty initial file diff --git a/src/helpers/creds-socket/CMakeLists.txt b/src/helpers/creds-socket/CMakeLists.txt new file mode 100644 index 0000000..c42e94d --- /dev/null +++ b/src/helpers/creds-socket/CMakeLists.txt @@ -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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# @author Lukasz Wojciechowski +# + +SET(LIB_CREDS_SOCKET_VERSION_MAJOR 0) +SET(LIB_CREDS_SOCKET_VERSION ${LIB_CREDS_SOCKET_VERSION_MAJOR}.0.1) + +SET(LIB_CREDS_SOCKET_PATH ${CYNARA_PATH}/helpers/creds-socket) + +SET(LIB_CREDS_SOCKET_SOURCES + ${LIB_CREDS_SOCKET_PATH}/creds-socket.cpp + ) + +INCLUDE_DIRECTORIES( + ${CYNARA_PATH}/include + ${LIB_CREDS_SOCKET_PATH} + ) + +ADD_LIBRARY(${TARGET_LIB_CREDS_SOCKET} SHARED ${LIB_CREDS_SOCKET_SOURCES}) + +SET_TARGET_PROPERTIES( + ${TARGET_LIB_CREDS_SOCKET} + PROPERTIES + SOVERSION ${LIB_CREDS_SOCKET_VERSION_MAJOR} + VERSION ${LIB_CREDS_SOCKET_VERSION} + ) + +INSTALL(TARGETS ${TARGET_LIB_CREDS_SOCKET} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/src/helpers/creds-socket/creds-socket.cpp b/src/helpers/creds-socket/creds-socket.cpp new file mode 100644 index 0000000..0ee2661 --- /dev/null +++ b/src/helpers/creds-socket/creds-socket.cpp @@ -0,0 +1,23 @@ +/* + * 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 creds-socket.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Implementation of external libcynara-creds-socket API + */ + +// Empty initial file diff --git a/src/helpers/session/CMakeLists.txt b/src/helpers/session/CMakeLists.txt new file mode 100644 index 0000000..b019f4c --- /dev/null +++ b/src/helpers/session/CMakeLists.txt @@ -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 CMakeLists.txt +# @author Aleksander Zdyb +# @author Radoslaw Bartosiak +# @author Lukasz Wojciechowski +# + +SET(LIB_SESSION_VERSION_MAJOR 0) +SET(LIB_SESSION_VERSION ${LIB_SESSION_VERSION_MAJOR}.0.1) + +SET(LIB_SESSION_PATH ${CYNARA_PATH}/helpers/session) + +SET(LIB_SESSION_SOURCES + ${LIB_SESSION_PATH}/session.cpp + ) + +INCLUDE_DIRECTORIES( + ${CYNARA_PATH}/include + ${LIB_SESSION_PATH} + ) + +ADD_LIBRARY(${TARGET_LIB_SESSION} SHARED ${LIB_SESSION_SOURCES}) + +SET_TARGET_PROPERTIES( + ${TARGET_LIB_SESSION} + PROPERTIES + SOVERSION ${LIB_SESSION_VERSION_MAJOR} + VERSION ${LIB_SESSION_VERSION} + ) + +INSTALL(TARGETS ${TARGET_LIB_SESSION} DESTINATION ${LIB_INSTALL_DIR}) diff --git a/src/helpers/session/session.cpp b/src/helpers/session/session.cpp new file mode 100644 index 0000000..f65f23b --- /dev/null +++ b/src/helpers/session/session.cpp @@ -0,0 +1,23 @@ +/* + * 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 session.cpp + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Implementation of external libcynara-session API + */ + +// Empty initial file diff --git a/src/include/CMakeLists.txt b/src/include/CMakeLists.txt index 486f657..261c34d 100644 --- a/src/include/CMakeLists.txt +++ b/src/include/CMakeLists.txt @@ -17,13 +17,13 @@ # INSTALL(FILES - ${CYNARA_PATH}/include/cynara-client.h - ${CYNARA_PATH}/include/cynara-client-error.h - DESTINATION ${INCLUDE_INSTALL_DIR}/cynara - ) - -INSTALL(FILES ${CYNARA_PATH}/include/cynara-admin.h ${CYNARA_PATH}/include/cynara-admin-error.h + ${CYNARA_PATH}/include/cynara-client.h + ${CYNARA_PATH}/include/cynara-client-error.h + ${CYNARA_PATH}/include/cynara-creds-commons.h + ${CYNARA_PATH}/include/cynara-creds-dbus.h + ${CYNARA_PATH}/include/cynara-creds-socket.h + ${CYNARA_PATH}/include/cynara-session.h DESTINATION ${INCLUDE_INSTALL_DIR}/cynara ) diff --git a/src/include/cynara-creds-commons.h b/src/include/cynara-creds-commons.h new file mode 100644 index 0000000..655dbac --- /dev/null +++ b/src/include/cynara-creds-commons.h @@ -0,0 +1,37 @@ +/* + * 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 cynara-creds-commons.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file contains common APIs for Cynara credentials helper. + */ + + +#ifndef CYNARA_CREDS_COMMONS_H +#define CYNARA_CREDS_COMMONS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* empty initial file */ + +#ifdef __cplusplus +} +#endif + +#endif /* CYNARA_CREDS_COMMONS_H */ diff --git a/src/include/cynara-creds-dbus.h b/src/include/cynara-creds-dbus.h new file mode 100644 index 0000000..925a829 --- /dev/null +++ b/src/include/cynara-creds-dbus.h @@ -0,0 +1,37 @@ +/* + * 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 cynara-creds-dbus.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file contains Cynara credentials helper APIs for dbus clients. + */ + + +#ifndef CYNARA_CREDS_DBUS_H +#define CYNARA_CREDS_DBUS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* empty initial file */ + +#ifdef __cplusplus +} +#endif + +#endif /* CYNARA_CREDS_DBUS_H */ diff --git a/src/include/cynara-creds-socket.h b/src/include/cynara-creds-socket.h new file mode 100644 index 0000000..bc89684 --- /dev/null +++ b/src/include/cynara-creds-socket.h @@ -0,0 +1,37 @@ +/* + * 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 cynara-creds-socket.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file contains Cynara credentials helper APIs for socket clients. + */ + + +#ifndef CYNARA_CREDS_SOCKET_H +#define CYNARA_CREDS_SOCKET_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* empty initial file */ + +#ifdef __cplusplus +} +#endif + +#endif /* CYNARA_CREDS_SOCKET_H */ diff --git a/src/include/cynara-session.h b/src/include/cynara-session.h new file mode 100644 index 0000000..ab96e0b --- /dev/null +++ b/src/include/cynara-session.h @@ -0,0 +1,37 @@ +/* + * 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 cynara-session.h + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief This file contains Cynara session helper APIs. + */ + + +#ifndef CYNARA_SESSION_H +#define CYNARA_SESSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* empty initial file */ + +#ifdef __cplusplus +} +#endif + +#endif /* CYNARA_SESSION_H */ -- 2.7.4 From b77fd803be77217292ba941f59fa40225b72f3e1 Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Wed, 3 Sep 2014 21:13:03 +0200 Subject: [PATCH 07/16] Implement cynara-session library Change-Id: I929408dc59db5f4ab115567fd4839258bd086418 --- src/helpers/session/session.cpp | 22 +++++++++++++- src/include/cynara-session.h | 64 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 84 insertions(+), 2 deletions(-) diff --git a/src/helpers/session/session.cpp b/src/helpers/session/session.cpp index f65f23b..8c94868 100644 --- a/src/helpers/session/session.cpp +++ b/src/helpers/session/session.cpp @@ -15,9 +15,29 @@ */ /* * @file session.cpp + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb * @author Lukasz Wojciechowski * @version 1.0 * @brief Implementation of external libcynara-session API */ -// Empty initial file +#include +#include +#include + +#include + +#include + +CYNARA_API +char *cynara_session_from_pid(pid_t client_pid) { + std::string path = std::string("/proc/") + std::to_string(client_pid); + + struct stat st; + if (stat(path.c_str(), &st) < 0) + return nullptr; + + std::string session = std::to_string(st.st_ctim.tv_sec) + path; + return strdup(session.c_str()); +} diff --git a/src/include/cynara-session.h b/src/include/cynara-session.h index ab96e0b..d24c57d 100644 --- a/src/include/cynara-session.h +++ b/src/include/cynara-session.h @@ -15,6 +15,8 @@ */ /* * @file cynara-session.h + * \author Aleksander Zdyb + * \author Radoslaw Bartosiak * @author Lukasz Wojciechowski * @version 1.0 * @brief This file contains Cynara session helper APIs. @@ -24,11 +26,71 @@ #ifndef CYNARA_SESSION_H #define CYNARA_SESSION_H +#include + #ifdef __cplusplus extern "C" { #endif -/* empty initial file */ +/** + * \par Description: + * Creates a client session string based on pid and time of creation of client process + * + * \par Purpose: + * This function can be used to create session string identifier used in cynara_check() + * and cynara_async_check() functions defined in client libraries. + * + * \par Typical use case: + * The function is called before the call of one of ...check() functions. + * Returned string is used as client_session param in ...check() function. + * String is released with free() function. + * + * \par Method of function operation: + * The function generates client session based on the pid and start time of the client process. + * Time is acquired from /proc/PID directory. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is thread-safe. + * + * \par Important notes: + * Memory for returned string is obtained with malloc(), and should be freed with free(). + * + * \param[in] client_pid client application process identifier (PID). + * + * \return session string on success + * or NULL on error. + */ +char *cynara_session_from_pid(pid_t client_pid); + +/* //sample code + * + * (...) + * + * //create client session + * char *client_session; + * client_session = cynara_session_from_pid(client_pid); + * if (!client_session) { + * //use another way to create session or abandon request sending + * } + * + * //check access (details of this function can be found in cynara-client.h) + * int ret = cynara_check(p_cynara, client, client_session, user, privilege); + * + * //release client_session memory + * free(client_session); + * + * //handle check answer + * if (ret < 0) { + * //handle error + * } else { + * //handle response + * } + * + * (...) + */ #ifdef __cplusplus } -- 2.7.4 From f9a46cb7e26c340cc779f86947895b3b33bc7453 Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Sun, 31 Aug 2014 10:22:44 +0200 Subject: [PATCH 08/16] Add new error codes needed by credential helpers Added codes are: CYNARA_API_METHOD_NOT_SUPPORTED CYNARA_API_UNKNOWN_ERROR Change-Id: I604ce30b37bdfe4ecba637bcf423e6fea0b2610c --- src/include/cynara-client-error.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/include/cynara-client-error.h b/src/include/cynara-client-error.h index e5539ea..a506762 100644 --- a/src/include/cynara-client-error.h +++ b/src/include/cynara-client-error.h @@ -48,6 +48,12 @@ /*! \brief indicating that value is not present in cache */ #define CYNARA_API_CACHE_MISS -5 + +/*! \brief indicating that provided method is not supported by library */ +#define CYNARA_API_METHOD_NOT_SUPPORTED -6 + +/*! \brief indicating an unknown error */ +#define CYNARA_API_UNKNOWN_ERROR -7 /** @}*/ #endif // CYNARA_CLIENT_ERROR_H -- 2.7.4 From 7558b9540b6c51b9822c63bbbdf42da282b1a7c1 Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Wed, 3 Sep 2014 21:23:56 +0200 Subject: [PATCH 09/16] Add enums for credentials acquire methods Change-Id: I5719a7622a78ae6d1ca86a7dcce986c69abb3e23 --- src/include/cynara-creds-commons.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/include/cynara-creds-commons.h b/src/include/cynara-creds-commons.h index 655dbac..9f012e1 100644 --- a/src/include/cynara-creds-commons.h +++ b/src/include/cynara-creds-commons.h @@ -16,6 +16,8 @@ /* * @file cynara-creds-commons.h * @author Lukasz Wojciechowski + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb * @version 1.0 * @brief This file contains common APIs for Cynara credentials helper. */ @@ -24,6 +26,16 @@ #ifndef CYNARA_CREDS_COMMONS_H #define CYNARA_CREDS_COMMONS_H +enum cynara_client_creds { + CLIENT_METHOD_SMACK, + CLIENT_METHOD_PID +}; + +enum cynara_user_creds { + USER_METHOD_UID, + USER_METHOD_GID +}; + #ifdef __cplusplus extern "C" { #endif -- 2.7.4 From d9db2d3f62949613cf7523f77f40d415e051af3d Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Wed, 3 Sep 2014 21:13:03 +0200 Subject: [PATCH 10/16] Implement cynara-creds-socket library Change-Id: Ifa27c49c3361547c75d50aa7cbf72e4bd3648201 --- src/helpers/creds-socket/CMakeLists.txt | 1 + src/helpers/creds-socket/creds-socket-inner.cpp | 113 +++++++++++++++++++++++ src/helpers/creds-socket/creds-socket-inner.h | 41 +++++++++ src/helpers/creds-socket/creds-socket.cpp | 48 +++++++++- src/include/cynara-creds-socket.h | 115 +++++++++++++++++++++++- 5 files changed, 316 insertions(+), 2 deletions(-) create mode 100644 src/helpers/creds-socket/creds-socket-inner.cpp create mode 100644 src/helpers/creds-socket/creds-socket-inner.h diff --git a/src/helpers/creds-socket/CMakeLists.txt b/src/helpers/creds-socket/CMakeLists.txt index c42e94d..a425c0b 100644 --- a/src/helpers/creds-socket/CMakeLists.txt +++ b/src/helpers/creds-socket/CMakeLists.txt @@ -25,6 +25,7 @@ SET(LIB_CREDS_SOCKET_PATH ${CYNARA_PATH}/helpers/creds-socket) SET(LIB_CREDS_SOCKET_SOURCES ${LIB_CREDS_SOCKET_PATH}/creds-socket.cpp + ${LIB_CREDS_SOCKET_PATH}/creds-socket-inner.cpp ) INCLUDE_DIRECTORIES( diff --git a/src/helpers/creds-socket/creds-socket-inner.cpp b/src/helpers/creds-socket/creds-socket-inner.cpp new file mode 100644 index 0000000..a227e5b --- /dev/null +++ b/src/helpers/creds-socket/creds-socket-inner.cpp @@ -0,0 +1,113 @@ +/* + * 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 creds-socket-inner.cpp + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Implementation of internal libcynara-creds-socket functions + */ + + +#include +#include +#include + +#include +#include + +#include + +#include "creds-socket-inner.h" + +int getClientSmackLabel(int socketFd, char **client) { + char dummy; + int ret; + socklen_t length = 1; + char *result; + + ret = getsockopt(socketFd, SOL_SOCKET, SO_PEERSEC, &dummy, &length); + if ((ret < 0) && (errno != ERANGE)) + return CYNARA_API_INVALID_PARAM; + + result = static_cast(calloc(length + 1, sizeof(char))); + if (result == nullptr) + return CYNARA_API_OUT_OF_MEMORY; + + ret = getsockopt(socketFd, SOL_SOCKET, SO_PEERSEC, result, &length); + if (ret < 0) { + free(result); + return CYNARA_API_INVALID_PARAM; + } + + *client = result; + return CYNARA_API_SUCCESS; +} + +#define GET_CRED(SOCK, RESULT, CRED) \ + struct ucred credentials; \ + int ret = getCredentials(SOCK, &credentials); \ + if (ret < 0) \ + return ret; \ + \ + *RESULT = strdup(std::to_string(credentials.CRED).c_str()); \ + if (*RESULT == nullptr) \ + return CYNARA_API_OUT_OF_MEMORY; \ + \ + return CYNARA_API_SUCCESS; \ + +int getClientPid(int socketFd, char **client) { + GET_CRED(socketFd, client, pid) +} + +int getUserId(int socketFd, char **user) { + GET_CRED(socketFd, user, uid) +} + +int getUserGid(int socketFd, char **user) { + GET_CRED(socketFd, user, gid) +} + +int getCredentials(int socketFd, struct ucred *credentials) { + if (credentials == nullptr) + return CYNARA_API_UNKNOWN_ERROR; + + int ret; + socklen_t length = sizeof(struct ucred); + ret = getsockopt(socketFd, SOL_SOCKET, SO_PEERCRED, credentials, &length); + if (ret < 0) { + switch (errno) { + case EBADF: + case ENOTSOCK: + return CYNARA_API_INVALID_PARAM; + default: + return CYNARA_API_UNKNOWN_ERROR; + } + } + return CYNARA_API_SUCCESS; +} + +int getPid(int socketFd, pid_t *pid) { + struct ucred credentials; + int ret = getCredentials(socketFd, &credentials); + if (ret < 0) + return ret; + + *pid = credentials.pid; + + return CYNARA_API_SUCCESS; +} diff --git a/src/helpers/creds-socket/creds-socket-inner.h b/src/helpers/creds-socket/creds-socket-inner.h new file mode 100644 index 0000000..3edb151 --- /dev/null +++ b/src/helpers/creds-socket/creds-socket-inner.h @@ -0,0 +1,41 @@ +/* + * 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 creds-socket-inner.h + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Definition of internal external libcynara-creds-socket functions + */ + +#ifndef SRC_HELPERS_CREDSSOCKET_CREDSSOCKETINNER_H_ +#define SRC_HELPERS_CREDSSOCKET_CREDSSOCKETINNER_H_ + +#include +#include + +int getClientSmackLabel(int socketFd, char **client); + +int getClientPid(int socketFd, char **client); +int getUserId(int socketFd, char **user); +int getUserGid(int socketFd, char **user); + +int getCredentials(int socketFd, struct ucred *credentials); + +int getPid(int socketFd, pid_t *pid); + +#endif /* SRC_HELPERS_CREDSSOCKET_CREDSSOCKETINNER_H_ */ diff --git a/src/helpers/creds-socket/creds-socket.cpp b/src/helpers/creds-socket/creds-socket.cpp index 0ee2661..a135f87 100644 --- a/src/helpers/creds-socket/creds-socket.cpp +++ b/src/helpers/creds-socket/creds-socket.cpp @@ -15,9 +15,55 @@ */ /* * @file creds-socket.cpp + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb * @author Lukasz Wojciechowski * @version 1.0 * @brief Implementation of external libcynara-creds-socket API */ -// Empty initial file +#include +#include + +#include + +#include + +#include +#include +#include + +CYNARA_API +int cynara_creds_socket_get_client(int socket_fd, enum cynara_client_creds method, char **client) { + if (client == nullptr) + return CYNARA_API_INVALID_PARAM; + + switch (method) { + case cynara_client_creds::CLIENT_METHOD_SMACK: + return getClientSmackLabel(socket_fd, client); + case cynara_client_creds::CLIENT_METHOD_PID: + return getClientPid(socket_fd, client); + default: + return CYNARA_API_METHOD_NOT_SUPPORTED; + } +} + +CYNARA_API +int cynara_creds_socket_get_user(int socket_fd, enum cynara_user_creds method, char **user) { + if (user == nullptr) + return CYNARA_API_INVALID_PARAM; + + switch (method) { + case cynara_user_creds::USER_METHOD_UID: + return getUserId(socket_fd, user); + case cynara_user_creds::USER_METHOD_GID: + return getUserGid(socket_fd, user); + default: + return CYNARA_API_METHOD_NOT_SUPPORTED; + } +} + +CYNARA_API +int cynara_creds_socket_get_pid(int socket_fd, pid_t *pid) { + return getPid(socket_fd, pid); +} diff --git a/src/include/cynara-creds-socket.h b/src/include/cynara-creds-socket.h index bc89684..1b6c09e 100644 --- a/src/include/cynara-creds-socket.h +++ b/src/include/cynara-creds-socket.h @@ -15,6 +15,8 @@ */ /* * @file cynara-creds-socket.h + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb * @author Lukasz Wojciechowski * @version 1.0 * @brief This file contains Cynara credentials helper APIs for socket clients. @@ -24,11 +26,122 @@ #ifndef CYNARA_CREDS_SOCKET_H #define CYNARA_CREDS_SOCKET_H +#include + +#include "cynara-creds-commons.h" + #ifdef __cplusplus extern "C" { #endif -/* empty initial file */ +/** + * \par Description: + * Creates a client identification string with given method. Client is a process at the other + * side of socket. + * + * \par Purpose: + * Client identification string is required for cynara_check() and cynara_async_check() functions. + * + * \par Typical use case: + * The function is called before the call of one of ...check() functions. + * Returned string is used as client parameter in ...check() function. + * String is released with free() function when it is no longer needed. + * + * \par Method of function operation: + * The function generates client string using SO_PEERCRED on socket. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is NOT thread-safe. If functions from described API are called by multithreaded + * application from different threads, they must be put into mutex protected critical section. + * + * \par Important notes: + * Memory for returned client string is obtained with malloc(), and should be freed with free(). + * Allocated string is returned only, when function succeeds. + * + * \param[in] socket_fd Descriptor of open connected UNIX socket + * \param[in] method Method of client identifier creation + * \param[out] client Placeholder for allocated string containing client id + * + * \return CYNARA_API_SUCCESS on success + * CYNARA_API_INVALID_PARAM when client is NULL or socket_fd is not valid connected socket + * descriptor + * CYNARA_API_METHOD_NOT_SUPPORTED when requested method is not supported + * CYNARA_API_OUT_OF_MEMORY when there was error allocating memory + */ +int cynara_creds_socket_get_client(int socket_fd, enum cynara_client_creds method, char **client); + +/** + * \par Description: + * Creates a user identification string with given method. User is an executor of process + * at the other side of socket. + * + * \par Purpose: + * User identification string is required for cynara_check() and cynara_async_check() functions. + * + * \par Typical use case: + * The function is called before the call of one of ...check() functions. + * Returned string is used as user parameter in ...check() function. + * String is released with free() function when it is no longer needed. + * + * \par Method of function operation: + * The function generates user string using SO_PEERCRED on socket. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is NOT thread-safe. If functions from described API are called by multithreaded + * application from different threads, they must be put into mutex protected critical section. + * + * \par Important notes: + * Memory for returned user string is obtained with malloc(), and should be freed with free(). + * Allocated string is returned only, when function succeeds. + * + * \param[in] socket_fd Descriptor of open connected UNIX socket + * \param[in] method Method of user identifier creation + * \param[out] user Placeholder for allocated string containing user id + * + * \return CYNARA_API_SUCCESS on success + * CYNARA_API_INVALID_PARAM when user is NULL or socket_fd is not valid connected socket + * descriptor + * CYNARA_API_METHOD_NOT_SUPPORTED when requested method is not supported + * CYNARA_API_OUT_OF_MEMORY when there was error allocating memory + */ +int cynara_creds_socket_get_user(int socket_fd, enum cynara_user_creds method, char **user); + +/** + * \par Description: + * Return PID of process at the other side of socket. + * + * \par Purpose: + * PID may be used for client_session creation with cynara_session_from_pid() function + * from libcynara-session library. Client_session is needed for cynara_check() + * and cynara_async_check() functions. + * + * \par Typical use case: + * The function is called before the call of cynara_session_from_pid() function. + * + * \par Method of function operation: + * The function reads PID of peer using SO_PEERCRED on socket. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is NOT thread-safe. If functions from described API are called by multithreaded + * application from different threads, they must be put into mutex protected critical section. + * + * \param[in] socket_fd Descriptor of open connected UNIX socket + * \param[out] pid Placeholder for pid + * + * \return CYNARA_API_SUCCESS on success + * CYNARA_API_INVALID_PARAM when socket_fd is not valid connected socket descriptor + * CYNARA_API_UNKNOWN_ERROR when system function fails in incredible situation + */ +int cynara_creds_socket_get_pid(int socket_fd, pid_t *pid); #ifdef __cplusplus } -- 2.7.4 From a41af0d1e2a95773389dcf6a67c2213b1e6debc1 Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Wed, 3 Sep 2014 21:48:25 +0200 Subject: [PATCH 11/16] Prepare libcynara-creds-dbus for implementation Change-Id: Ibdecf8790b7d296e35c063c52202a4a672ad9e9a --- src/helpers/creds-dbus/CMakeLists.txt | 1 + src/helpers/creds-dbus/creds-dbus-inner.cpp | 58 +++++++++++++ src/helpers/creds-dbus/creds-dbus-inner.h | 39 +++++++++ src/helpers/creds-dbus/creds-dbus.cpp | 51 +++++++++++- src/include/cynara-creds-dbus.h | 125 +++++++++++++++++++++++++++- 5 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 src/helpers/creds-dbus/creds-dbus-inner.cpp create mode 100644 src/helpers/creds-dbus/creds-dbus-inner.h diff --git a/src/helpers/creds-dbus/CMakeLists.txt b/src/helpers/creds-dbus/CMakeLists.txt index 4e19a8b..c80d301 100644 --- a/src/helpers/creds-dbus/CMakeLists.txt +++ b/src/helpers/creds-dbus/CMakeLists.txt @@ -25,6 +25,7 @@ SET(LIB_CREDS_DBUS_PATH ${CYNARA_PATH}/helpers/creds-dbus) SET(LIB_CREDS_DBUS_SOURCES ${LIB_CREDS_DBUS_PATH}/creds-dbus.cpp + ${LIB_CREDS_DBUS_PATH}/creds-dbus-inner.cpp ) PKG_CHECK_MODULES(LIB_CREDS_DBUS_DEP diff --git a/src/helpers/creds-dbus/creds-dbus-inner.cpp b/src/helpers/creds-dbus/creds-dbus-inner.cpp new file mode 100644 index 0000000..f72f073 --- /dev/null +++ b/src/helpers/creds-dbus/creds-dbus-inner.cpp @@ -0,0 +1,58 @@ +/* + * 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 creds-dbus-inner.cpp + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Implementation of internal libcynara-creds-dbus functions + */ + +#include + +#include + +#include "creds-dbus-inner.h" + +int getClientSmackLabel(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, + char **client UNUSED) { + //todo + return CYNARA_API_METHOD_NOT_SUPPORTED; +} + +int getClientPid(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, + char **client UNUSED) { + //todo + return CYNARA_API_METHOD_NOT_SUPPORTED; +} + +int getUserId(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, + char **user UNUSED) { + //todo + return CYNARA_API_METHOD_NOT_SUPPORTED; +} + +int getUserGid(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, + char **user UNUSED) { + //todo + return CYNARA_API_METHOD_NOT_SUPPORTED; +} + +int getPid(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, pid_t *pid UNUSED) { + //todo + return CYNARA_API_METHOD_NOT_SUPPORTED; +} diff --git a/src/helpers/creds-dbus/creds-dbus-inner.h b/src/helpers/creds-dbus/creds-dbus-inner.h new file mode 100644 index 0000000..4c51119 --- /dev/null +++ b/src/helpers/creds-dbus/creds-dbus-inner.h @@ -0,0 +1,39 @@ +/* + * 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 creds-dbus-inner.h + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb + * @author Lukasz Wojciechowski + * @version 1.0 + * @brief Definition of internal external libcynara-creds-dbus functions + */ + +#ifndef SRC_HELPERS_CREDSDBUS_CREDSDBUSINNER_H_ +#define SRC_HELPERS_CREDSDBUS_CREDSDBUSINNER_H_ + +#include +#include + +int getClientSmackLabel(DBusConnection *connection, const char *uniqueName, char **client); +int getClientPid(DBusConnection *connection, const char *uniqueName, char **client); + +int getUserId(DBusConnection *connection, const char *uniqueName, char **user); +int getUserGid(DBusConnection *connection, const char *uniqueName, char **user); + +int getPid(DBusConnection *connection, const char *uniqueName, pid_t *pid); + +#endif /* SRC_HELPERS_CREDSDBUS_CREDSDBUSINNER_H_ */ diff --git a/src/helpers/creds-dbus/creds-dbus.cpp b/src/helpers/creds-dbus/creds-dbus.cpp index 535ca84..344cd02 100644 --- a/src/helpers/creds-dbus/creds-dbus.cpp +++ b/src/helpers/creds-dbus/creds-dbus.cpp @@ -15,9 +15,58 @@ */ /* * @file creds-dbus.cpp + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb * @author Lukasz Wojciechowski * @version 1.0 * @brief Implementation of external libcynara-creds-dbus API */ -// Empty initial file + +#include + +#include + +#include +#include +#include + +CYNARA_API +int cynara_creds_dbus_get_client(DBusConnection *connection, const char *uniqueName, + enum cynara_client_creds method, char **client) { + if (connection == nullptr || uniqueName == nullptr || client == nullptr) + return CYNARA_API_INVALID_PARAM; + + switch (method) { + case cynara_client_creds::CLIENT_METHOD_SMACK: + return getClientSmackLabel(connection, uniqueName, client); + case cynara_client_creds::CLIENT_METHOD_PID: + return getClientPid(connection, uniqueName, client); + default: + return CYNARA_API_METHOD_NOT_SUPPORTED; + } +} + +CYNARA_API +int cynara_creds_dbus_get_user(DBusConnection *connection, const char *uniqueName, + enum cynara_user_creds method, char **user) { + if (connection == nullptr || uniqueName == nullptr || user == nullptr) + return CYNARA_API_INVALID_PARAM; + + switch (method) { + case cynara_user_creds::USER_METHOD_UID: + return getUserId(connection, uniqueName, user); + case cynara_user_creds::USER_METHOD_GID: + return getUserGid(connection, uniqueName, user); + default: + return CYNARA_API_METHOD_NOT_SUPPORTED; + } +} + +CYNARA_API +int cynara_creds_dbus_get_pid(DBusConnection *connection, const char *uniqueName, pid_t *pid) { + if (connection == nullptr || uniqueName == nullptr) + return CYNARA_API_INVALID_PARAM; + + return getPid(connection, uniqueName, pid); +} diff --git a/src/include/cynara-creds-dbus.h b/src/include/cynara-creds-dbus.h index 925a829..904e4dd 100644 --- a/src/include/cynara-creds-dbus.h +++ b/src/include/cynara-creds-dbus.h @@ -16,6 +16,7 @@ /* * @file cynara-creds-dbus.h * @author Lukasz Wojciechowski + * @author Radoslaw Bartosiak * @version 1.0 * @brief This file contains Cynara credentials helper APIs for dbus clients. */ @@ -24,11 +25,133 @@ #ifndef CYNARA_CREDS_DBUS_H #define CYNARA_CREDS_DBUS_H +#include +#include + +#include "cynara-creds-commons.h" + #ifdef __cplusplus extern "C" { #endif -/* empty initial file */ +/** + * \par Description: + * Creates a client identification string with given method. Client is a process identified by the + * unique name at the other side of the dbus connection. + * + * \par Purpose: + * Client identification string is required for cynara_check() and cynara_async_check() functions. + * + * \par Typical use case: + * The function is called before the call of one of ...check() functions. + * Returned string is used as client parameter in ...check() function. + * String is released with free() function when it is no longer needed. + * + * \par Method of function operation: + * The function generates client string by calling a method from DBus Interface + * ("org.freedesktop.DBus") which is placed on system bus ("org.freedesktop.DBus"). + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is NOT thread-safe. If functions from described API are called by multithreaded + * application from different threads, they must be put into mutex protected critical section. + * + * \par Important notes: + * Memory for returned client string is obtained with malloc(), and should be freed with free(). + * Allocated string is returned only, when function succeeds. + * + * \param[in] connection DBus connection to a bus. It manages incomming and outgoing messages + * \param[in] uniqueName DBus identifier of the client + * \param[in] method Method of client identifier creation + * \param[out] client Placeholder for allocated string containing client id + * + * \return CYNARA_API_SUCCESS on success + * CYNARA_API_INVALID_PARAM when client is NULL or uniqueName or client has wrong + * value (i.e NULL or non-existing) + * CYNARA_API_METHOD_NOT_SUPPORTED when requested method is not supported + * CYNARA_API_OUT_OF_MEMORY when there was error allocating memory + */ +int cynara_creds_dbus_get_client(DBusConnection *connection, const char *uniqueName, + enum cynara_client_creds method, char **client); + +/** + * \par Description: + * Creates a user identification string with given method. User is an executor of process + * at the other side of socket. + * + * \par Purpose: + * User identification string is required for cynara_check() and cynara_async_check() functions. + * + * \par Typical use case: + * The function is called before the call of one of ...check() functions. + * Returned string is used as user parameter in ...check() function. + * String is released with free() function when it is no longer needed. + * + * \par Method of function operation: + * The function generates user string by calling a method from DBus Interface + * ("org.freedesktop.DBus") which is placed on system bus ("org.freedesktop.DBus"). + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is NOT thread-safe. If functions from described API are called by multithreaded + * application from different threads, they must be put into mutex protected critical section. + * + * \par Important notes: + * Memory for returned user string is obtained with malloc(), and should be freed with free(). + * Allocated string is returned only, when function succeeds. + * + * \param[in] connection DBus connection to a bus. It manages incomming and outgoing messages + * \param[in] uniqueName DBus identifier of the client invoked by the user + * \param[in] method Method of client identifier creation + * \param[out] user Placeholder for allocated string containing user id + * + * \return CYNARA_API_SUCCESS on success + * CYNARA_API_INVALID_PARAM when user is NULL or connection is not valid DBus connection or + * uniqueName does not represent a process conected to the DBus + * CYNARA_API_METHOD_NOT_SUPPORTED when requested method is not supported + * CYNARA_API_OUT_OF_MEMORY when there was error allocating memory + */ +int cynara_creds_dbus_get_user(DBusConnection *connection, const char *uniqueName, + enum cynara_user_creds method, char **user); + +/** + * \par Description: + * Return PID of a proces identified by the unique name at the other side of the dbus connection. + * + * \par Purpose: + * PID may be used for client_session creation with cynara_helper_session_from_pid() function + * from libcynara-helper-session library. Client_session is needed for cynara_check() + * and cynara_async_check() functions. + * + * \par Typical use case: + * The function is called before the call of cynara_helper_session_from_pid() function. + * + * \par Method of function operation: + * The function reads PID of the peer by calling a method from DBus Interface + * ("org.freedesktop.DBus") which is placed on system bus ("org.freedesktop.DBus") + * with "GetConnectionUnixProcessID" argument. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is NOT thread-safe. If functions from described API are called by multithreaded + * application from different threads, they must be put into mutex protected critical section. + * + * \param[in] connection DBus connection to a bus. It manages incomming and outgoing messages + * \param[in] uniqueName DBus identifier of the client invoked by the user + * \param[out] pid Placeholder for PID returned by function + * + * \return CYNARA_API_SUCCESS on success + * CYNARA_API_INVALID_PARAM when socket_fd is not valid connected socket descriptor + * CYNARA_API_UNKNOWN_ERROR when system function fails in incredible situation + * CYNARA_API_OUT_OF_MEMORY when there was error allocating memory + */ +int cynara_creds_dbus_get_pid(DBusConnection *connection, const char *uniqueName, pid_t *pid); #ifdef __cplusplus } -- 2.7.4 From f42327401e1a13cb8434b24ab9195d269c5c99f6 Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Sun, 31 Aug 2014 21:01:33 +0200 Subject: [PATCH 12/16] Add mockuped versions of default credential methods helpers Change-Id: I762a435b4a2fcf81239e7d91b454cd8c785095cb --- src/helpers/creds-commons/creds-commons.cpp | 23 ++++++++++++++++++++++- src/include/cynara-creds-commons.h | 4 +++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/helpers/creds-commons/creds-commons.cpp b/src/helpers/creds-commons/creds-commons.cpp index 4cb7897..390f2ea 100644 --- a/src/helpers/creds-commons/creds-commons.cpp +++ b/src/helpers/creds-commons/creds-commons.cpp @@ -16,8 +16,29 @@ /* * @file creds-commons.cpp * @author Lukasz Wojciechowski + * @author Radoslaw Bartosiak + * @author Aleksander Zdyb * @version 1.0 * @brief Implementation of external libcynara-creds-commons API */ -// Empty initial file +#include + +#include +#include + +CYNARA_API +int cynara_creds_get_default_client_method(enum cynara_client_creds *method) { + //todo read from proper file and parse + + *method = CLIENT_METHOD_SMACK; + return CYNARA_API_SUCCESS; +} + +CYNARA_API +int cynara_creds_get_default_user_method(enum cynara_user_creds *method) { + //todo read from proper file and parse + + *method = USER_METHOD_UID; + return CYNARA_API_SUCCESS; +} diff --git a/src/include/cynara-creds-commons.h b/src/include/cynara-creds-commons.h index 9f012e1..7e46126 100644 --- a/src/include/cynara-creds-commons.h +++ b/src/include/cynara-creds-commons.h @@ -40,7 +40,9 @@ enum cynara_user_creds { extern "C" { #endif -/* empty initial file */ +int cynara_creds_get_default_client_method(enum cynara_client_creds *method); + +int cynara_creds_get_default_user_method(enum cynara_user_creds *method); #ifdef __cplusplus } -- 2.7.4 From 86a124c006960764e9eb4fc5754e705dcd05e994 Mon Sep 17 00:00:00 2001 From: Aleksander Zdyb Date: Thu, 4 Sep 2014 15:31:31 +0200 Subject: [PATCH 13/16] Implement cynara-creds-dbus library Signed-off-by: Radoslaw Bartosiak Signed-off-by: Aleksander Zdyb Change-Id: Iccf9cb0acb1016746d8af7a4ee85714e74f4664e --- src/helpers/creds-dbus/creds-dbus-inner.cpp | 168 +++++++++++++++++++++++++--- 1 file changed, 153 insertions(+), 15 deletions(-) diff --git a/src/helpers/creds-dbus/creds-dbus-inner.cpp b/src/helpers/creds-dbus/creds-dbus-inner.cpp index f72f073..dbbfb0d 100644 --- a/src/helpers/creds-dbus/creds-dbus-inner.cpp +++ b/src/helpers/creds-dbus/creds-dbus-inner.cpp @@ -23,27 +23,160 @@ */ #include +#include +#include #include #include "creds-dbus-inner.h" -int getClientSmackLabel(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, - char **client UNUSED) { - //todo - return CYNARA_API_METHOD_NOT_SUPPORTED; +// TODO: Move this class somewhere else +// TODO: Find a better name for this class +// TODO: Introduce std::exception instead of throwing ints +// TODO: Make this class more general +// TODO: Write tests for this class +class DBusMethod { +public: + typedef int ArgType; + DBusMethod(DBusConnection *connection, const std::string &method) : m_connection(connection) { + if (connection == nullptr) + throw CYNARA_API_INVALID_PARAM; + + m_message = dbus_message_new_method_call(m_dbusName.c_str(), m_dbusObject.c_str(), + m_dbusInterface.c_str(), method.c_str()); + + if (m_message == nullptr) + throw CYNARA_API_OUT_OF_MEMORY; + } + + ~DBusMethod() { + if (m_message != nullptr) + dbus_message_unref(m_message); + + delete m_argsIter; + } + + void appendArg(ArgType type, void *value) { + if (dbus_message_append_args(m_message, type, value, DBUS_TYPE_INVALID) == FALSE) + throw CYNARA_API_UNKNOWN_ERROR; + } + + void getArgPtr(ArgType type, void *value) { + if (m_argsIter == nullptr) + throw CYNARA_API_UNKNOWN_ERROR; + + if (dbus_message_iter_get_arg_type(m_argsIter) != type) + throw CYNARA_API_UNKNOWN_ERROR; + + dbus_message_iter_get_basic(m_argsIter, value); + dbus_message_iter_next(m_argsIter); + } + + DBusMethod send(void) { + DBusPendingCall *reply = nullptr; + auto ret = dbus_connection_send_with_reply(m_connection, m_message, &reply, + DBUS_TIMEOUT_USE_DEFAULT); + if (ret == FALSE) + throw CYNARA_API_OUT_OF_MEMORY; + + if (reply == nullptr) + throw CYNARA_API_INVALID_PARAM; + + dbus_connection_flush(m_connection); + dbus_pending_call_block(reply); + + DBusMessage *replyMsg = dbus_pending_call_steal_reply(reply); + if (replyMsg == nullptr) + throw CYNARA_API_UNKNOWN_ERROR; + + return { m_connection, replyMsg }; + } + +private: + DBusMethod(DBusConnection *connection, DBusMessage *message) + : m_connection(connection), m_message(message), m_argsIter(new DBusMessageIter()) { + + if (dbus_message_iter_init(m_message, m_argsIter) == FALSE) + throw CYNARA_API_UNKNOWN_ERROR; + } + + DBusConnection *m_connection = nullptr; + DBusMessage *m_message = nullptr; + DBusMessageIter *m_argsIter = nullptr; + + static const std::string m_dbusName; + static const std::string m_dbusObject; + static const std::string m_dbusInterface; +}; + +const std::string DBusMethod::m_dbusName = "org.freedesktop.DBus"; +const std::string DBusMethod::m_dbusObject = "/org/freedesktop/DBus"; +const std::string DBusMethod::m_dbusInterface = "org.freedesktop.DBus"; + + +int getIdFromConnection(DBusConnection *connection, const char *uniqueName, + const std::string &dbusMethod, unsigned int *id) { + + if (uniqueName == nullptr) + return CYNARA_API_INVALID_PARAM; + + if (dbusMethod != "GetConnectionUnixUser" && dbusMethod != "GetConnectionUnixProcessID") + return CYNARA_API_INVALID_PARAM; + + try { + DBusMethod call(connection, dbusMethod); + call.appendArg(DBUS_TYPE_STRING, &uniqueName); + auto reply = call.send(); + reply.getArgPtr(DBUS_TYPE_UINT32, id); + } catch (int apiError) { + return apiError; + } + + return CYNARA_API_SUCCESS; } -int getClientPid(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, - char **client UNUSED) { - //todo - return CYNARA_API_METHOD_NOT_SUPPORTED; +int getClientSmackLabel(DBusConnection *connection, const char *uniqueName, char **client) { + if (uniqueName == nullptr) + return CYNARA_API_INVALID_PARAM; + + try { + DBusMethod call(connection, "GetConnectionSmackContext"); + call.appendArg(DBUS_TYPE_STRING, &uniqueName); + auto reply = call.send(); + char *label; + reply.getArgPtr(DBUS_TYPE_STRING, &label); + *client = strdup(label); + if (*client == nullptr) + return CYNARA_API_OUT_OF_MEMORY; + } catch (int apiError) { + return apiError; + } + + return CYNARA_API_SUCCESS; } -int getUserId(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, - char **user UNUSED) { - //todo - return CYNARA_API_METHOD_NOT_SUPPORTED; +int getUint32(DBusConnection *connection, const char *uniqueName, const char *method, + char **value) { + unsigned int dbusValue; + int ret = getIdFromConnection(connection, uniqueName, method, &dbusValue); + + if (ret != CYNARA_API_SUCCESS) + return ret; + + *value = strdup(std::to_string(dbusValue).c_str()); + + if (*value == nullptr) + return CYNARA_API_OUT_OF_MEMORY; + + return CYNARA_API_SUCCESS; +} + +int getClientPid(DBusConnection *connection, const char *uniqueName, char **client) { + return getUint32(connection, uniqueName, "GetConnectionUnixProcessID", client); +} + +int getUserId(DBusConnection *connection, const char *uniqueName, char **user) { + return getUint32(connection, uniqueName, "GetConnectionUnixUser", user); } int getUserGid(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, @@ -52,7 +185,12 @@ int getUserGid(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, return CYNARA_API_METHOD_NOT_SUPPORTED; } -int getPid(DBusConnection *connection UNUSED, const char *uniqueName UNUSED, pid_t *pid UNUSED) { - //todo - return CYNARA_API_METHOD_NOT_SUPPORTED; +int getPid(DBusConnection *connection, const char *uniqueName, pid_t *pid) { + unsigned int _pid; + auto ret = getIdFromConnection(connection, uniqueName, "GetConnectionUnixProcessID", &_pid); + + if (ret == CYNARA_API_SUCCESS) + *pid = _pid; + + return ret; } -- 2.7.4 From 409a48e8b43bae1ee0b5b786b9f029577726adb3 Mon Sep 17 00:00:00 2001 From: Jacek Bukarewicz Date: Thu, 28 Aug 2014 14:21:47 +0200 Subject: [PATCH 14/16] Synchronize RPM and pkg-config versions This change also introduces CYNARA_VERSION cmake variable which will need to be kept in sync with rpm package version. We cannot rely on passing version from RPM spec since we want to be able to build Cynara independently of the Tizen build system. Change-Id: I1bdd3a603a486d386f261e8330a9635923945569 Signed-off-by: Jacek Bukarewicz --- CMakeLists.txt | 1 + pkgconfig/cynara-admin/cynara-admin.pc.in | 2 +- pkgconfig/cynara-client/cynara-client.pc.in | 2 +- pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in | 2 +- pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in | 2 +- pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in | 2 +- pkgconfig/cynara-session/cynara-session.pc.in | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4f80a2..8cdd475 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) PROJECT("cynara") +set(CYNARA_VERSION 0.2.2) ############################# cmake packages ################################## diff --git a/pkgconfig/cynara-admin/cynara-admin.pc.in b/pkgconfig/cynara-admin/cynara-admin.pc.in index 3bf19a0..faa6c47 100644 --- a/pkgconfig/cynara-admin/cynara-admin.pc.in +++ b/pkgconfig/cynara-admin/cynara-admin.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: cynara-admin Description: cynara-admin package -Version: 0.0.1 +Version: @CYNARA_VERSION@ Requires: Libs: -L${libdir} -lcynara-admin Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-client/cynara-client.pc.in b/pkgconfig/cynara-client/cynara-client.pc.in index d81e8ab..e1505a0 100644 --- a/pkgconfig/cynara-client/cynara-client.pc.in +++ b/pkgconfig/cynara-client/cynara-client.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: cynara-client Description: cynara-client package -Version: 0.0.1 +Version: @CYNARA_VERSION@ Requires: Libs: -L${libdir} -lcynara-client Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in b/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in index cb87e5f..7d6e3c4 100644 --- a/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in +++ b/pkgconfig/cynara-creds-commons/cynara-creds-commons.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: cynara-creds-commons Description: Base package for all cynara-creds packages -Version: 0.0.1 +Version: @CYNARA_VERSION@ Requires: Libs: -L${libdir} -lcynara-creds-commons Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in b/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in index 296ce6c..eb09848 100644 --- a/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in +++ b/pkgconfig/cynara-creds-dbus/cynara-creds-dbus.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: cynara-creds-dbus Description: cynara-creds package for dbus clients -Version: 0.0.1 +Version: @CYNARA_VERSION@ Requires: dbus-1 Libs: -L${libdir} -lcynara-creds-dbus Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in b/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in index b81cf68..3c53f53 100644 --- a/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in +++ b/pkgconfig/cynara-creds-socket/cynara-creds-socket.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: cynara-creds-socket Description: cynara-creds package for socket clients -Version: 0.0.1 +Version: @CYNARA_VERSION@ Requires: Libs: -L${libdir} -lcynara-creds-socket Cflags: -I${includedir}/cynara diff --git a/pkgconfig/cynara-session/cynara-session.pc.in b/pkgconfig/cynara-session/cynara-session.pc.in index fa6e763..e734739 100644 --- a/pkgconfig/cynara-session/cynara-session.pc.in +++ b/pkgconfig/cynara-session/cynara-session.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/include Name: cynara-session Description: cynara-session package -Version: 0.0.1 +Version: @CYNARA_VERSION@ Requires: Libs: -L${libdir} -lcynara-session Cflags: -I${includedir}/cynara -- 2.7.4 From 90c41617da666439c88415a2fb2868ac9e8ef1fa Mon Sep 17 00:00:00 2001 From: Radoslaw Bartosiak Date: Thu, 4 Sep 2014 15:59:50 +0200 Subject: [PATCH 15/16] Add documentation to cynara-creds-commons.h Signed-off-by: Radoslaw Bartosiak Change-Id: I717b1cc988c5fc6780d42774c75a4596a522c3e2 --- src/include/cynara-creds-commons.h | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/include/cynara-creds-commons.h b/src/include/cynara-creds-commons.h index 7e46126..1bb3ffc 100644 --- a/src/include/cynara-creds-commons.h +++ b/src/include/cynara-creds-commons.h @@ -40,8 +40,67 @@ enum cynara_user_creds { extern "C" { #endif +/** + * \par Description: + * Gets the system default method value for client feature used in cynara-creds. + * + * \par Purpose: + * Functions cynara_creds_dbus_get_client() and cynara_creds_socket_get_client() take a method + * parameter, which determines a kind of process feature (i.e PID, SMACK label) returned by them. + * The described function provides implementation for obtaining a system default value + * for this parameter. + * + * \par Typical use case: + * The function might be called before cynara_creds_dbus_get_client() and cynara_creds_socket_get_client(), + * when functions shall be invoked with system default value of method parameter. + * + * \par Method of function operation: + * Now the function is mocked up. It sets method to CLIENT_METHOD_SMACK and returns CYNARA_API_SUCCESS. + * In the future the function will probably read the value from /etc/cynara/cynara_client_creds file. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is thread-safe. + * + * \param[out] method Placeholder for system default client feature + * (like CLIENT_METHOD_SMACK, CLIENT_METHOD_PID) + * + * \return CYNARA_API_SUCCESS on success, negative error code on error + */ int cynara_creds_get_default_client_method(enum cynara_client_creds *method); +/** + * \par Description: + * Gets the system default method value for user feature used in cynara-creds. + * + * \par Purpose: + * Functions cynara_creds_dbus_get_user() and cynara_creds_socket_get_user() take a method + * parameter, which determines a kind of process feature (i.e UID, GID) returned by them. + * The described function provides implementation for obtaining a system default value + * for this parameter. + * + * \par Typical use case: + * The function might be called before cynara_creds_dbus_get_user() and cynara_creds_socket_get_user(), + * when functions shall be invoked with system default value of method parameter. + * + * \par Method of function operation: + * + * The function reads the value from /etc/cynara/cynara_user_creds file. + * Now the function is mocked up. It sets method to USER_METHOD_UID and returns CYNARA_API_SUCCESS. + * In the future the function will probably read the value from /etc/cynara/cynara_user_creds file. + * + * \par Sync (or) Async: + * This is a synchronous API. + * + * \par Thread safety: + * This function is thread-safe. + * + * \param[out] method Placeholder for system default user feature (like USER_METHOD_UID, USER_METHOD_GID) + * + * \return CYNARA_API_SUCCESS on success, negative error code on error + */ int cynara_creds_get_default_user_method(enum cynara_user_creds *method); #ifdef __cplusplus -- 2.7.4 From 95189fc1ae98c7f85885048dbb9ccb5eed584e33 Mon Sep 17 00:00:00 2001 From: Zofia Abramowska Date: Thu, 4 Sep 2014 15:16:42 +0200 Subject: [PATCH 16/16] Fix creds dependencies Change-Id: I3d5dd7bdfad9a58b99e754d5acb9dcb20a18b0e8 --- packaging/cynara.spec | 2 ++ src/include/cynara-creds-commons.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packaging/cynara.spec b/packaging/cynara.spec index 2036d61..a297c4f 100644 --- a/packaging/cynara.spec +++ b/packaging/cynara.spec @@ -132,6 +132,7 @@ 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) @@ -146,6 +147,7 @@ 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) diff --git a/src/include/cynara-creds-commons.h b/src/include/cynara-creds-commons.h index 1bb3ffc..ca83e3a 100644 --- a/src/include/cynara-creds-commons.h +++ b/src/include/cynara-creds-commons.h @@ -26,6 +26,8 @@ #ifndef CYNARA_CREDS_COMMONS_H #define CYNARA_CREDS_COMMONS_H +#include + enum cynara_client_creds { CLIENT_METHOD_SMACK, CLIENT_METHOD_PID -- 2.7.4