Enable changing owner, group and permissions for /run/waylan-0 68/57368/11
authorŁukasz Stelmach <l.stelmach@samsung.com>
Thu, 14 Jan 2016 14:29:05 +0000 (15:29 +0100)
committerGwanglim Lee <gl77.lee@samsung.com>
Wed, 6 Apr 2016 03:56:46 +0000 (20:56 -0700)
Introduce three new configuration options to change the owner, group
and permissions for the Wayland socket.

Change-Id: Idd3cfdad8bad7b33e9359e05cb3566595fcee11e
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
config/default/e.src
config/mobile/e.src
config/standard/e.src
config/tiling/e.src
src/bin/e_comp_wl.c
src/bin/e_config.c
src/bin/e_config.h

index 73cdd1e..9974b99 100644 (file)
@@ -227,4 +227,7 @@ group "E_Config" struct {
   value "powersave.min" int: 0;
   value "powersave.max" int: 5;
   value "wm_win_rotation" uchar: 0;
+  value "wayland_socket_owner" string: "root";
+  value "wayland_socket_group" string: "root";
+  value "wayland_socket_permissions" int: 511; // decimal for 0777
 }
index 380e9be..e0573a4 100644 (file)
@@ -870,4 +870,7 @@ group "E_Config" struct {
     value "exe_always_single_instance" uchar: 1;
     value "use_desktop_window_profile" int: 0;
     value "wm_win_rotation" uchar: 0;
+    value "wayland_socket_owner" string: "root";
+    value "wayland_socket_group" string: "root";
+    value "wayland_socket_permissions" int: 511; // decimal for 0777
 }
index 79b89ac..6607f1b 100644 (file)
@@ -1111,4 +1111,7 @@ group "E_Config" struct {
     value "exe_always_single_instance" uchar: 0;
     value "use_desktop_window_profile" int: 0;
     value "wm_win_rotation" uchar: 0;
+    value "wayland_socket_owner" string: "root";
+    value "wayland_socket_group" string: "root";
+    value "wayland_socket_permissions" int: 511; // decimal for 0777
 }
index fcc6b9f..89f7ee0 100644 (file)
@@ -1133,4 +1133,7 @@ group "E_Config" struct {
     value "exe_always_single_instance" uchar: 0;
     value "use_desktop_window_profile" int: 0;
     value "wm_win_rotation" uchar: 0;
+    value "wayland_socket_owner" string: "root";
+    value "wayland_socket_group" string: "root";
+    value "wayland_socket_permissions" int: 511; // decimal for 0777
 }
index 7f1dfdc..a62279e 100644 (file)
@@ -4015,6 +4015,7 @@ _e_comp_wl_compositor_create(void)
    const char *name;
    int fd = 0;
    E_Module *_mod;
+   const char *runtime_dir;
 
    /* create new compositor data */
    if (!(cdata = E_NEW(E_Comp_Wl_Data, 1)))
@@ -4043,6 +4044,32 @@ _e_comp_wl_compositor_create(void)
         goto sock_err;
      }
 
+   runtime_dir = getenv("XDG_RUNTIME_DIR");
+   if (runtime_dir &&
+       e_config->wayland_socket_owner &&
+       e_config->wayland_socket_group) {
+     struct group *g;
+     struct passwd *u;
+     uid_t uid;
+     gid_t gid;
+
+     char socket_path[108]; // sun_path is 108 bytes see <sys/un.h>
+     snprintf(socket_path, sizeof(socket_path), "%s/%s", runtime_dir, name);
+
+     u = getpwnam(e_config->wayland_socket_owner);
+     uid = (u !=NULL) ? u->pw_uid : 0;
+
+     g = getgrnam(e_config->wayland_socket_group);
+     gid = (g != NULL) ? g->gr_gid : 0;
+
+     DBG("socket path: %s owner: %s (%d) group: %s (%d) permissions: %o",
+        e_config->wayland_socket_owner, uid,
+        e_config->wayland_socket_group, gid,
+        e_config->wayland_socket_permissions);
+
+     chmod(socket_path, e_config->wayland_socket_permissions);
+     chown(socket_path, uid, gid);
+   }
    /* set wayland display environment variable */
    e_env_set("WAYLAND_DISPLAY", name);
 
index 3d0ee25..9ae1e6e 100644 (file)
@@ -196,6 +196,9 @@ _e_config_edd_init(Eina_Bool old)
    E_CONFIG_VAL(D, T, cursor_timer_interval, INT);
    E_CONFIG_LIST(D, T, client_types, _e_config_client_type_edd);
    E_CONFIG_VAL(D, T, comp_shadow_file, STR);
+   E_CONFIG_VAL(D, T, wayland_socket_owner, STR);
+   E_CONFIG_VAL(D, T, wayland_socket_group, STR);
+   E_CONFIG_VAL(D, T, wayland_socket_permissions, INT);
 }
 
 /* externally accessible functions */
index f8c0b89..d8d0779 100644 (file)
@@ -126,6 +126,9 @@ struct _E_Config
    int cursor_timer_interval;
    Eina_List *client_types;
    const char *comp_shadow_file;
+   const char*  wayland_socket_owner;
+   const char*  wayland_socket_group;
+   unsigned int wayland_socket_permissions;
 };
 
 struct _E_Config_Desklock_Background