tizen beta release
authorKibum Kim <kb0929.kim@samsung.com>
Mon, 27 Feb 2012 12:15:48 +0000 (21:15 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Mon, 27 Feb 2012 12:15:48 +0000 (21:15 +0900)
39 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0644]
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/tet_code [new file with mode: 0755]
TC/tet_scen [new file with mode: 0755]
TC/tetbuild.cfg [new file with mode: 0755]
TC/tetclean.cfg [new file with mode: 0755]
TC/tetexec.cfg [new file with mode: 0755]
TC/unit/Makefile [new file with mode: 0755]
TC/unit/tc_gen.sh [new file with mode: 0755]
TC/unit/tslist [new file with mode: 0755]
TC/unit/utc_ApplicationFW_ac_check_launch_privilege_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_ac_register_launch_privilege_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func.c [new file with mode: 0755]
TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0755]
app-checker-server.pc.in [new file with mode: 0755]
app-checker.pc.in [new file with mode: 0755]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0755]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/libapp-checker-0.install.in [new file with mode: 0755]
debian/libapp-checker-0.postinst [new file with mode: 0755]
debian/libapp-checker-dev.install.in [new file with mode: 0755]
debian/libapp-checker-server-0.install.in [new file with mode: 0755]
debian/libapp-checker-server-0.postinst [new file with mode: 0755]
debian/libapp-checker-server-dev.install.in [new file with mode: 0755]
debian/rules [new file with mode: 0755]
include/ac_sock.h [new file with mode: 0755]
include/app-checker-server.h [new file with mode: 0755]
include/app-checker.h [new file with mode: 0755]
include/internal.h [new file with mode: 0755]
packaging/app-checker.spec [new file with mode: 0644]
src/ac_lib.c [new file with mode: 0755]
src/ac_server.c [new file with mode: 0755]
src/ac_sock.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..064881e
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Jayoun Lee <airjany@samsung.com>
+Sewook Park <sewook7.park@samsung.com>
+Jaeho Lee <jaeho81.lee@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..622b475
--- /dev/null
@@ -0,0 +1,105 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+PROJECT(app-checker C)
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
+
+### Global setting ###
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include/app-checker")
+
+# Build type : Release
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF()
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+
+pkg_check_modules(pkgs REQUIRED dlog glib-2.0)
+pkg_check_modules(libpkgs REQUIRED dlog glib-2.0)
+
+FIND_LIBRARY(LIB_DL dl)
+
+FOREACH(flag ${libpkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(TEST_CFLAGS "${TEST_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+# Compiler flags
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/legacy)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_SKIP_BUILD_RPATH true)
+
+# Get uname value to set 'TARGET' definition 
+# TODO: Is this needed?
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DRW_DATA_PREFIX=\"/opt/share\"")
+
+# Linker flags
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+
+### Build ###
+
+
+# app-checker
+add_library(app-checker SHARED
+               src/ac_lib.c
+               src/ac_sock.c
+               )
+target_link_libraries(app-checker ${libpkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(app-checker PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(app-checker PROPERTIES VERSION ${VERSION})
+
+# 
+SET(DAEMON_NAME "app-checker-server")
+add_library(${DAEMON_NAME} SHARED
+        src/ac_server.c
+       src/ac_sock.c
+        )
+
+target_link_libraries(${DAEMON_NAME} ${pkgs_LDFLAGS} ${LIB_DL})
+SET_TARGET_PROPERTIES(${DAEMON_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${DAEMON_NAME} PROPERTIES VERSION ${VERSION})
+
+# pkgconfig file
+CONFIGURE_FILE(app-checker.pc.in app-checker.pc @ONLY)
+CONFIGURE_FILE(app-checker-server.pc.in app-checker-server.pc @ONLY)
+
+
+
+### Install ###
+INSTALL(TARGETS app-checker DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${DAEMON_NAME} DESTINATION lib COMPONENT RuntimeLibraries)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/app-checker.h DESTINATION include/app-checker)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/app-checker.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/app-checker-server.h DESTINATION include/app-checker)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/app-checker-server.pc DESTINATION lib/pkgconfig)
+
+
+
+
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..9c13a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..e7a9432
--- /dev/null
@@ -0,0 +1,20 @@
+#!/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
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..a119011
--- /dev/null
@@ -0,0 +1,19 @@
+#!/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
diff --git a/TC/tet_code b/TC/tet_code
new file mode 100755 (executable)
index 0000000..a2cf6c1
--- /dev/null
@@ -0,0 +1,12 @@
+# 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"
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755 (executable)
index 0000000..43cbc9b
--- /dev/null
@@ -0,0 +1,7 @@
+all
+       ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+       :include:/unit/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100755 (executable)
index 0000000..a584acd
--- /dev/null
@@ -0,0 +1,2 @@
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100755 (executable)
index 0000000..c66eda4
--- /dev/null
@@ -0,0 +1,2 @@
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100755 (executable)
index 0000000..0d9d39a
--- /dev/null
@@ -0,0 +1 @@
+TET_OUTPUT_CAPTURE=False
diff --git a/TC/unit/Makefile b/TC/unit/Makefile
new file mode 100755 (executable)
index 0000000..8993f7d
--- /dev/null
@@ -0,0 +1,25 @@
+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)
diff --git a/TC/unit/tc_gen.sh b/TC/unit/tc_gen.sh
new file mode 100755 (executable)
index 0000000..54f482d
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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"
diff --git a/TC/unit/tslist b/TC/unit/tslist
new file mode 100755 (executable)
index 0000000..2478015
--- /dev/null
@@ -0,0 +1,3 @@
+/unit/utc_ApplicationFW_ac_register_launch_privilege_func
+/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func
+/unit/utc_ApplicationFW_ac_check_launch_privilege_func
diff --git a/TC/unit/utc_ApplicationFW_ac_check_launch_privilege_func.c b/TC/unit/utc_ApplicationFW_ac_check_launch_privilege_func.c
new file mode 100755 (executable)
index 0000000..df57741
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ *  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);
+}
diff --git a/TC/unit/utc_ApplicationFW_ac_register_launch_privilege_func.c b/TC/unit/utc_ApplicationFW_ac_register_launch_privilege_func.c
new file mode 100755 (executable)
index 0000000..34cfe03
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *  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);
+}
diff --git a/TC/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func.c b/TC/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func.c
new file mode 100755 (executable)
index 0000000..73f8fd8
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ *  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);
+}
diff --git a/TC/unit/utc_MODULE_API_func.c.in b/TC/unit/utc_MODULE_API_func.c.in
new file mode 100755 (executable)
index 0000000..2899c28
--- /dev/null
@@ -0,0 +1,76 @@
+#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);
+}
diff --git a/app-checker-server.pc.in b/app-checker-server.pc.in
new file mode 100755 (executable)
index 0000000..fe01845
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: libapp-checker-server
+Description: application checker server
+Version: @VERSION@
+Requires: 
+Libs: -L${libdir} -lapp-checker-server
+Cflags: -I${includedir}
diff --git a/app-checker.pc.in b/app-checker.pc.in
new file mode 100755 (executable)
index 0000000..38b85c8
--- /dev/null
@@ -0,0 +1,13 @@
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: libapp-checker
+Description: application checker
+Version: @VERSION@
+Requires: 
+Libs: -L${libdir} -lapp-checker
+Cflags: -I${includedir}
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..b25b9a5
--- /dev/null
@@ -0,0 +1,7 @@
+app-checker (0.0.5-1) unstable; urgency=low
+
+  * Initial release
+  * Git: pkgs/a/app-checker
+  * Tag: app-check_0.0.5-1
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 07 Dec 2011 13:41:34 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755 (executable)
index 0000000..cb7ba32
--- /dev/null
@@ -0,0 +1,37 @@
+Source: app-checker
+Section: devel
+Priority: extra
+Maintainer: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+Build-Depends: debhelper (>= 5), dlog-dev, libglib2.0-dev
+Standards-Version: 0.1.0 
+
+Package: libapp-checker-dev
+Section: libs
+Architecture: any
+Depends: libapp-checker-0 (= ${Source-Version})
+Description: libapp-checker dev package
+
+Package: libapp-checker-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: libapp-checker-0 package
+
+Package: libapp-checker-server-dev
+Section: libs
+Architecture: any
+Depends: libapp-checker-server-0 (= ${Source-Version})
+Description: libapp-checker dev package
+
+Package: libapp-checker-server-0
+Section: devel
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: libapp-checker server package
+
+Package: app-checker-dbg
+Section: debug
+Architecture: any
+Depends: libapp-checker-0, libapp-checker-server-0, ${shlibs:Depends}, ${misc:Depends}
+Description: app-checker dbg package 
+
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..ca882bb
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/debian/libapp-checker-0.install.in b/debian/libapp-checker-0.install.in
new file mode 100755 (executable)
index 0000000..95060a0
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/lib/libapp-checker.so*\r
diff --git a/debian/libapp-checker-0.postinst b/debian/libapp-checker-0.postinst
new file mode 100755 (executable)
index 0000000..f904ab2
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "${USER}" = "root" ]
+then
+       chown root:root /usr/lib/libapp-checker.so.0.1.0
+fi
+
+chmod 644 /usr/lib/libapp-checker.so.0.1.0
+
+#chmod 1777 /opt/share/miregex # Set directory to be writable for other accounts
diff --git a/debian/libapp-checker-dev.install.in b/debian/libapp-checker-dev.install.in
new file mode 100755 (executable)
index 0000000..ef3d90e
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/include/app-checker/app-checker.h
+@PREFIX@/lib/pkgconfig/app-checker.pc
diff --git a/debian/libapp-checker-server-0.install.in b/debian/libapp-checker-server-0.install.in
new file mode 100755 (executable)
index 0000000..de22c58
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/lib/libapp-checker-server.so*\r
diff --git a/debian/libapp-checker-server-0.postinst b/debian/libapp-checker-server-0.postinst
new file mode 100755 (executable)
index 0000000..2c53bed
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if [ "${USER}" = "root" ]
+then
+       chown root:root /usr/lib/libapp-checker-server.so.0.1.0
+fi
+
+chmod 644 /usr/lib/libapp-checker-server.so.0.1.0
+
+mkdir -p /usr/lib/ac-plugins
+
+#chmod 1777 /opt/share/miregex # Set directory to be writable for other accounts
diff --git a/debian/libapp-checker-server-dev.install.in b/debian/libapp-checker-server-dev.install.in
new file mode 100755 (executable)
index 0000000..88dc4bc
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/include/app-checker/app-checker-server.h
+@PREFIX@/lib/pkgconfig/app-checker-server.pc
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..379306f
--- /dev/null
@@ -0,0 +1,114 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+CFLAGS += -Wall -g
+LDFLAGS ?= 
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+CFLAGS += -fvisibility=hidden -fpic
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+       mkdir -p $(CMAKE_TMP_DIR);
+       cd $(CMAKE_TMP_DIR); CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+       touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       cd $(CMAKE_TMP_DIR) && $(MAKE) all  
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               cat $$f > $${f%.in}; \
+               sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+               sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+       done
+
+       touch $@
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       rm -rf $(CMAKE_TMP_DIR)
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/wavplayer.
+       cd $(CMAKE_TMP_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+       dh_install --sourcedir=debian/tmp
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       dh_strip --dbg-package=app-checker-dbg
+       dh_compress
+       dh_fixperms
+#      dh_perl
+       dh_makeshlibs
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/include/ac_sock.h b/include/ac_sock.h
new file mode 100755 (executable)
index 0000000..6866c72
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *  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>
+ *
+ * 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.
+ *
+ */
+\r
+\r
+#ifndef __APP_PKT_T_\r
+#define __APP_PKT_T_\r
+\r
+#include <unistd.h>\r
+#define __USE_GNU\r
+#include <sys/socket.h>\r
+#include <linux/un.h>\r
+\r
+enum ac_cmd {\r
+       AC_CHECK,\r
+       AC_REGISTER,\r
+       AC_UNREGISTER,\r
+};\r
+\r
+#define AC_SOCK_NAME "/tmp/ac-socket"\r
+#define AC_SOCK_MAXBUFF 65535\r
+\r
+typedef struct _ac_pkt_t {\r
+       int cmd;\r
+       int len;\r
+       unsigned char data[1];\r
+} ac_pkt_t;\r
+\r
+int _create_server_sock();\r
+int _create_client_sock();\r
+int _app_send_raw(int cmd, unsigned char *data, int datalen);\r
+ac_pkt_t *_app_recv_raw(int fd, int *clifd, struct ucred *cr);\r
+int _send_result_to_server(int fd, int res);\r
+\r
+\r
+#endif\r
+\r
diff --git a/include/app-checker-server.h b/include/app-checker-server.h
new file mode 100755 (executable)
index 0000000..4667fab
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ *  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>
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __APP_CHECKER_SERVER_H__
+#define __APP_CHECKER_SERVER_H__
+
+#ifdef __cpulusplus
+extern "C" {
+#endif
+
+typedef enum _ac_return_val {
+       AC_R_ERROR = -1,                /**< General error */
+       AC_R_OK = 0                     /**< General success */
+}ac_return_val;
+
+int ac_server_initailize();
+
+#ifdef __cpulusplus
+       }
+#endif
+
+#endif         /* __APP_CHECKER_SERVER_H__ */
+
+
+
+
diff --git a/include/app-checker.h b/include/app-checker.h
new file mode 100755 (executable)
index 0000000..b3c4fe0
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  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>
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __APP_CHECKER_H__
+#define __APP_CHECKER_H__
+
+#ifdef __cpulusplus
+extern "C" {
+#endif
+
+typedef enum _ac_return_val {
+       AC_R_ETIMEOUT = -6,             /**< Timeout */
+       AC_R_EINVAL = -4,               /**< Invalid argument */
+       AC_R_ECOMM = -3,        
+       AC_R_ENOPULUGINS = -2,
+       AC_R_ERROR = -1,                /**< General error */
+       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_register_launch_privilege(const char *pkg_name, const char *pkg_type);
+
+int ac_unregister_launch_privilege(const char *pkg_name, const char *pkg_type);
+
+
+#ifdef __cpulusplus
+       }
+#endif
+
+#endif         /* __APP_CHECKER_H__ */
diff --git a/include/internal.h b/include/internal.h
new file mode 100755 (executable)
index 0000000..54ce035
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  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>
+ *
+ * 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.
+ *
+ */
+\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
diff --git a/packaging/app-checker.spec b/packaging/app-checker.spec
new file mode 100644 (file)
index 0000000..6f3de2a
--- /dev/null
@@ -0,0 +1,90 @@
+Name:      app-checker
+Summary:    App Checker
+Version:    0.0.2
+Release:    1
+Group:      System/Libraries
+License:    SAMSUNG
+Source0:    %{name}-%{version}.tar.gz
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+
+BuildRequires: cmake
+
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(glib-2.0)
+
+
+%description
+libapp-checker
+
+%package devel
+Summary:    App Checker
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+libapp-checker (developement files)
+
+%package server
+Summary:    App Checker Server
+Group:      System/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description server
+libapp-checker server
+
+%package server-devel
+Summary:    App Checker Server
+Group:      System/Libraries
+Requires:   %{name}-server = %{version}-%{release}
+
+%description server-devel
+libapp-checker server (developement files)
+
+
+
+%prep
+%setup -q
+
+
+%build
+
+CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%defattr(-,root,root,-)
+/usr/bin/ac_test
+/usr/lib/libapp-checker.so.0
+/usr/lib/libapp-checker.so.0.1.0
+
+%files devel
+%defattr(-,root,root,-)
+/usr/lib/libapp-checker.so
+/usr/lib/pkgconfig/app-checker.pc
+/usr/include/app-checker/app-checker.h
+
+%files server
+%defattr(-,root,root,-)
+/usr/lib/libapp-checker-server.so.0
+/usr/lib/libapp-checker-server.so.0.1.0
+
+%files server-devel
+%defattr(-,root,root,-)
+/usr/lib/libapp-checker-server.so
+/usr/lib/pkgconfig/app-checker-server.pc
+/usr/include/app-checker/app-checker-server.h
+
diff --git a/src/ac_lib.c b/src/ac_lib.c
new file mode 100755 (executable)
index 0000000..0861b55
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ *  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>
+ *
+ * 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 <stdio.h>
+#include <glib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <app-checker.h>
+#include "ac_sock.h"
+#include "internal.h"
+
+#ifndef SLPAPI
+#define SLPAPI __attribute__ ((visibility("default")))
+#endif
+
+static int app_send_cmd(const char *pkg_name, const char *pkg_type, int pid, int cmd)
+{
+       int ret = -1;
+       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);
+       ad.pid = pid;
+
+       data = g_base64_encode(&ad, sizeof(ad));
+       
+       if ((ret = _app_send_raw(cmd, data, strnlen(data, AC_SOCK_MAXBUFF - 8))) < 0) {
+               switch (ret) {
+               case -EINVAL:
+                       ret = AC_R_EINVAL;
+                       break;
+               case -ECOMM:
+                       ret = AC_R_ECOMM;
+                       break;
+               case -EAGAIN:
+                       ret = AC_R_ETIMEOUT;
+                       break;
+               case AC_R_ENOPULUGINS:
+                       ret = AC_R_ENOPULUGINS;
+                       break;
+               default:
+                       ret = AC_R_ERROR;
+               }
+       }
+
+       g_free(data);
+       return ret;
+}
+
+SLPAPI int ac_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid)
+{
+       int ret = -1;
+
+       if(pkg_name == NULL || pkg_type == NULL)
+               return AC_R_EINVAL;
+
+       ret = app_send_cmd(pkg_name, pkg_type, pid, AC_CHECK);
+
+       return ret;
+}
+
+SLPAPI int ac_register_launch_privilege(const char *pkg_name, const char *pkg_type)
+{
+       int ret = -1;
+
+       if(pkg_name == NULL || pkg_type == NULL)
+               return AC_R_EINVAL;
+
+       ret = app_send_cmd(pkg_name, pkg_type, -1, AC_REGISTER);
+
+       return ret;
+}
+
+SLPAPI int ac_unregister_launch_privilege(const char *pkg_name, const char *pkg_type)
+{
+       int ret = -1;
+
+       if(pkg_name == NULL || pkg_type == NULL)
+               return AC_R_EINVAL;
+
+       ret = app_send_cmd(pkg_name, pkg_type, -1, AC_UNREGISTER);
+
+       return ret;     
+}
+
diff --git a/src/ac_server.c b/src/ac_server.c
new file mode 100755 (executable)
index 0000000..531a487
--- /dev/null
@@ -0,0 +1,364 @@
+/*
+ *  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>
+ *
+ * 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 <stdio.h>
+#include <glib.h>
+#include <poll.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include <app-checker.h>
+#include "ac_sock.h"
+#include "internal.h"
+
+#define PLUGINS_PREFIX "/usr/lib/ac-plugins"
+#define MAX_LOCAL_BUFSZ        512
+
+#ifndef SLPAPI
+#define SLPAPI __attribute__ ((visibility("default")))
+#endif
+
+GSList *pkg_type_list = NULL;
+
+typedef struct _ac_type_list_t {
+       char *pkg_type;
+       GSList *so_list;
+} ac_type_list_t;
+
+typedef struct _ac_so_list_t {
+       char *so_name;
+       int (*ac_check)(const char*);
+       int (*ac_register)(const char*);
+       int (*ac_unregister)(const char*);
+} ac_so_list_t;
+
+static int __send_to_sigkill(int pid)
+{
+       int pgid;
+
+       pgid = getpgid(pid);
+       if (pgid <= 1)
+               return -1;
+
+       if (killpg(pgid, SIGKILL) < 0)
+               return -1;
+
+       return 0;
+}
+
+static int __check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid)
+{
+       GSList *iter = NULL;
+       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);
+                               if (so_t->ac_check && so_t->ac_check(pkg_name) < 0) {
+                                       if(pid > 0)
+                                               __send_to_sigkill(pid);                                 
+                                       return AC_R_ERROR;
+                               }
+                       }
+                       return AC_R_OK;
+               }                                               
+       }
+
+       return AC_R_ENOPULUGINS;
+}
+
+static int __register_launch_privilege(const char *pkg_name, const char *pkg_type)
+{
+       GSList *iter = NULL;
+       GSList *iter2 = NULL;
+       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) {
+                       for (iter2 = type_t->so_list; iter2 != NULL; iter = g_slist_next(iter2)) {
+                               so_t = iter2->data;
+                               if (so_t->ac_register && so_t->ac_register(pkg_name) < 0) {
+                                       ret = AC_R_ERROR;
+                               }
+                       }
+                       return ret;
+               }                                               
+       }
+
+       return AC_R_ENOPULUGINS;
+
+}
+
+static int __unregister_launch_privilege(const char *pkg_name, const char *pkg_type)
+{
+       GSList *iter = NULL;
+       GSList *iter2 = NULL;
+       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) {
+                       for (iter2 = type_t->so_list; iter2 != NULL; iter = g_slist_next(iter2)) {
+                               so_t = iter2->data;
+                               if (so_t->ac_unregister && so_t->ac_unregister(pkg_name) < 0) {
+                                       ret = AC_R_ERROR;
+                               }
+                       }
+                       return ret;
+               }                                               
+       }
+
+       return AC_R_ENOPULUGINS;;
+
+}
+
+static gboolean __ac_handler(gpointer data)
+{
+       GPollFD *gpollfd = (GPollFD *) data;
+       int fd = gpollfd->fd;
+       ac_pkt_t *pkt;
+       int clifd;
+       struct ucred cr;
+       struct ac_data *ad;
+       int ret = -1;
+       int size;
+
+       if ((pkt = _app_recv_raw(fd, &clifd, &cr)) == NULL) {
+               _E("recv error");
+               return FALSE;
+       }
+
+       ad = (struct ac_data *)g_base64_decode(pkt->data, &size);
+
+       _D("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); 
+               free(pkt);
+               return TRUE;
+               break;
+       case AC_REGISTER:
+               ret = __register_launch_privilege(ad->pkg_name, ad->pkg_type);
+               break;          
+       case AC_UNREGISTER:
+               ret = __unregister_launch_privilege(ad->pkg_name, ad->pkg_type);
+               break;          
+       default:
+               _E("no support packet");
+       }
+
+       _send_result_to_server(clifd, ret);
+       
+       g_free(ad);
+       free(pkt);
+       return TRUE;
+}
+
+static gboolean __ac_glib_check(GSource *src)
+{
+       GSList *fd_list;
+       GPollFD *tmp;
+
+       fd_list = src->poll_fds;
+       do {
+               tmp = (GPollFD *) fd_list->data;
+               if ((tmp->revents & (POLLIN | POLLPRI)))
+                       return TRUE;
+               fd_list = fd_list->next;
+       } while (fd_list);
+
+       return FALSE;
+}
+
+static gboolean __ac_glib_dispatch(GSource *src, GSourceFunc callback,
+                                 gpointer data)
+{
+       callback(data);
+       return TRUE;
+}
+
+static gboolean __ac_glib_prepare(GSource *src, gint *timeout)
+{
+       return FALSE;
+}
+
+static GSourceFuncs funcs = {
+       .prepare = __ac_glib_prepare,
+       .check = __ac_glib_check,
+       .dispatch = __ac_glib_dispatch,
+       .finalize = NULL
+};
+
+static void __pkt_type_list_free()
+{
+       GSList *iter = NULL;
+       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) {
+                       for (iter2 = type_t->so_list; iter2 != NULL; iter2 = g_slist_next(iter2)) {
+                               so_t = iter2->data;
+                               if(so_t) {
+                                       if(so_t->so_name)
+                                               free(so_t->so_name);
+                                       free(so_t);
+                               }
+                       }
+                       g_slist_free(type_t->so_list);
+               
+               
+                       if(type_t->pkg_type)
+                               free(type_t->pkg_type);
+                       free(type_t);
+               }
+       }
+       g_slist_free(pkg_type_list);
+       return;
+}
+
+int __initialize()
+{
+       int fd;
+       GPollFD *gpollfd;
+       GSource *src;
+       int ret;
+
+       _D("app checker server initialize");
+
+       fd = _create_server_sock();
+
+       src = g_source_new(&funcs, sizeof(GSource));
+
+       gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       gpollfd->events = POLLIN;
+       gpollfd->fd = fd;
+
+       g_source_add_poll(src, gpollfd);
+       g_source_set_callback(src, (GSourceFunc) __ac_handler,
+                             (gpointer) gpollfd, NULL);
+       g_source_set_priority(src, G_PRIORITY_DEFAULT);
+
+       ret = g_source_attach(src, NULL);
+       if (ret == 0)
+       {
+               /* TODO: error handle*/
+               return AC_R_ERROR;
+       }
+
+       g_source_unref(src);
+
+       DIR *dp;
+       struct dirent *dentry;
+       DIR *sub_dp;
+       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) 
+                       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);
+
+               type_t = malloc(sizeof(ac_type_list_t));
+               if(type_t == NULL) {
+                       __pkt_type_list_free();
+                       return AC_R_ERROR;
+               }
+               memset(type_t, 0, sizeof(ac_type_list_t));
+               type_t->pkg_type = strdup(dentry->d_name);
+               type_t->so_list = NULL;
+
+               pkg_type_list = g_slist_append(pkg_type_list, (void *)type_t);
+               
+               sub_dp = opendir(buf);
+               
+               while ((sub_dentry = readdir(sub_dp)) != NULL) {
+                       
+                       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);
+                       
+                       handle = dlopen(buf2, RTLD_LAZY);
+                       if(handle == NULL) 
+                               continue;
+                       so_t = malloc(sizeof(ac_so_list_t));
+                       if(so_t == NULL) {
+                               __pkt_type_list_free();
+                               return AC_R_ERROR;
+                       }
+                       memset(type_t, 0, sizeof(ac_so_list_t));
+                       so_t->so_name = strdup(sub_dentry->d_name);
+                       so_t->ac_check = dlsym(handle, "check_launch_privilege");
+                       so_t->ac_register = dlsym(handle, "check_register_privilege");
+                       so_t->ac_unregister = dlsym(handle, "check_unregister_privilege");
+
+                       type_t->so_list = g_slist_append(type_t->so_list, (void *)so_t);
+                       handle = NULL;
+               }
+       }
+
+       return AC_R_OK;
+}
+
+SLPAPI int ac_server_initailize()
+{
+       int ret = AC_R_OK;
+       
+       ret = __initialize();
+       
+       return ret;
+}
+
diff --git a/src/ac_sock.c b/src/ac_sock.c
new file mode 100755 (executable)
index 0000000..bd17a7c
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ *  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>
+ *
+ * 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.
+ *
+ */
+\r
+\r
+#include <sys/types.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include <sys/stat.h>\r
+#include <errno.h>\r
+#include <fcntl.h>\r
+\r
+\r
+#include "ac_sock.h"\r
+#include "internal.h"\r
+\r
+static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, socklen_t salen,\r
+                  int nsec);\r
+\r
+static inline void __set_sock_option(int fd, int cli)\r
+{\r
+       int size;\r
+       struct timeval tv = { 5, 200 * 1000 };  /*  5.2 sec */\r
+\r
+       size = AC_SOCK_MAXBUFF;\r
+       setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));\r
+       setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));\r
+       if (cli)\r
+               setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));\r
+}\r
+\r
+int _create_server_sock()\r
+{\r
+       struct sockaddr_un saddr;\r
+       struct sockaddr_un p_saddr;\r
+       int fd;\r
+\r
+       fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);\r
+       /*  support above version 2.6.27*/\r
+       if (fd < 0) {\r
+               if(errno == EINVAL) {\r
+                       fd = socket(AF_UNIX, SOCK_STREAM, 0);\r
+                       if(fd < 0) {\r
+                               _E("second chance - socket create error");\r
+                               return -1;\r
+                       }\r
+               } else {\r
+                       _E("socket error");\r
+                       return -1;\r
+               }\r
+       }\r
+\r
+       bzero(&saddr, sizeof(saddr));\r
+       saddr.sun_family = AF_UNIX;\r
+       snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s",AC_SOCK_NAME);\r
+       unlink(saddr.sun_path);\r
+       \r
+       if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {\r
+               _E("bind error");\r
+               return -1;\r
+       }\r
+\r
+       if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {\r
+               /* Flawfinder: ignore*/\r
+               _E("failed to change the socket permission");\r
+               return -1;\r
+       }\r
+\r
+       __set_sock_option(fd, 0);\r
+\r
+       if (listen(fd, 10) == -1) {\r
+               _E("listen error");\r
+               return -1;\r
+       }       \r
+\r
+       return fd;\r
+}\r
+\r
+int _create_client_sock()\r
+{\r
+       int fd = -1;\r
+       struct sockaddr_un saddr = { 0, };\r
+       int retry = 1;\r
+       int ret = -1;\r
+\r
+       fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);    \r
+       /*  support above version 2.6.27*/\r
+       if (fd < 0) {\r
+               if (errno == EINVAL) {\r
+                       fd = socket(AF_UNIX, SOCK_STREAM, 0);\r
+                       if (fd < 0) {\r
+                               _E("second chance - socket create error");\r
+                               return -1;\r
+                       }\r
+               } else {\r
+                       _E("socket error");\r
+                       return -1;\r
+               }\r
+       }\r
+\r
+       saddr.sun_family = AF_UNIX;\r
+       snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s", AC_SOCK_NAME);\r
+ retry_con:\r
+       ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),\r
+                       100 * 1000);\r
+       if (ret < -1) {\r
+               _E("maybe peer not launched or peer daed\n");\r
+               if (retry > 0) {\r
+                       usleep(100 * 1000);\r
+                       retry--;\r
+                       goto retry_con;\r
+               }\r
+       }\r
+       if (ret < 0) {\r
+               close(fd);\r
+               return -1;\r
+       }\r
+\r
+       __set_sock_option(fd, 1);\r
+\r
+       return fd;\r
+}\r
+\r
+static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t salen,\r
+                  int nsec)\r
+{\r
+       int flags;\r
+       int ret;\r
+       int error;\r
+       socklen_t len;\r
+       fd_set readfds;\r
+       fd_set writefds;\r
+       struct timeval timeout;\r
+\r
+       flags = fcntl(fd, F_GETFL, 0);\r
+       fcntl(fd, F_SETFL, flags | O_NONBLOCK);\r
+\r
+       error = 0;\r
+       if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {\r
+               if (errno != EAGAIN && errno != EINPROGRESS) {\r
+                       fcntl(fd, F_SETFL, flags);      \r
+                       return (-2);\r
+               }\r
+       }\r
+\r
+       /* Do whatever we want while the connect is taking place. */\r
+       if (ret == 0)\r
+               goto done;      /* connect completed immediately */\r
+\r
+       FD_ZERO(&readfds);\r
+       FD_SET(fd, &readfds);\r
+       writefds = readfds;\r
+       timeout.tv_sec = 0;\r
+       timeout.tv_usec = nsec;\r
+\r
+       if ((ret = select(fd + 1, &readfds, &writefds, NULL, \r
+                       nsec ? &timeout : NULL)) == 0) {\r
+               close(fd);      /* timeout */\r
+               errno = ETIMEDOUT;\r
+               return (-1);\r
+       }\r
+\r
+       if (FD_ISSET(fd, &readfds) || FD_ISSET(fd, &writefds)) {\r
+               len = sizeof(error);\r
+               if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)\r
+                       return (-1);    /* Solaris pending error */\r
+       } else\r
+               return (-1);    /* select error: sockfd not set*/\r
+\r
+ done:\r
+       fcntl(fd, F_SETFL, flags);      \r
+       if (error) {\r
+               close(fd);      \r
+               errno = error;\r
+               return (-1);\r
+       }\r
+       return (0);\r
+}\r
+\r
+/**\r
+ * @brief      Send data (in raw) to the process with 'pid' via socket\r
+ */\r
+int _app_send_raw(int cmd, unsigned char *data, int datalen)\r
+{\r
+       int fd;\r
+       int len;\r
+       int res = 0;\r
+       ac_pkt_t *pkt = NULL;\r
+\r
+       if (data == NULL || datalen > AC_SOCK_MAXBUFF - 8) {\r
+               _E("keybundle error\n");\r
+               return -EINVAL;\r
+       }\r
+\r
+       fd = _create_client_sock();\r
+       if (fd < 0)\r
+               return -ECOMM;\r
+\r
+       pkt = (ac_pkt_t *) malloc(sizeof(char) * AC_SOCK_MAXBUFF);\r
+       if (NULL == pkt) {\r
+               _E("Malloc Failed!");\r
+               return -ENOMEM;\r
+       }\r
+       memset(pkt, 0, AC_SOCK_MAXBUFF);\r
+\r
+       pkt->cmd = cmd;\r
+       pkt->len = datalen;\r
+       memcpy(pkt->data, data, datalen);\r
+\r
+       if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {\r
+               _E("sendto() failed - %d %d", len, datalen + 8);\r
+               if (errno == EPIPE) {\r
+                       _E("fd:%d\n", fd);\r
+               }\r
+               close(fd);\r
+               if (pkt) {\r
+                       free(pkt);\r
+                       pkt = NULL;\r
+               }\r
+               return -ECOMM;\r
+       }\r
+       if (pkt) {\r
+               free(pkt);\r
+               pkt = NULL;\r
+       }\r
+\r
+       len = recv(fd, &res, sizeof(int), 0);\r
+       if (len == -1) {\r
+               if (errno == EAGAIN) {\r
+                       _E("recv timeout \n");\r
+                       res = -EAGAIN;\r
+               } else {\r
+                       _E("recv error\n");\r
+                       res = -ECOMM;\r
+               }\r
+       } else\r
+               _D("recv result  = %d (%d)", res, len);\r
+       close(fd);\r
+\r
+       return res;\r
+}\r
+\r
+ac_pkt_t *_app_recv_raw(int fd, int *clifd, struct ucred *cr)\r
+{\r
+       int len;\r
+       struct sockaddr_un aul_addr = { 0, };\r
+       int sun_size;\r
+       ac_pkt_t *pkt = NULL;\r
+       int cl = sizeof(struct ucred);\r
+\r
+       sun_size = sizeof(struct sockaddr_un);\r
+\r
+       if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,\r
+                            (socklen_t *) &sun_size)) == -1) {\r
+               if (errno != EINTR)\r
+                       _E("accept error");\r
+               return NULL;\r
+       }\r
+\r
+       if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,\r
+                      (socklen_t *) &cl) < 0) {\r
+               _E("peer information error");\r
+               close(*clifd);\r
+               return NULL;\r
+       }\r
+\r
+       pkt = (ac_pkt_t *) malloc(sizeof(char) * AC_SOCK_MAXBUFF);\r
+       if(pkt == NULL) {\r
+               close(*clifd);\r
+               return NULL;\r
+       }\r
+       memset(pkt, 0, AC_SOCK_MAXBUFF);\r
+\r
+       __set_sock_option(*clifd, 1);\r
+\r
+ retry_recv:\r
+       /* receive single packet from socket */\r
+       len = recv(*clifd, pkt, AC_SOCK_MAXBUFF, 0);\r
+       if (len < 0)\r
+               if (errno == EINTR)\r
+                       goto retry_recv;\r
+\r
+       if ((len < 8) || (len != (pkt->len + 8))) {\r
+               _E("recv error %d %d", len, pkt->len);\r
+               free(pkt);\r
+               close(*clifd);\r
+               return NULL;\r
+       }\r
+\r
+       return pkt;\r
+}\r
+\r
+int _send_result_to_server(int fd, int res)\r
+{\r
+       if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {\r
+               if (errno == EPIPE)\r
+                       _E("send failed due to EPIPE.\n");\r
+               _E("send fail to client");\r
+       }\r
+       close(fd);\r
+       return 0;\r
+}\r