pepper-utils: fix files for HAVE_CYNARA
authorSung-Jin Park <sj76.park@samsung.com>
Thu, 4 Jul 2019 09:55:00 +0000 (18:55 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 9 Jul 2019 06:28:06 +0000 (15:28 +0900)
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
configure.ac
packaging/pepper.spec
src/lib/devicemgr/Makefile.am
src/lib/keyrouter/Makefile.am
src/lib/pepper/utils-security.c

index ab0a2d65af4f59abd286d62c937050d89457d4dd..16e3abaa65df4c5771d645f53bf6e76b78b42590 100644 (file)
@@ -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"])
 
index f98bdb5b2e048b569fd610b023bde9a22e8e374a..5d135d9768f2b46c26e8a8eab1f122efb0740942 100644 (file)
@@ -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
index ef455d78a4eb6b1f03a2e475b616a2966bf53227..153941cad3ad5323a7f82a728f049ea2b3dc7bc7 100644 (file)
@@ -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 \
index 4920e1ce542cdb95656087b263c17270d8e9e439..fe36affb04bd291cb5a3176cbce7cb0b7360f4dc 100644 (file)
@@ -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 \
index dd3ad39e4d7b9b4e40f083bbe4410bac753be9f9..001ea9906f53bf812fe20187524951ae3c563c26 100644 (file)
 #include <cynara-client.h>
 #include <cynara-creds-socket.h>
 #include <sys/smack.h>
-#endif
+#include <stdarg.h>
+#include <stdio.h>
+
+#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;
 }