[PATCH wayland 2/2] server: require XDG_RUNTIME_DIR

Pekka Paalanen ppaalanen at gmail.com
Wed Jun 6 04:30:19 PDT 2012


An arbitrary fallback to the current directory is only confusing.

Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 src/wayland-server.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index ed9f001..fb4e157 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1091,6 +1091,16 @@ wl_display_add_socket(struct wl_display *display, const char *name)
 	socklen_t size, name_size;
 	const char *runtime_dir;
 
+	runtime_dir = getenv("XDG_RUNTIME_DIR");
+	if (!runtime_dir) {
+		wl_log("error: XDG_RUNTIME_DIR not set in the environment\n");
+
+		/* to prevent programs reporting
+		 * "failed to add socket: Success" */
+		errno = ENOENT;
+		return -1;
+	}
+
 	s = malloc(sizeof *s);
 	if (s == NULL)
 		return -1;
@@ -1101,13 +1111,6 @@ wl_display_add_socket(struct wl_display *display, const char *name)
 		return -1;
 	}
 
-	runtime_dir = getenv("XDG_RUNTIME_DIR");
-	if (runtime_dir == NULL) {
-		runtime_dir = ".";
-		wl_log("XDG_RUNTIME_DIR not set, falling back to %s\n",
-			runtime_dir);
-	}
-
 	if (name == NULL)
 		name = getenv("WAYLAND_DISPLAY");
 	if (name == NULL)
-- 
1.7.3.4



More information about the wayland-devel mailing list