<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 16, 2014 at 9:23 AM, Imran Zaman <span dir="ltr"><<a href="mailto:imran.zaman@gmail.com" target="_blank">imran.zaman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is used for nested compositor architectures.<br></blockquote><div><br></div><div>Could you please provide a little more explanation than that.  What kind of nesting are you doing?<br><br></div><div>Also, why are you doing this through environment variables and not something explicit?  For instance, the compositor can easily grab the socket and chmod it.  It has the privileges and knows what socket it is.<br><br></div><div>--Jason Ekstrand<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Signed-off-by: Imran Zaman <<a href="mailto:imran.zaman@gmail.com">imran.zaman@gmail.com</a>><br>
---<br>
 src/wayland-server.c | 27 +++++++++++++++++++++++++++<br>
 1 file changed, 27 insertions(+)<br>
<br>
diff --git a/src/wayland-server.c b/src/wayland-server.c<br>
index 09e8903..721fabe 100644<br>
--- a/src/wayland-server.c<br>
+++ b/src/wayland-server.c<br>
@@ -39,6 +39,8 @@<br>
 #include <fcntl.h><br>
 #include <sys/file.h><br>
 #include <sys/stat.h><br>
+#include <sys/types.h><br>
+#include <grp.h><br>
 #include <ffi.h><br>
<br>
 #include "wayland-private.h"<br>
@@ -1117,6 +1119,10 @@ static int<br>
 _wl_display_add_socket(struct wl_display *display, struct wl_socket *s)<br>
 {<br>
        socklen_t size;<br>
+       const char *socket_mode_str;<br>
+       const char *socket_group_str;<br>
+       const struct group *socket_group;<br>
+       unsigned socket_mode;<br>
<br>
        s->fd = wl_os_socket_cloexec(PF_LOCAL, SOCK_STREAM, 0);<br>
        if (s->fd < 0) {<br>
@@ -1134,6 +1140,27 @@ _wl_display_add_socket(struct wl_display *display, struct wl_socket *s)<br>
                return -1;<br>
        }<br>
<br>
+       socket_group_str = getenv("WAYLAND_SERVER_GROUP");<br>
+       if (socket_group_str != NULL) {<br>
+               socket_group = getgrnam(socket_group_str);<br>
+               if (socket_group != NULL) {<br>
+                       if (chown(s->addr.sun_path,<br>
+                               -1, socket_group->gr_gid) != 0)<br>
+                               wl_log("chown(\"%s\") failed: %s",<br>
+                                       s->addr.sun_path,<br>
+                                       strerror(errno));<br>
+               }<br>
+       }<br>
+       socket_mode_str = getenv("WAYLAND_SERVER_MODE");<br>
+       if (socket_mode_str != NULL) {<br>
+               if (sscanf(socket_mode_str, "%o", &socket_mode) > 0)<br>
+                       if (chmod(s->addr.sun_path, socket_mode) != 0) {<br>
+                               wl_log("chmod(\"%s\") failed: %s",<br>
+                                       s->addr.sun_path,<br>
+                                       strerror(errno));<br>
+                       }<br>
+       }<br>
+<br>
        s->source = wl_event_loop_add_fd(display->loop, s->fd,<br>
                                         WL_EVENT_READABLE,<br>
                                         socket_data, display);<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</font></span></blockquote></div><br></div></div>