From: Sangyoon Jang Date: Mon, 27 Jun 2016 05:25:51 +0000 (+0900) Subject: Clean up repository X-Git-Tag: submit/tizen/20160627.042541^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F76728%2F1;p=platform%2Fcore%2Fappfw%2Fpkgmgr-tool.git Clean up repository Remove unused files. (pkg_initdb) Remove excutable bit from source file. Change-Id: I6ee19dc01abc79c99606c3be782906add45401b9 Signed-off-by: Sangyoon Jang --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f5612bb..b7a96db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,11 +24,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs_initdb REQUIRED bundle pkgmgr-parser pkgmgr-info libtzplatform-config pkgmgr) -FOREACH(flag ${pkgs_initdb_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - pkg_check_modules(pkgs_test REQUIRED dlog glib-2.0 bundle pkgmgr pkgmgr-parser pkgmgr-info pkgmgr-installer libtzplatform-config aul) FOREACH(flag ${pkgs_test_CFLAGS}) @@ -67,8 +62,6 @@ ADD_EXECUTABLE(rsc-slice src/pkg_rsc_slice.c) TARGET_LINK_LIBRARIES(rsc-slice ${pkgs_test_LDFLAGS}) INSTALL(TARGETS rsc-slice DESTINATION bin) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/10_package-manager-add.post DESTINATION ${SYSCONF_INSTALL_DIR}/gumd/useradd.d/) - INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mime.wac.xml DESTINATION /usr/share/mime/packages/) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mime.tpk.xml DESTINATION /usr/share/mime/packages/) diff --git a/data/10_package-manager-add.post b/data/10_package-manager-add.post deleted file mode 100644 index aa13d61..0000000 --- a/data/10_package-manager-add.post +++ /dev/null @@ -1 +0,0 @@ -pkg_initdb --uid $2 diff --git a/packaging/pkgmgr-tool.spec b/packaging/pkgmgr-tool.spec index 6de46e9..7b9b010 100644 --- a/packaging/pkgmgr-tool.spec +++ b/packaging/pkgmgr-tool.spec @@ -79,7 +79,6 @@ fi %dir %{_sysconfdir}/opt/upgrade %{_sysconfdir}/opt/upgrade/pkgmgr.patch.sh %{_bindir}/pkgcmd -%attr(755,root,root) %{_sysconfdir}/gumd/useradd.d/10_package-manager-add.post %{_bindir}/pkg_getsize %{_bindir}/pkg_clearcache %{_bindir}/pkginfo diff --git a/src/pkg_initdb.c b/src/pkg_initdb.c deleted file mode 100644 index 8baa5f1..0000000 --- a/src/pkg_initdb.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Jayoun Lee , Sewook Park , - * Jaeho Lee , Shobhit Srivastava - * - * 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. - * - */ - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* For multi-user support */ -#include - -#define OWNER_ROOT 0 -#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) -#define BUFSZE 4096 - -#ifdef _E -#undef _E -#endif -#define _E(fmt, arg...) fprintf(stderr, "[PKG_INITDB][E][%s,%d] "fmt"\n", \ - __FUNCTION__, __LINE__, ##arg); - -#ifdef _D -#undef _D -#endif -#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", \ - __FUNCTION__, __LINE__, ##arg); - -#define PKGINSTALLMANIFEST_CMD "/usr/bin/pkg-install-manifest" - -static int _is_global(uid_t uid) -{ - return (uid == OWNER_ROOT || uid == GLOBAL_USER) ? 1 : 0; -} - -static int _initdb_load_directory(uid_t uid, const char *directory) -{ - DIR *dir; - struct dirent file_info; - struct dirent *result; - char buf[BUFSZE]; - pid_t pid; - int status; - - dir = opendir(directory); - if (!dir) { - _E("Failed to access the [%s] because %s", directory, - strerror_r(errno, buf, sizeof(buf))); - return -1; - } - - _D("Loading manifest files from %s", directory); - - while (readdir_r(dir, &file_info, &result) == 0) { - if (result == NULL) - break; - if (file_info.d_type != DT_REG) - continue; - - snprintf(buf, sizeof(buf), "%s/%s", directory, - file_info.d_name); - _D("manifest file %s", buf); - - pid = fork(); - if (pid == 0) { - if (setuid(uid) != 0) { - _E("failed to set uid"); - closedir(dir); - return -1; - } - - execl(PKGINSTALLMANIFEST_CMD, PKGINSTALLMANIFEST_CMD, - "-x", buf, (char *)NULL); - _E("failed to execute: %s", - strerror_r(errno, buf, sizeof(buf))); - exit(EXIT_FAILURE); - } else if (pid < 0) { - _E("failed to fork and execute %s!", - PKGINSTALLMANIFEST_CMD); - closedir(dir); - return -1; - } else { - waitpid(pid, &status, 0); - } - } - - closedir(dir); - - return 0; -} - -static int _is_authorized() -{ - /* pkg_init db should be called by as root privilege. */ - uid_t uid = getuid(); - - if ((uid_t) OWNER_ROOT == uid) - return 1; - else - return 0; -} - -static void _remove_old_dbs(uid) -{ - const char *info_db_path; - const char *info_db_journal_path; - const char *cert_db_path; - const char *cert_db_journal_path; - - if (!_is_global(uid)) - tzplatform_set_user(uid); - - info_db_path = tzplatform_mkpath( - _is_global(uid) ? TZ_SYS_DB : TZ_USER_DB, - ".pkgmgr_parser.db"); - info_db_journal_path = tzplatform_mkpath( - _is_global(uid) ? TZ_SYS_DB : TZ_USER_DB, - ".pkgmgr_parser.db-journal"); - cert_db_path = tzplatform_mkpath( - _is_global(uid) ? TZ_SYS_DB : TZ_USER_DB, - ".pkgmgr_cert.db"); - cert_db_journal_path = tzplatform_mkpath( - _is_global(uid) ? TZ_SYS_DB : TZ_USER_DB, - ".pkgmgr_cert.db-journal"); - - if (remove(info_db_path)) - _E(" %s is not removed", info_db_path); - if (remove(info_db_journal_path)) - _E(" %s is not removed", info_db_journal_path); - if (remove(cert_db_path)) - _E(" %s is not removed", cert_db_path); - if (remove(cert_db_journal_path)) - _E(" %s is not removed", cert_db_journal_path); - - tzplatform_reset_user(); -} - -int main(int argc, char *argv[]) -{ - int ret; - const char *dir; - const char *dir_rw; - uid_t uid = 0; - - if (!_is_authorized()) { - _E("You are not an authorized user!"); - return -1; - } - - if (argc > 1) - uid = (uid_t)atoi(argv[1]); - - _remove_old_dbs(uid); - - ret = pkgmgr_parser_create_and_initialize_db(uid); - if (ret < 0) { - _E("cannot create db"); - return -1; - } - - if (_is_global(uid)) { - /* first, RO location */ - dir = tzplatform_getenv(TZ_SYS_RO_PACKAGES); - ret = _initdb_load_directory(uid, dir); - - /* second, RW location */ - dir_rw = tzplatform_getenv(TZ_SYS_RW_PACKAGES); - if (dir && dir_rw) - if (strcmp(dir, dir_rw)) - ret = _initdb_load_directory(uid, dir_rw); - } else { - /* specified user location */ - tzplatform_set_user(uid); - dir = tzplatform_getenv(TZ_USER_PACKAGES); - ret = _initdb_load_directory(uid, dir); - tzplatform_reset_user(); - } - - return ret; -} diff --git a/src/pkg_rsc_slice.c b/src/pkg_rsc_slice.c old mode 100755 new mode 100644