[PATCH weston 2/3] compositor: print a clear message when XDG_RUNTIME_DIR is not set

Kristian Høgsberg hoegsberg at gmail.com
Fri Jun 8 09:49:09 PDT 2012


On Fri, Jun 08, 2012 at 01:05:34AM +0000, Eoff, Ullysses A wrote:
> Not sure why we're requiring XDG_RUNTIME_DIR to be set... isn't there another way to handle this more gracefully instead forcing Weston to exit?  I don't believe I've ever had problems running Weston when XDG_RUNTIME_DIR was undefined.
> 
> According to the spec at <http://standards.freedesktop.org/basedir-spec/latest/ar01s03.html>:
> 
> "If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk."

I just don't know that there is a 'replacement directory with similar
capabilities'.  Specifically

       "The directory MUST be owned by the user, and he MUST be the
	only one having read and write access to it. Its Unix access
	mode MUST be 0700."

is what provides access control for wayland clients and

       "The directory MUST by fully-featured by the standards of the
        operating system. More specifically, on Unix-like operating
        systems AF_UNIX sockets, symbolic links, hard links, proper
        permissions, file locking, sparse files, memory mapping, file
        change notifications, a reliable hard link count must be
        supported, and no restrictions on the file name character set
        should be imposed."

let's us put the socket there and lock it correctly.  So I don't want
to transparently fall back to /tmp and compromise that.  Hence, if you
need work around this, I think it's fair to require that you set
XDG_RUNTIME_DIR.

Kristian

> U. Artie Eoff
> 
> >-----Original Message-----
> >From: wayland-devel-
> >bounces+ullysses.a.eoff=intel.com at lists.freedesktop.org [mailto:wayland-
> >devel-bounces+ullysses.a.eoff=intel.com at lists.freedesktop.org] On Behalf
> >Of Pekka Paalanen
> >Sent: Wednesday, June 06, 2012 7:00 AM
> >To: krh at bitplanet.net
> >Cc: Pekka Paalanen; wayland-devel at lists.freedesktop.org
> >Subject: [PATCH weston 2/3] compositor: print a clear message when
> >XDG_RUNTIME_DIR is not set
> >
> >Without this patch, Weston would not start with the message:
> >creating a keymap file for 44012 bytes failed: No such file or directory
> >
> >If you do not know, that we use XDG_RUNTIME_DIR for that, the message is
> >very confusing. Therefore implement a clear error message right at the
> >start if XDG_RUNTIME_DIR is not set.
> >
> >Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> >---
> > src/compositor.c |   11 +++++++++++
> > 1 files changed, 11 insertions(+), 0 deletions(-)
> >
> >diff --git a/src/compositor.c b/src/compositor.c
> >index 93eeb24..3039c3d 100644
> >--- a/src/compositor.c
> >+++ b/src/compositor.c
> >@@ -3088,6 +3088,12 @@ load_module(const char *name, const char
> >*entrypoint, void **handle)
> > 	return init;
> > }
> >
> >+static const char xdg_error_message[] =
> >+	"fatal: environment variable XDG_RUNTIME_DIR is not set.\n"
> >+	"Refer to your distribution on how to get it, or\n"
> >+	"http://www.freedesktop.org/wiki/Specifications/basedir-spec\n"
> >+	"on how to implement it.\n";
> >+
> > int main(int argc, char *argv[])
> > {
> > 	struct wl_display *display;
> >@@ -3129,6 +3135,11 @@ int main(int argc, char *argv[])
> > 	argc = parse_options(core_options,
> > 			     ARRAY_LENGTH(core_options), argc, argv);
> >
> >+	if (!getenv("XDG_RUNTIME_DIR")) {
> >+		fprintf(stderr, xdg_error_message);
> >+		exit(EXIT_FAILURE);
> >+	}
> >+
> > 	display = wl_display_create();
> >
> > 	loop = wl_display_get_event_loop(display);
> >--
> >1.7.3.4
> >
> >_______________________________________________
> >wayland-devel mailing list
> >wayland-devel at lists.freedesktop.org
> >http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list