Revert "Add wrapper to fix TC-320" 65/26865/1
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Fri, 29 Aug 2014 11:26:18 +0000 (13:26 +0200)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Fri, 29 Aug 2014 11:26:18 +0000 (13:26 +0200)
This reverts commit 5c67e3748c2beb9cd685390d1f0d4349f3334f0f.

Conflicts:
tool/pkgcmd.wrapper

Change-Id: If9097f274f78f706beaea5bb5e2da42fe46b4d0d

packaging/pkgmgr.spec
tool/CMakeLists.txt
tool/pkg_cmd_WA.c [deleted file]
tool/pkg_initdb.c
tool/pkgcmd.wrapper [deleted file]

index 7a98927..463276e 100644 (file)
@@ -139,9 +139,7 @@ update-mime-database /usr/share/mime
 %dir %{_sysconfdir}/package-manager/backendlib
 %dir %{_sysconfdir}/opt/upgrade
 %{_sysconfdir}/opt/upgrade/pkgmgr.patch.sh
-%attr(4755, root, root) %{_bindir}/pkgcmd
-%{_bindir}/pkgcmd.real
-%attr(755, root, root) %{_bindir}/pkgcmd.wrapper
+%{_bindir}/pkgcmd
 %{_bindir}/pkg_initdb
 %{_bindir}/pkg_getsize
 %{_bindir}/pkginfo
index 34e1c7d..1ac49d6 100755 (executable)
@@ -22,13 +22,8 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
 SET(CMAKE_C_FLAGS_RELEASE "-O2")
 
-add_executable(pkgcmd.real
-               pkg_cmd.c)
-target_link_libraries(pkgcmd.real pkgmgr-client ${pkgs_test_LDFLAGS})
-INSTALL(TARGETS pkgcmd.real DESTINATION bin)
-
 add_executable(pkgcmd
-               pkg_cmd_WA.c)
+               pkg_cmd.c)
 target_link_libraries(pkgcmd pkgmgr-client ${pkgs_test_LDFLAGS})
 INSTALL(TARGETS pkgcmd DESTINATION bin)
 
@@ -55,5 +50,3 @@ install(FILES ${CMAKE_BINARY_DIR}/org.tizen.pkgmgr-install.xml DESTINATION /usr/
 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.wac.xml DESTINATION /usr/share/mime/packages/)
 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime.tpk.xml DESTINATION /usr/share/mime/packages/)
 
-install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pkgcmd.wrapper DESTINATION /usr/bin/)
-
diff --git a/tool/pkg_cmd_WA.c b/tool/pkg_cmd_WA.c
deleted file mode 100644 (file)
index 29dbf5d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-int main(int argc, char **argv, char **env)
-{
-       setresuid(0,0,0);
-       setresgid(0,0,0);
-       return execve("/usr/bin/pkgcmd.wrapper",argv,env);
-}
index 5920762..8b529e8 100755 (executable)
@@ -39,8 +39,7 @@
 #define OWNER_ROOT 0
 #define GROUP_MENU 6010
 #define BUFSZE 1024
-#define OPT_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES)
-#define USR_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RO_PACKAGES)
+#define SYS_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES)
 #define PACKAGE_INFO_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
 #define PACKAGE_INFO_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal")
 
@@ -255,14 +254,10 @@ int main(int argc, char *argv[])
                return 0;
        }
 
-       ret = initdb_load_directory(OPT_MANIFEST_DIRECTORY);
+       ret = initdb_load_directory(SYS_MANIFEST_DIRECTORY);
        if (ret == -1) {
                _E("cannot load opt manifest directory.");
        }
-       ret = initdb_load_directory(USR_MANIFEST_DIRECTORY);
-       if (ret == -1) {
-               _E("cannot load usr manifest directory.");
-       }
 
        ret = initdb_change_perm(PACKAGE_INFO_DB_FILE);
        if (ret == -1) {
diff --git a/tool/pkgcmd.wrapper b/tool/pkgcmd.wrapper
deleted file mode 100755 (executable)
index b1d312f..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/bash 
-
-# This script is a workaround for bug TC-320 where pkgcmd doesn't work with xwalk
-#
-# - the real command pkgcmd is renamed pkgcmd.real
-# - the "new" pkgcmd command is only a small binary with setuid bit (executes as root)
-# - this script "pkgcmd.wrapper" decides what to do depending on arguments
-#
-#                                                          /-> xwalkctl (if install or uninstall)
-# sbdb -> (developer) pkgcmd (gets root) -> pkgcmd.wrapper
-#                                                          \-> pkgcmd.real (original binary in other cases)
-#
-# Authors:!
-#      Stéphane Desneux <stephane.desneux@open.eurogiciel.org>
-#      Baptiste Durand <baptiste.durand@open.eurogiciel.org>
-
-DEBUG=0
-[[ "$DEBUG" == 1 ]] && exec 2>>/tmp/pkgcmd.log || exec 2>/dev/null
-
-function debug() {
-       [[ "$DEBUG" == 1 ]] && echo "$0: $@" >&2
-}
-
-TEMP=$(getopt -n 'pkgcmd' -o iurmcgCkaADL:lsd:p:t:n:T:T:S:qh --long install,uninstall,reinstall,move,clear,getsize,check,kill,app-path,activate,deactivate,activate\ with\ Label:,list,show,descriptor:,package-path:,package-type:,package-name:,move-type:,getsize-type:,csc:,quiet,help -- "$@")
-[[ $? != 0 ]] && { echo "pkgcmd.wrapper: invalid options. Terminating..." >&2; exit 1; }
-
-# save initial arguments
-ARGS="$@"
-debug "--------------------- new call -----------------------"
-debug "ARGS: $ARGS"
-
-# change args to getopt output
-debug "OPTS: $TEMP"
-eval set -- "$TEMP"
-
-op=
-while true; do
-       case "$1" in
-               -i|--install)           op="install";   shift;;
-               -u|--uninstall)         op="uninstall"; shift;;
-               -a|--app-path)          op="app_path";  shift;;
-               -l|--list)                      op="list";              shift;;
-               -t|--package-type)      pkgtype=$2;             shift 2;;
-               -p|--package-path)      pkgpath=$2;             shift 2;;
-               -n|--package-name)      pkgname=$2;             shift 2;;
-
-               # other options (we don't care of)
-               -r|--reinstall) shift;;
-               -m|--move) shift;;
-               -c|--clear) shift;;
-               -g|--getsize) shift;;
-               -C|--check) shift;;
-               -k|--kill) shift;;
-               -A|--activate) shift;;
-               -D|--deactivate) shift;;
-               -s|--show) shift;;
-               -q|--quiet) shift;;
-               -h|--help) shift;;
-
-               # other options with argument (we don't care of)
-               -L|--activate\ with\ Label) shift 2;;
-               -d|--descriptor) shift 2;;
-               -T|--move-type|--getsize-type) shift 2;;
-               -S|--csc) shift 2;;
-               --) shift; break;;
-       esac
-done
-
-debug "op=$op type=$pkgtype path=$pkgpath name=$pkgname"
-
-# get user to install to from USER env var (or 'guest' as fallback)
-USER=${USER:-root}
-
-if [[ "$USER" == "root" || "$USER" == "developer" ]]; then
-       # root and developer don't install apps for themselves.
-       # so take the first valid user: check app, check guest
-       if getent passwd | grep -q "^app:"; then
-               USER=app
-       elif getent passwd | grep -q "^guest:"; then
-               USER=guest
-       else
-               debug "Using 'app' user by default: 'app' or 'guest' not found"
-               USER=app
-       fi
-fi
-debug "user: $USER"
-
-shopt -s nocasematch
-if [[ "$op" == "list" ]]; then
-       debug "list"
-       su - app -c "bash -l -c 'xwalkctl'" | awk '/^\w+\s+\w+$/{printf("%s %s\n",$1,$2)}' | while read id name; do
-               echo "pkg_type [wgt]    pkgid [$id]     name [$name]    version [0.0]"
-       done
-       exec /usr/bin/pkgcmd.real $ARGS | grep -v "^You are not an authorized user"
-elif [[ "$op" == "app_path" ]]; then
-       path=/tmp/app_rw
-       mkdir -p $path
-       chmod 777 $path
-       chown app:app $path
-       chsmack -a User $path
-       debug "send app path: $path"
-       echo "Tizen Application Installation Path: $path"
-       echo "spend time for pkgcmd is [0]ms"
-elif [[ "$op" == "install" && "$pkgtype" =~ wgt ]]; then
-       # call xwalkctl
-       debug "run: xwalkctl -i $pkgpath"
-       exec su - $USER -c "bash -l -c 'xwalkctl -i $pkgpath'"
-elif [[ "$op" == "uninstall" ]]; then
-       # call xwalkctl
-       debug "run xwalkctl -u $pkgname"
-       exec su - $USER -c "bash -l -c 'xwalkctl -u $pkgname'"
-else
-       # launch the real pkgcmd binary if we're not installing or uninstalling
-       debug "run pkgcmd.real"
-       exec su - $USER -c "bash -l -c '/usr/bin/pkgcmd.real $ARGS'" | grep -v "^You are not an authorized user"
-fi
-