printf("15 --> filter by app taskmanage [0|1]\n");
printf("16 --> filter by app hwacceleration\n");
printf("17 --> filter by app screenreader\n");
+ printf("18 --> filter by app ui_gadget [0|1]\n");
choice = __get_integer_input_data();
switch (choice) {
case 0:
free(value);
value = NULL;
break;
+ case 18:
+ val = __get_integer_input_data();
+ ret = pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_UI_GADGET, val);
+ if (ret < 0) {
+ printf("pkgmgrinfo_appinfo_filter_add_bool() failed\n");
+ ret = -1;
+ goto err;
+ }
+ break;
default:
printf("Invalid filter property\n");
pkgmgrinfo_appinfo_filter_destroy(handle);
#endif
#define _D(fmt, arg...) fprintf(stderr, "[PKG_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define PKGINFO_CMD "/usr/bin/pkginfo --imd"
+#define PKGINSTALLUG_CMD "/usr/bin/pkg_install_ug"
+#define PKGPRIVILEGE_CMD "/usr/bin/pkg_privilege -i"
+
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, const char *cmd)
+static int _initdb_load_directory(uid_t uid, const char *directory)
{
DIR *dir;
struct dirent entry, *result;
char buf[BUFSZE];
char buf2[BUFSZE];
- // desktop file
dir = opendir(directory);
if (!dir) {
_E("Failed to access the [%s] because %s", directory,
continue;
}
- snprintf(buf2, sizeof(buf2), "%s %s", cmd, buf);
setresuid(uid, uid, OWNER_ROOT);
+ snprintf(buf2, sizeof(buf2), "%s %s", PKGINFO_CMD, buf);
+ system(buf2);
+ snprintf(buf2, sizeof(buf2), "%s %s", PKGINSTALLUG_CMD, buf);
+ system(buf2);
+ snprintf(buf2, sizeof(buf2), "%s %s", PKGPRIVILEGE_CMD, buf);
system(buf2);
setresuid(OWNER_ROOT, OWNER_ROOT, OWNER_ROOT);
}
return 0;
}
-static int _install_manifest(uid_t uid)
-{
- int ret;
- const char *dir;
-
- if (!_is_global(uid)) {
- tzplatform_set_user(uid);
- }
-
- dir = tzplatform_getenv(
- _is_global(uid) ? TZ_SYS_RW_PACKAGES : TZ_USER_PACKAGES);
- ret = _initdb_load_directory(uid, dir, "/usr/bin/pkginfo --imd");
-
- tzplatform_reset_user();
-
- return ret;
-}
-
-static int _install_privilege(uid_t uid)
-{
- int ret;
- const char *dir;
-
- if (!_is_global(uid))
- tzplatform_set_user(uid);
-
- dir = tzplatform_getenv(
- _is_global(uid) ? TZ_SYS_RW_PACKAGES : TZ_USER_PACKAGES);
- ret = _initdb_load_directory(uid, dir, "/usr/bin/pkg_privilege -i");
-
- tzplatform_reset_user();
-
- return ret;
-}
-
static int _is_authorized()
{
/* pkg_init db should be called by as root privilege. */
int main(int argc, char *argv[])
{
int ret;
+ const char *dir;
uid_t uid = 0;
if (!_is_authorized()) {
return -1;
}
- ret = _install_manifest(uid);
- if (ret < 0) {
- _E("cannot install manifest");
- return -1;
- }
-
- ret = _install_privilege(uid);
- if (ret < 0) {
- _E("cannot install priveilge");
- return -1;
- }
+ if (!_is_global(uid))
+ tzplatform_set_user(uid);
+ dir = tzplatform_getenv(
+ _is_global(uid) ? TZ_SYS_RW_PACKAGES : TZ_USER_PACKAGES);
+ tzplatform_reset_user();
- return 0;
+ return _initdb_load_directory(uid, dir);
}
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <pkgmgr_parser.h>
+#include <tzplatform_config.h>
+
+#define OWNER_ROOT 0
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
+#define UG_CLIENT tzplatform_mkpath(TZ_SYS_BIN, "ug-client")
+
+static int _install_ug(const char *manifest)
+{
+ manifest_x *mfx;
+ uiapplication_x *tmp;
+ const char *exec;
+ int ret;
+
+ mfx = pkgmgr_parser_process_manifest_xml(manifest);
+ if (mfx == NULL) {
+ printf("Parse manifest failed\n");
+ return -1;
+ }
+
+ for (tmp = mfx->uiapplication; tmp; tmp = tmp->next) {
+ if (tmp->exec == NULL || tmp->ui_gadget == NULL ||
+ strcasecmp(tmp->ui_gadget, "true") != 0)
+ continue;
+
+ ret = symlink(UG_CLIENT, tmp->exec);
+ if (ret != 0)
+ printf("failed to install ug %s: %s\n", tmp->exec,
+ strerror(errno));
+ }
+
+ pkgmgr_parser_free_manifest_xml(mfx);
+
+ return 0;
+}
+
+static void _print_usage(const char *cmd)
+{
+ printf("usage: %s <manifest>\n", cmd);
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ if (getuid() != OWNER_ROOT && getuid() != GLOBAL_USER) {
+ printf("Only root or tizenglobalapp user is allowed\n");
+ return -1;
+ }
+
+ if (argc < 2) {
+ _print_usage(argv[0]);
+ return -1;
+ }
+
+ ret = _install_ug(argv[1]);
+
+ return ret;
+}