BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgmgr-info-parser-devel
BuildRequires: pkgmgr-info-parser
+BuildRequires: libsmack
Requires: pwdutils
+Requires: libcap-tools
%description
Packager Manager client library package for packaging
update-mime-database /usr/share/mime
# Create tizenglobalapp user needed for global installation
-%{_sbindir}/useradd -d %TZ_SYS_RW_APP -m %TZ_SYS_GLOBALAPP_USER -r -c "system user for common applications" -g users
+%{_sbindir}/useradd -d %TZ_SYS_RW_APP -m %TZ_SYS_GLOBALAPP_USER -r -c "system user for common applications" -g root
+
#mkdir -p %TZ_SYS_RW_APP/.config/xwalk-service/applications
#cd %TZ_SYS_RW_APP/
#ln -s .config/xwalk-service/applications/
%dir %{_sysconfdir}/opt/upgrade
%{_sysconfdir}/opt/upgrade/pkgmgr.patch.sh
%{_bindir}/pkgcmd
-%{_bindir}/pkg_initdb
+%attr(06755,root,root) %{_bindir}/pkg_initdb
%{_bindir}/pkg_getsize
%{_bindir}/pkginfo
%{_bindir}/pkgmgr-install
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)
INCLUDE(FindPkgConfig)
+
+pkg_check_modules(pkgs_initdb REQUIRED libsmack ecore dbus-1 ail libxml-2.0 bundle pkgmgr-parser vconf security-server pkgmgr-info libtzplatform-config)
+FOREACH(flag ${pkgs_initdb_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+
pkg_check_modules(pkgs_test REQUIRED ecore dbus-1 ail libxml-2.0 bundle pkgmgr-parser vconf security-server pkgmgr-info libtzplatform-config)
FOREACH(flag ${pkgs_test_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
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)
-target_link_libraries(pkg_initdb ${pkgs_test_LDFLAGS})
+target_link_libraries(pkg_initdb ${pkgs_initdb_LDFLAGS})
INSTALL(TARGETS pkg_initdb DESTINATION bin)
add_executable(pkgmgr-install pkgmgr-install.c)
#include <pkgmgr_parser.h>
#include <pkgmgr-info.h>
+#include <sys/smack.h>
/* For multi-user support */
#include <tzplatform_config.h>
#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 "_"
+#define PKG_INFO_DB_LABEL "*"
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+
#ifdef _E
#undef _E
#endif
#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define SET_DEFAULT_LABEL(x) \
+ if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \
+ else _D("chsmack -a \"*\" %s", x)
+
static int initdb_count_package(void)
{
int total = 0;
snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
for (i = 0; files[i]; i++) {
- ret = chown(files[i], OWNER_ROOT, GROUP_MENU);
+ ret = chown(files[i], GLOBAL_USER, OWNER_ROOT);
if (ret == -1) {
strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, GROUP_MENU, buf);
+ _E("FAIL : chown %s %d.%d, because %s", db_file, GLOBAL_USER, OWNER_ROOT, buf);
return -1;
}
/* pkg_init db should be called by as root privilege. */
uid_t uid = getuid();
- if ((uid_t) 0 == uid)
+ uid_t euid = geteuid();
+ //euid need to be root to allow smack label changes during initialization
+ if ((uid_t) OWNER_ROOT == uid)
return 1;
else
return 0;
_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);
+ if(remove(PACKAGE_INFO_DB_FILE))
+ _E(" %s is not removed",PACKAGE_INFO_DB_FILE);
+ if(remove(PACKAGE_INFO_DB_FILE_JOURNAL))
+ _E(" %s is not removed",PACKAGE_INFO_DB_FILE_JOURNAL);
}
+
+ setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT);
/* This is for AIL initializing */
ret = setenv("INITDB", "1", 1);
_D("INITDB : %d", ret);
_D("Some Packages in the Package Info DB.");
return 0;
}
-
ret = initdb_load_directory(SYS_MANIFEST_DIRECTORY);
if (ret == -1) {
_E("cannot load opt manifest directory.");
_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 };
- initdb_xsystem(argv_parserjn);
- const char *argv_cert[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE, NULL };
- initdb_xsystem(argv_cert);
- const char *argv_certjn[] = { "/usr/bin/chsmack", "-a", PKG_INFO_DB_LABEL, PKG_CERT_DB_FILE_JOURNAL, NULL };
- initdb_xsystem(argv_certjn);
+
+ setuid(OWNER_ROOT);
+
+ SET_DEFAULT_LABEL(PKG_PARSER_DB_FILE);
+ SET_DEFAULT_LABEL(PKG_PARSER_DB_FILE_JOURNAL);
+ SET_DEFAULT_LABEL(PKG_CERT_DB_FILE);
+ SET_DEFAULT_LABEL(PKG_CERT_DB_FILE_JOURNAL);
return 0;
}