server: require XDG_RUNTIME_DIR

An arbitrary fallback to the current directory is only confusing.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
Pekka Paalanen 2012-06-06 14:30:19 +03:00 committed by Kristian Høgsberg
parent 0c7ca38c7f
commit c29020332a

View file

@ -1091,6 +1091,16 @@ wl_display_add_socket(struct wl_display *display, const char *name)
socklen_t size, name_size; socklen_t size, name_size;
const char *runtime_dir; 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); s = malloc(sizeof *s);
if (s == NULL) if (s == NULL)
return -1; return -1;
@ -1101,13 +1111,6 @@ wl_display_add_socket(struct wl_display *display, const char *name)
return -1; 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) if (name == NULL)
name = getenv("WAYLAND_DISPLAY"); name = getenv("WAYLAND_DISPLAY");
if (name == NULL) if (name == NULL)