#include "ivi-compositor.h"
#include "policy.h"
+#ifdef HAVE_SMACK
+#include <sys/smack.h>
+#endif
+
+#include <string.h>
+
/*
* default policy implementation allows every action to be possible
*
return true;
}
+static bool
+ivi_policy_default_surface_deactivate(struct ivi_surface *surf, void *user_data)
+{
+ /* verify that the surface should be de-activated to */
+ return true;
+}
+
static bool
ivi_policy_default_surface_activate_default(struct ivi_surface *surf, void *user_data)
{
return true;
}
+static bool
+ivi_policy_default_surface_advertise_state_change(struct ivi_surface *surf, void *user_data)
+{
+ /* verify that the surface should sent as notification */
+ return true;
+}
+
+#ifdef HAVE_SMACK
+static bool
+ivi_policy_default_shell_bind_interface(void *client, void *interface)
+{
+ struct wl_interface *shell_interface = interface;
+ struct wl_client *conn_client = client;
+
+ pid_t pid, uid, gid;
+ int client_fd;
+ char *label;
+ bool ret = false;
+
+ wl_client_get_credentials(conn_client, &pid, &uid, &gid);
+
+ client_fd = wl_client_get_fd(conn_client);
+ if (smack_new_label_from_socket(client_fd, &label) < 0) {
+ return ret;
+ }
+
+ if (strcmp(shell_interface->name, "agl_shell") == 0)
+ if (strcmp(label, "User::App::homescreen") == 0)
+ ret = true;
+
+ if (strcmp(shell_interface->name, "agl_shell_desktop") == 0)
+ if (strcmp(label, "User::App::launcher") == 0 ||
+ strcmp(label, "User::App::alexa-viewer") == 0 ||
+ strcmp(label, "User::App::tbtnavi") == 0 ||
+ strcmp(label, "User::App::hvac") == 0)
+ ret = true;
+
+ if (ret)
+ weston_log("Client with pid %d, uid %d, gid %d, allowed "
+ "to bind to %s for label %s\n", pid, uid, gid,
+ shell_interface->name, label);
+
+ /* client responsible for free'ing */
+ free(label);
+ return ret;
+}
+#else
+static bool
+ivi_policy_default_shell_bind_interface(void *client, void *interface)
+{
+ return true;
+}
+#endif
+
static bool
ivi_policy_default_allow_to_add(void *user_data)
{
ivi_layout_activate(a_policy->output, a_policy->app_id);
break;
case AGL_SHELL_POLICY_EVENT_HIDE:
- /* FIXME: remove the active one, like basically unmap it? */
+ ivi_layout_deactivate(a_policy->policy->ivi, a_policy->app_id);
default:
break;
}
.surface_create = ivi_policy_default_surface_create,
.surface_commited = ivi_policy_default_surface_commmited,
.surface_activate = ivi_policy_default_surface_activate,
+ .surface_deactivate = ivi_policy_default_surface_deactivate,
.surface_activate_by_default = ivi_policy_default_surface_activate_default,
+ .surface_advertise_state_change = ivi_policy_default_surface_advertise_state_change,
+ .shell_bind_interface = ivi_policy_default_shell_bind_interface,
.policy_rule_allow_to_add = ivi_policy_default_allow_to_add,
.policy_rule_try_event = ivi_policy_default_try_event,
};
if (!ivi->policy)
return -1;
+ weston_log("Installing 'allow-all' policy engine\n");
return 0;
}