temporary grant requested permissions
authorJosé Bollo <jose.bollo@iot.bzh>
Tue, 20 Dec 2016 12:59:43 +0000 (13:59 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 20 Dec 2016 14:01:58 +0000 (15:01 +0100)
Change-Id: If9a7d2a183aa8b0c0ed531b4d915443e199b488b
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/wgtpkg-install.c
src/wgtpkg-permissions.c

index 71a0ff6..9881e9c 100644 (file)
@@ -41,7 +41,7 @@
 
 static const char permission_required[] = "required";
 static const char permission_optional[] = "optional";
-static const char feature_required_permissions[] = FWK_PREFIX "required-permissions";
+static const char feature_required_permissions[] = FWK_PREFIX "required-permission";
 static const char* exec_type_strings[] = {
        "application/x-executable",
        "application/vnd.agl.native"
@@ -252,6 +252,7 @@ static int install_security(const struct wgt_desc *desc)
        perm = first_usable_permission();
        while(perm) {
                rc = secmgr_permit(perm);
+               INFO("permitting %s %s", perm, rc ? "FAILED!" : "success");
                if (rc)
                        goto error2;
                perm = next_usable_permission();
index 362b1c1..8379446 100644 (file)
@@ -129,13 +129,25 @@ int permission_exists(const char *name)
 /* request the permission, returns 1 if granted or 0 otherwise */
 int request_permission(const char *name)
 {
+#define HACK_ALLOWING_REQUESTED_PERMISSIONS 1
+
        struct permission *p = get_permission(name);
+
+#if defined(HACK_ALLOWING_REQUESTED_PERMISSIONS) && HACK_ALLOWING_REQUESTED_PERMISSIONS
+       if (!p)
+               p = add_permission(name);
+#endif
        if (p) {
+#if defined(HACK_ALLOWING_REQUESTED_PERMISSIONS) && HACK_ALLOWING_REQUESTED_PERMISSIONS
+               p->granted = 1;
+#endif
                p->requested = 1;
                if (p->granted)
                        return 1;
        }
        return 0;
+
+#undef HACK_ALLOWING_REQUESTED_PERMISSIONS
 }
 
 /* iteration over granted and requested permissions */