--- /dev/null
+#!/bin/sh
+
+export TET_INSTALL_PATH=$HOME/git/tetware/TETware # local tetware path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/git/tetware/TETware
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
--- /dev/null
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+33 "INSPECT"
--- /dev/null
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/unit/tslist
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
--- /dev/null
+TET_OUTPUT_CAPTURE=False
--- /dev/null
+CC ?= gcc
+
+TARGETS = utc_ApplicationFW_ac_register_launch_privilege_func \
+ utc_ApplicationFW_ac_unregister_launch_privilege_func \
+ utc_ApplicationFW_ac_check_launch_privilege_func
+
+PKGS = glib-2.0 dlog app-checker
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+LDFLAGS += -L/usr/lib -lpthread
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+ $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+ rm -f $(TARGETS)
--- /dev/null
+#!/bin/sh
+
+TMPSTR=$0
+SCRIPT=${TMPSTR##*/}
+
+if [ $# -lt 2 ]; then
+ echo "Usage) $SCRIPT module_name api_name"
+ exit 1
+fi
+
+MODULE=$1
+API=$2
+TEMPLATE=utc_MODULE_API_func.c.in
+TESTCASE=utc_${MODULE}_${API}_func
+
+sed -e '
+ s^@API@^'"$API"'^g
+ s^@MODULE@^'"$MODULE"'^g
+ ' $TEMPLATE > $TESTCASE.c
+
+if [ ! -e "$TESTCASE.c" ]; then
+ echo "Failed"
+ exit 1
+fi
+echo "Testcase file is $TESTCASE.c"
+echo "Done"
+echo "please put \"$TESTCASE\" as Target in Makefile"
+echo "please put \"/unit/$TESTCASE\" in tslist"
--- /dev/null
+/unit/utc_ApplicationFW_ac_register_launch_privilege_func
+/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func
+/unit/utc_ApplicationFW_ac_check_launch_privilege_func
--- /dev/null
+/*
+ * app-checker
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * 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.
+ *
+ */
+#include <tet_api.h>
+#include <app-checker.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_ac_check_launch_privilege_func_01(void);
+static void utc_ApplicationFW_ac_check_launch_privilege_func_02(void);
+static void utc_ApplicationFW_ac_check_launch_privilege_func_03(void);
+static void utc_ApplicationFW_ac_check_launch_privilege_func_04(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_ac_check_launch_privilege_func_01, POSITIVE_TC_IDX},
+ {utc_ApplicationFW_ac_check_launch_privilege_func_02, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_ac_check_launch_privilege_func_03, NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_ac_check_launch_privilege_func_04, NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/** API Prototype
+*int ac_check_launch_privilege(const char *pkg_name,
+* const char *pkg_type, int pid);
+*/
+
+
+/**
+ * @brief Positive test case of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_01(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_check_launch_privilege("org.tizen.calculator", "deb",
+ getpid());
+ if (r < 0) {
+ tet_infoline
+ ("ac_check_launch_privilege()"
+ " failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_02(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_check_launch_privilege(NULL, "deb", getpid());
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_check_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_03(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_check_launch_privilege("org.tizen.calculator", NULL, getpid());
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_check_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 03 of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_04(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_check_launch_privilege(NULL, NULL, getpid());
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_check_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-checker
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * 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.
+ *
+ */
+#include <tet_api.h>
+#include <app-checker.h>
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_ac_register_launch_privilege_func_01(void);
+static void utc_ApplicationFW_ac_register_launch_privilege_func_02(void);
+static void utc_ApplicationFW_ac_register_launch_privilege_func_03(void);
+static void utc_ApplicationFW_ac_register_launch_privilege_func_04(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_ac_register_launch_privilege_func_01,
+ POSITIVE_TC_IDX},
+ {utc_ApplicationFW_ac_register_launch_privilege_func_02,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_ac_register_launch_privilege_func_03,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_ac_register_launch_privilege_func_04,
+ NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+/** API Prototype
+*int ac_register_launch_privilege(const char *pkg_name,
+* const char *pkg_type);
+*/
+
+/**
+ * @brief Positive test case of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_01(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_register_launch_privilege("org.tizen.calculator", "deb");
+ if (r < 0 && r != AC_R_ENOPULUGINS) {
+ tet_infoline
+ ("ac_register_launch_privilege()"
+ " failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_02(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_register_launch_privilege(NULL, "deb");
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_register_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_03(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_register_launch_privilege("org.tizen.calculator", NULL);
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_register_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 03 of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_04(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_register_launch_privilege(NULL, NULL);
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_register_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+/*
+ * app-checker
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * 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.
+ *
+ */
+#include <tet_api.h>
+#include <app-checker.h>
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_01(void);
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_02(void);
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_03(void);
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_04(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ {utc_ApplicationFW_ac_unregister_launch_privilege_func_01,
+ POSITIVE_TC_IDX},
+ {utc_ApplicationFW_ac_unregister_launch_privilege_func_02,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_ac_unregister_launch_privilege_func_03,
+ NEGATIVE_TC_IDX},
+ {utc_ApplicationFW_ac_unregister_launch_privilege_func_04,
+ NEGATIVE_TC_IDX},
+ {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/** API Prototype
+*int ac_unregister_launch_privilege(const char *pkg_name,
+* const char *pkg_type);
+*/
+
+
+/**
+ * @brief Positive test case of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_01(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_unregister_launch_privilege("org.tizen.calculator", "deb");
+ if (r < 0 && r != AC_R_ENOPULUGINS) {
+ tet_infoline
+ ("ac_unregister_launch_privilege()"
+ " failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_02(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_unregister_launch_privilege(NULL, "deb");
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_unregister_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_03(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_unregister_launch_privilege("org.tizen.calculator", NULL);
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_unregister_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 03 of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_04(void)
+{
+ int r = AC_R_ERROR;
+ r = ac_unregister_launch_privilege(NULL, NULL);
+ if (r != AC_R_EINVAL) {
+ tet_infoline
+ ("ac_unregister_launch_privilege()"
+ " failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+#include <tet_api.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_@MODULE@_@API@_func_01(void);
+static void utc_@MODULE@_@API@_func_02(void);
+
+enum {
+ POSITIVE_TC_IDX = 0x01,
+ NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+ { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX },
+ { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX },
+};
+
+static void startup(void)
+{
+ int r;
+/*
+ char *err;
+ r = initailze...;
+ if (r) {
+ err = "Error message.......";
+ tet_infoline(err);
+ tet_delete(POSITIVE_TC_IDX, err);
+ tet_delete(NEGATIVE_TC_IDX, err);
+ }
+*/
+
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+ int r = 0;
+
+/*
+ r = @API@(...);
+*/
+ if (r) {
+ tet_infoline("@API@() failed in positive test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init @API@()
+ */
+static void utc_@MODULE@_@API@_func_02(void)
+{
+ int r = 0;
+
+/*
+ r = @API@(...);
+*/
+ if (!r) {
+ tet_infoline("@API@() failed in negative test case");
+ tet_result(TET_FAIL);
+ return;
+ }
+ tet_result(TET_PASS);
+}
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
AC_R_OK = 0 /**< General success */
}ac_return_val;
-int ac_server_initailize();
+int ac_server_initialize();
+int ac_server_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid);
#ifdef __cpulusplus
}
AC_R_OK = 0 /**< General success */
}ac_return_val;
-int ac_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid);
+int ac_check_launch_privilege(const char *appid, const char *pkg_type, int pid);
int ac_register_launch_privilege(const char *pkg_name, const char *pkg_type);
* limitations under the License.
*
*/
-\r
-\r
-#ifndef __INTERNAL_H__\r
-#define __INTERNAL_H__\r
-\r
-#include <unistd.h>\r
-#include <ctype.h>\r
-#include <dlog.h>\r
-\r
-#undef LOG_TAG\r
-#define LOG_TAG "APP-CHECKER"\r
-\r
-#define MAX_PACKAGE_STR_SIZE 512\r
-#define MAX_PACKAGE_TYPE_SIZE 128\r
-\r
-struct ac_data {\r
- char pkg_name[MAX_PACKAGE_STR_SIZE];\r
- char pkg_type[MAX_PACKAGE_TYPE_SIZE];\r
- int pid;\r
-};\r
-\r
-#define _E(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)\r
-#define _D(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)\r
-\r
-#define retvm_if(expr, val, fmt, arg...) do { \\r
- if(expr) { \\r
- _E(fmt, ##arg); \\r
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \\r
- return (val); \\r
- } \\r
-} while (0)\r
-\r
-#define retv_if(expr, val) do { \\r
- if(expr) { \\r
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \\r
- return (val); \\r
- } \\r
-} while (0)\r
-\r
-#endif /* __INTERNAL_H__ */\r
-\r
+
+
+#ifndef __INTERNAL_H__
+#define __INTERNAL_H__
+
+#include <unistd.h>
+#include <ctype.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "APP_CHECKER"
+
+#define MAX_PACKAGE_STR_SIZE 512
+#define MAX_PACKAGE_TYPE_SIZE 128
+
+struct ac_data {
+ char pkg_name[MAX_PACKAGE_STR_SIZE];
+ char pkg_type[MAX_PACKAGE_TYPE_SIZE];
+ int pid;
+};
+
+#define _E(fmt, arg...) LOGE(fmt,##arg)
+#define _D(fmt, arg...) LOGD(fmt,##arg)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+ if(expr) { \
+ _E(fmt, ##arg); \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+ if(expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} while (0)
+
+#endif /* __INTERNAL_H__ */
+
Name: app-checker
Summary: App Checker
-Version: 0.0.8
-Release: 2
+Version: 0.0.20
+Release: 1
Group: System/Libraries
-License: Apache License, Version 2.0
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
Requires(post): /sbin/ldconfig
%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
+export CFLAGS="$CFLAGS -Wall -Werror -Wno-unused-function"
CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=/usr
make %{?jobs:-j%jobs}
%files
+%manifest app-checker.manifest
%defattr(-,root,root,-)
/usr/lib/libapp-checker.so.0
/usr/lib/libapp-checker.so.0.1.0
/usr/include/app-checker/app-checker.h
%files server
+%manifest app-checker.manifest
%defattr(-,root,root,-)
/usr/lib/libapp-checker-server.so.0
/usr/lib/libapp-checker-server.so.0.1.0
unsigned char *data;
struct ac_data ad;
- strncpy(ad.pkg_name, pkg_name, MAX_PACKAGE_STR_SIZE);
- strncpy(ad.pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE);
+ memset(&ad, 0, sizeof(ad));
+
+ strncpy(ad.pkg_name, pkg_name, MAX_PACKAGE_STR_SIZE-1);
+ strncpy(ad.pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE-1);
ad.pid = pid;
data = (unsigned char *)g_base64_encode((const guchar *)&ad, sizeof(ad));
return ret;
}
-SLPAPI int ac_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid)
+SLPAPI int ac_check_launch_privilege(const char *appid, const char *pkg_type, int pid)
{
int ret = -1;
- if(pkg_name == NULL || pkg_type == NULL)
+ if(appid == NULL || pkg_type == NULL)
return AC_R_EINVAL;
- ret = app_send_cmd(pkg_name, pkg_type, pid, AC_CHECK);
+ ret = app_send_cmd(appid, pkg_type, pid, AC_CHECK);
return ret;
}
#include "internal.h"
#define PLUGINS_PREFIX "/usr/lib/ac-plugins"
-#define MAX_LOCAL_BUFSZ 512
+#define MAX_LOCAL_BUFSZ 512
#ifndef SLPAPI
#define SLPAPI __attribute__ ((visibility("default")))
GSList *iter2 = NULL;
ac_type_list_t *type_t;
ac_so_list_t *so_t;
-
+
for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
type_t = iter->data;
if (strncmp(type_t->pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE) == 0) {
for (iter2 = type_t->so_list; iter2 != NULL; iter2 = g_slist_next(iter2)) {
so_t = iter2->data;
- _D("type : %s / so name : %s / func : %x", type_t->pkg_type, so_t->so_name, so_t->ac_check);
+ SECURE_LOGD("type : %s / so name : %s / func : %x", type_t->pkg_type, so_t->so_name, so_t->ac_check);
if (so_t->ac_check && so_t->ac_check(pkg_name) < 0) {
if(pid > 0)
- __send_to_sigkill(pid);
+ __send_to_sigkill(pid);
return AC_R_ERROR;
}
}
return AC_R_OK;
- }
+ }
}
return AC_R_ENOPULUGINS;
ac_type_list_t *type_t;
ac_so_list_t *so_t;
int ret = AC_R_OK;
-
+
for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
type_t = iter->data;
if (strncmp(type_t->pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE) == 0) {
}
}
return ret;
- }
+ }
}
return AC_R_ENOPULUGINS;
ac_type_list_t *type_t;
ac_so_list_t *so_t;
int ret = AC_R_OK;
-
+
for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
type_t = iter->data;
if (strncmp(type_t->pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE) == 0) {
}
}
return ret;
- }
+ }
}
return AC_R_ENOPULUGINS;;
}
ad = (struct ac_data *)g_base64_decode((const gchar*)pkt->data, (gsize *)&size);
+ if (ad == NULL) {
+ _E("out of memory");
+ free(pkt);
+ close(clifd);
+ return FALSE;
+ }
- _D("cmd : %d, pkgname : %s, pkgtype : %s", pkt->cmd, ad->pkg_name, ad->pkg_type);
+ SECURE_LOGD("cmd : %d, pkgname : %s, pkgtype : %s", pkt->cmd, ad->pkg_name, ad->pkg_type);
switch (pkt->cmd) {
case AC_CHECK:
_send_result_to_server(clifd, AC_R_OK);
ret = __check_launch_privilege(ad->pkg_name, ad->pkg_type, ad->pid);
- g_free(ad);
+ g_free(ad);
free(pkt);
return TRUE;
break;
case AC_REGISTER:
ret = __register_launch_privilege(ad->pkg_name, ad->pkg_type);
- break;
+ break;
case AC_UNREGISTER:
ret = __unregister_launch_privilege(ad->pkg_name, ad->pkg_type);
- break;
+ break;
default:
_E("no support packet");
}
_send_result_to_server(clifd, ret);
-
+
g_free(ad);
free(pkt);
return TRUE;
GSList *iter2 = NULL;
ac_type_list_t *type_t;
ac_so_list_t *so_t;
-
+
for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
type_t = iter->data;
if(type_t) {
}
}
g_slist_free(type_t->so_list);
-
-
+
+
if(type_t->pkg_type)
free(type_t->pkg_type);
free(type_t);
src = g_source_new(&funcs, sizeof(GSource));
gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ if (gpollfd == NULL) {
+ _E("out of memory");
+ g_source_unref(src);
+ close(fd);
+ return AC_R_ERROR;
+ }
+
gpollfd->events = POLLIN;
gpollfd->fd = fd;
DIR *dp;
struct dirent *dentry;
- DIR *sub_dp;
+ DIR *sub_dp = NULL;
struct dirent *sub_dentry;
char buf[MAX_LOCAL_BUFSZ];
char buf2[MAX_LOCAL_BUFSZ];
ac_type_list_t *type_t = NULL;
void *handle = NULL;
ac_so_list_t *so_t = NULL;
-
+
dp = opendir(PLUGINS_PREFIX);
if (dp == NULL) {
return AC_R_ERROR;
}
while ((dentry = readdir(dp)) != NULL) {
-
- if(dentry->d_type != DT_DIR)
+
+ if(dentry->d_type != DT_DIR)
continue;
if(strcmp(dentry->d_name,".") == 0 || strcmp(dentry->d_name,"..") == 0)
continue;
-
+
snprintf(buf,MAX_LOCAL_BUFSZ,"%s/%s",PLUGINS_PREFIX,dentry->d_name);
- _D("type : %s", dentry->d_name);
+ SECURE_LOGD("type : %s", dentry->d_name);
type_t = malloc(sizeof(ac_type_list_t));
if(type_t == NULL) {
__pkt_type_list_free();
+ closedir(dp);
return AC_R_ERROR;
}
memset(type_t, 0, sizeof(ac_type_list_t));
type_t->so_list = NULL;
pkg_type_list = g_slist_append(pkg_type_list, (void *)type_t);
-
+
sub_dp = opendir(buf);
-
+ if (sub_dp == NULL) {
+ __pkt_type_list_free();
+ closedir(dp);
+ return AC_R_ERROR;
+ }
+
while ((sub_dentry = readdir(sub_dp)) != NULL) {
-
- if(sub_dentry->d_type == DT_DIR)
+
+ if(sub_dentry->d_type == DT_DIR)
continue;
snprintf(buf2,MAX_LOCAL_BUFSZ,"%s/%s", buf, sub_dentry->d_name);
- _D("so_name : %s", buf2);
-
+ SECURE_LOGD("so_name : %s", buf2);
+
handle = dlopen(buf2, RTLD_LAZY);
- if(handle == NULL)
+ if(handle == NULL)
continue;
so_t = malloc(sizeof(ac_so_list_t));
if(so_t == NULL) {
__pkt_type_list_free();
+ dlclose(handle);
+ handle = NULL;
+ closedir(sub_dp);
+ closedir(dp);
return AC_R_ERROR;
}
memset(so_t, 0, sizeof(ac_so_list_t));
type_t->so_list = g_slist_append(type_t->so_list, (void *)so_t);
handle = NULL;
}
+ closedir(sub_dp);
}
+ closedir(dp);
return AC_R_OK;
}
-SLPAPI int ac_server_initailize()
+SLPAPI int ac_server_initialize()
{
int ret = AC_R_OK;
-
+
ret = __initialize();
-
+
return ret;
}
+SLPAPI int ac_server_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid)
+{
+ int ret = -1;
+ ret = __check_launch_privilege(pkg_name, pkg_type, pid);
+
+ return ret;
+}
static inline void __set_sock_option(int fd, int cli)
{
+ int ret;
int size;
struct timeval tv = { 5, 200 * 1000 }; /* 5.2 sec */
size = AC_SOCK_MAXBUFF;
- setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
- setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
- if (cli)
- setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+ if ( ret < 0 ) {
+ _E("setsockopt error");
+ }
+
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+ if ( ret < 0 ) {
+ _E("setsockopt error");
+ }
+
+ if (cli) {
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ if ( ret < 0 ) {
+ _E("setsockopt error");
+ }
+ }
}
int _create_server_sock()
}
}
- bzero(&saddr, sizeof(saddr));
+ memset(&saddr, 0, sizeof(saddr));
saddr.sun_family = AF_UNIX;
snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s",AC_SOCK_NAME);
unlink(saddr.sun_path);
if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
_E("bind error");
+ close(fd);
return -1;
}
if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
/* Flawfinder: ignore*/
_E("failed to change the socket permission");
+ close(fd);
return -1;
}
if (listen(fd, 10) == -1) {
_E("listen error");
+ close(fd);
return -1;
}
error = 0;
if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
if (errno != EAGAIN && errno != EINPROGRESS) {
- fcntl(fd, F_SETFL, flags);
+ (void)fcntl(fd, F_SETFL, flags);
return (-2);
}
}
return (-1); /* select error: sockfd not set*/
done:
- fcntl(fd, F_SETFL, flags);
+ (void)fcntl(fd, F_SETFL, flags);
if (error) {
close(fd);
errno = error;