When no logfile was specified (xf86LogFileFrom == X_DEFAULT) and we're not running as root log to $XDG_DATA_HOME/xorg/Xorg.#.log as Xorg won't be able to log to the default /var/log/... when it is not running as root.
Signed-off-by: Hans de Goede <[email protected]> --- hw/xfree86/common/xf86Helper.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c index 12a8771..b9d6c1b 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c @@ -1220,13 +1220,27 @@ xf86ErrorF(const char *format, ...) void xf86LogInit(void) { - char *lf = NULL; + char *env, *lf = NULL; + char buf[PATH_MAX]; #define LOGSUFFIX ".log" #define LOGOLDSUFFIX ".old" /* Get the log file name */ if (xf86LogFileFrom == X_DEFAULT) { + /* When not running as root, we won't be able to write to /var/log */ + if (geteuid() != 0) { + if ((env = getenv("XDG_DATA_HOME"))) + snprintf(buf, sizeof(buf), "%s/xorg", env); + else if ((env = getenv("HOME"))) + snprintf(buf, sizeof(buf), "%s/.local/share/xorg", env); + + if (env) { + (void)mkdir(buf, 0777); + strlcat(buf, "/Xorg.", sizeof(buf)); + xf86LogFile = buf; + } + } /* Append the display number and ".log" */ if (asprintf(&lf, "%s%%s" LOGSUFFIX, xf86LogFile) == -1) FatalError("Cannot allocate space for the log file name\n"); -- 1.9.0 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
