Add Multi User Features 01/22001/2 submit/tizen_common/20140528.173953 submit/tizen_common/20140528.183233 submit/tizen_common/20140529.194900 submit/tizen_common/20140530.021300 submit/tizen_common/20140602.071652 submit/tizen_ivi/20140618.000000 submit/tizen_ivi/20140618.000001 submit/tizen_ivi/20140619.000000 submit/tizen_ivi/20140622.000000 submit/tizen_ivi/20140623.000000 submit/tizen_ivi/20140623.000001
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Fri, 11 Apr 2014 12:34:15 +0000 (14:34 +0200)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Wed, 28 May 2014 15:05:55 +0000 (17:05 +0200)
Change-Id: Id34dcc5633b6378bbd526ad4647825cb524f3d20
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
tool/CMakeLists.txt
tool/pkg_cmd.c
tool/pkg_fota.c
tool/pkg_initdb.c

index 724b72d5daaafc413b87468d94716c2b8ad05cad..1ac49d6cbb76a684174b699b746aaad4f758f860 100755 (executable)
@@ -36,13 +36,10 @@ add_executable(pkg_getsize
                 pkg_getsize.c)
 target_link_libraries(pkg_getsize pkgmgr-client pkgmgr_installer ${pkgs_test_LDFLAGS})
 INSTALL(TARGETS pkg_getsize DESTINATION bin)
-
-add_executable(pkg_initdb
-                pkg_initdb.c)
+add_executable(pkg_initdb pkg_initdb.c)
 target_link_libraries(pkg_initdb ${pkgs_test_LDFLAGS})
 INSTALL(TARGETS pkg_initdb DESTINATION bin)
 
-
 add_executable(pkgmgr-install pkgmgr-install.c)
 target_link_libraries(pkgmgr-install pkgmgr-client pkgmgr-info ${toolpkgs_LDFLAGS})
 install(TARGETS pkgmgr-install DESTINATION bin)
index 3a10052c012cbbf2c78c13669317aeff5e463659..56d0eca2d9d6e7e9e598e82b052c1a45275b2f3c 100755 (executable)
@@ -972,7 +972,6 @@ int main(int argc, char *argv[])
 
        if (!__is_authorized()) {
                printf("You are not an authorized user!\n");
-               return PKGCMD_ERR_FATAL_ERROR;
        }
 
        if (argc == 1)
index 86c270b8159377fb06cb099667e04f734d7179b9..daf0817175c087e4f3049649acf5e544d7006b78 100644 (file)
 #define OPT_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES)
 #define USR_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RO_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")
 
 #define PKG_PARSER_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
 #define PKG_PARSER_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal")
 #define PKG_CERT_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
 #define PKG_CERT_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db-journal")
-#define PKG_INFO_DB_LABEL "pkgmgr::db"
+#define PKG_INFO_DB_LABEL "System"
 
 #ifdef _E
 #undef _E
@@ -220,28 +221,35 @@ static int pkg_fota_change_perm(const char *db_file)
 static int pkg_fota_give_smack()
 {
        int ret = 0;
+       char *label;
+       
+       label = getUserDBLabel();
 
-       const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
+       const char *argv_parser[] = { "/usr/bin/chsmack", "-a", label, getUserPkgParserDBPath(), NULL };
        ret = pkg_fota_xsystem(argv_parser);
        if (ret == -1) {
+               free(label);
                _E("exec : argv_parser fail");
                return -1;
        }
-       const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };
+       const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", label, getUserPkgParserJournalDBPath(), NULL };
        ret = pkg_fota_xsystem(argv_parserjn);
        if (ret == -1) {
+               free(label);
                _E("exec : argv_parserjn fail");
                return -1;
        }
-       const char *argv_cert[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE, NULL };
+       const char *argv_cert[] = { "/usr/bin/chsmack", "-a", label, getUserPkgCertDBPath(), NULL };
        ret = pkg_fota_xsystem(argv_cert);
        if (ret == -1) {
+               free(label);
                _E("exec : argv_cert fail");
                return -1;
        }
-       const char *argv_certjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE_JOURNAL, NULL };
+       const char *argv_certjn[] = { "/usr/bin/chsmack", "-a", label, getUserPkgCertJournalDBPath(), NULL };
        ret = pkg_fota_xsystem(argv_certjn);
        if (ret == -1) {
+               free(label);
                _E("exec : argv_certjn fail");
                return -1;
        }
@@ -260,14 +268,17 @@ static int __is_authorized()
                return 0;
 }
 
-
 int main(int argc, char *argv[])
 {
        int ret;
 
        if (!__is_authorized()) {
                _E("You are not an authorized user!\n");
-               return -1;
+       } else {
+               const char *argv_rm[] = { "/bin/rm", getUserPkgParserDBPath(), NULL };
+               pkg_fota_xsystem(argv_rm);
+               const char *argv_rmjn[] = { "/bin/rm", getUserPkgParserJournalDBPath(), NULL };
+               pkg_fota_xsystem(argv_rmjn);
        }
 
        /* This is for AIL initializing */
@@ -290,18 +301,18 @@ int main(int argc, char *argv[])
                _E("cannot load usr manifest directory.");
        }
 
-       ret = pkg_fota_change_perm(PACKAGE_INFO_DB_FILE);
+       ret = pkg_fota_change_perm(getUserPkgParserDBPath());
        if (ret == -1) {
                _E("cannot chown.");
                return -1;
        }
 
-       ret = pkg_fota_give_smack();
-       if (ret == -1) {
-               _E("cannot pkg_fota_give_smack.");
-               return -1;
+               ret = pkg_fota_give_smack();
+               if (ret == -1) {
+                       _E("cannot pkg_fota_give_smack.");
+                       return -1;
+               }
        }
-
        return 0;
 }
 
index aec8faa029611e0341d064425dbe3cccb7eec085..8f77297505d2744169f5b4d3e3e11868fdae0047 100755 (executable)
 #define OPT_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RW_PACKAGES)
 #define USR_MANIFEST_DIRECTORY tzplatform_getenv(TZ_SYS_RO_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")
 
 #define PKG_PARSER_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
 #define PKG_PARSER_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal")
 #define PKG_CERT_DB_FILE tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db")
 #define PKG_CERT_DB_FILE_JOURNAL tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db-journal")
-#define PKG_INFO_DB_LABEL "User"
+#define PKG_INFO_DB_LABEL "System"
 
 #ifdef _E
 #undef _E
@@ -238,6 +239,11 @@ int main(int argc, char *argv[])
        if (!__is_authorized()) {
                _E("You are not an authorized user!\n");
                return -1;
+       } else {
+               const char *argv_rm[] = { "/bin/rm", PACKAGE_INFO_DB_FILE, NULL };
+               initdb_xsystem(argv_rm);
+               const char *argv_rmjn[] = { "/bin/rm", PACKAGE_INFO_DB_FILE_JOURNAL, NULL };
+               initdb_xsystem(argv_rmjn);
        }
 
        /* This is for AIL initializing */
@@ -265,7 +271,6 @@ int main(int argc, char *argv[])
                _E("cannot chown.");
                return -1;
        }
-
        const char *argv_parser[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE, NULL };
        initdb_xsystem(argv_parser);
        const char *argv_parserjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_PARSER_DB_FILE_JOURNAL, NULL };