From f574b507267e0c3c0dd689e686d965d61c873864 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Thu, 4 Jul 2019 18:55:00 +0900 Subject: [PATCH] pepper-utils: fix files for HAVE_CYNARA Signed-off-by: Sung-Jin Park --- configure.ac | 2 ++ packaging/pepper.spec | 1 - src/lib/devicemgr/Makefile.am | 4 ++-- src/lib/keyrouter/Makefile.am | 4 ++-- src/lib/pepper/utils-security.c | 16 +++++++++------- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index ab0a2d6..16e3aba 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,8 @@ PKG_CHECK_MODULES(CYNARA, [cynara-client, cynara-creds-socket, cynara-session, l if test "x${have_cynara}" = "xyes"; then AC_DEFINE([HAVE_CYNARA], [1], [Define to 1 if you have cynara]) PEPPER_REQUIRES="$PEPPER_REQUIRES cynara-client cynara-creds-socket cynara-session libsmack" + PEPPER_CFLAGS+="$CYNARA_CFLAGS -DHAVE_CYNARA=1 " + PEPPER_LIBS+="$CYNARA_LIBS " fi AM_CONDITIONAL([HAVE_CYNARA], [test "x${have_cynara}" = "xyes"]) diff --git a/packaging/pepper.spec b/packaging/pepper.spec index f98bdb5..5d135d9 100644 --- a/packaging/pepper.spec +++ b/packaging/pepper.spec @@ -9,7 +9,6 @@ Source: %{name}-%{version}.tar.xz source1001: %name.manifest %define ENABLE_TDM 1 -%define HEADLESS_SERVER 1 BuildRequires: autoconf > 2.64 BuildRequires: automake >= 1.11 diff --git a/src/lib/devicemgr/Makefile.am b/src/lib/devicemgr/Makefile.am index ef455d7..153941c 100644 --- a/src/lib/devicemgr/Makefile.am +++ b/src/lib/devicemgr/Makefile.am @@ -5,8 +5,8 @@ AM_CFLAGS = $(GCC_CFLAGS) libpepper_devicemgr_includedir=$(includedir)/pepper libpepper_devicemgr_include_HEADERS = devicemgr.h pepper-devicemgr.h -libpepper_devicemgr_la_CFLAGS = $(AM_CFLAGS) $(PEPPER_DEVICEMGR_CFLAGS) $(CYNARA_CFLAGS) -libpepper_devicemgr_la_LIBADD = $(PEPPER_DEVICEMGR_LIBS) $(CYNARA_LIBS) +libpepper_devicemgr_la_CFLAGS = $(AM_CFLAGS) $(PEPPER_DEVICEMGR_CFLAGS) +libpepper_devicemgr_la_LIBADD = $(PEPPER_DEVICEMGR_LIBS) libpepper_devicemgr_la_SOURCES = devicemgr-internal.h \ devicemgr.c \ diff --git a/src/lib/keyrouter/Makefile.am b/src/lib/keyrouter/Makefile.am index 4920e1c..fe36aff 100644 --- a/src/lib/keyrouter/Makefile.am +++ b/src/lib/keyrouter/Makefile.am @@ -5,8 +5,8 @@ AM_CFLAGS = $(GCC_CFLAGS) libpepper_keyrouter_includedir=$(includedir)/pepper libpepper_keyrouter_include_HEADERS = keyrouter.h pepper-keyrouter.h -libpepper_keyrouter_la_CFLAGS = $(AM_CFLAGS) $(PEPPER_KEYROUTER_CFLAGS) $(CYNARA_CFLAGS) -libpepper_keyrouter_la_LIBADD = $(PEPPER_KEYROUTER_LIBS) $(CYNARA_LIBS) +libpepper_keyrouter_la_CFLAGS = $(AM_CFLAGS) $(PEPPER_KEYROUTER_CFLAGS) +libpepper_keyrouter_la_LIBADD = $(PEPPER_KEYROUTER_LIBS) libpepper_keyrouter_la_SOURCES = keyrouter-internal.h \ keyrouter.c \ diff --git a/src/lib/pepper/utils-security.c b/src/lib/pepper/utils-security.c index dd3ad39..001ea99 100644 --- a/src/lib/pepper/utils-security.c +++ b/src/lib/pepper/utils-security.c @@ -33,9 +33,11 @@ #include #include #include -#endif +#include +#include + +#define CYNARA_BUFSIZE 128 -#ifdef HAVE_CYNARA static cynara *g_cynara = NULL; static int g_cynara_refcount = 0; static int g_cynara_init_count = 0; @@ -46,7 +48,6 @@ _pepper_security_log_print(int err, const char *fmt, ...) int ret; va_list args; - const int CYNARA_BUFSIZE = 128; char buf[CYNARA_BUFSIZE] = "\0", tmp[CYNARA_BUFSIZE + CYNARA_BUFSIZE] = "\0"; if (fmt) { @@ -93,7 +94,7 @@ pepper_security_privilege_check(pid_t pid, uid_t uid, const char *privilege) snprintf(uid_str, 15, "%d", (int)uid); client_session = cynara_session_from_pid(pid); - PEPPER_CHECK(client_session, finish, ""); + PEPPER_CHECK(client_session, goto finish, ""); ret = cynara_check(g_cynara, client_smack, @@ -104,7 +105,7 @@ pepper_security_privilege_check(pid_t pid, uid_t uid, const char *privilege) if (ret == CYNARA_API_ACCESS_ALLOWED) res = PEPPER_TRUE; else - _pepper_security_log_print(ret, "rule: %s, client_smack: %s, pid: %d", rule, client_smack, pid); + _pepper_security_log_print(ret, "privilege: %s, client_smack: %s, pid: %d", privilege, client_smack, pid); finish: PEPPER_TRACE("Privilege Check For '%s' %s pid:%u uid:%u client_smack:%s(len:%d) client_session:%s ret:%d", @@ -127,7 +128,7 @@ PEPPER_API int pepper_security_init(void) { #ifdef HAVE_CYNARA - int ret; + int ret = CYNARA_API_SUCCESS; int retry_cnt = 0; static pepper_bool_t retried = PEPPER_FALSE; @@ -168,7 +169,7 @@ pepper_security_deinit(void) #ifdef HAVE_CYNARA if (g_cynara_refcount < 1) { - PEPPER_ERROR("%s called without pepper_security_init"); + PEPPER_ERROR("%s called without pepper_security_init\n", __FUNCTION__); return 0; } @@ -180,6 +181,7 @@ pepper_security_deinit(void) g_cynara = NULL; } #endif + return 1; } -- 2.34.1