X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fpolicy-default.c;h=a09bb1a391ad293bcd9821fd28f9ecda92376c48;hb=39ea644837dd29cd47a579a9703b43458187f82b;hp=23842ab34eb319c2eb1bfd27476fe8a7e88ea7dc;hpb=bbf173123cdd4c64330fbf77631a9ae120e7d09f;p=src%2Fagl-compositor.git diff --git a/src/policy-default.c b/src/policy-default.c index 23842ab..a09bb1a 100644 --- a/src/policy-default.c +++ b/src/policy-default.c @@ -26,6 +26,12 @@ #include "ivi-compositor.h" #include "policy.h" +#ifdef HAVE_SMACK +#include +#endif + +#include + /* * default policy implementation allows every action to be possible * @@ -78,11 +84,52 @@ ivi_policy_default_surface_advertise_state_change(struct ivi_surface *surf, void 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) @@ -131,5 +178,6 @@ ivi_policy_init(struct ivi_compositor *ivi) if (!ivi->policy) return -1; + weston_log("Installing 'allow-all' policy engine\n"); return 0; }