diff options
author | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-18 03:43:18 +0000 |
---|---|---|
committer | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-18 03:43:18 +0000 |
commit | 9609b9f14945b8dc55321a5fee7855f7b1dc9451 (patch) | |
tree | c1f9569b61951e6ac771b9f8992816d6381945a2 /config | |
parent | 5102f671d3f5a4e870e8ea8b78cef953d4f64111 (diff) |
Bug #5898 <https://bugs.freedesktop.org/show_bug.cgi?id=5898> Use mktemp
command to create files safely in TMPDIR or /tmp on systems that have
it - don't try to create files there if mktemp is not present. Fix
based on NetBSD fix from
<http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=32805> .
Diffstat (limited to 'config')
-rw-r--r-- | config/Makefile.am | 8 | ||||
-rw-r--r-- | config/Xsession.cpp | 44 |
2 files changed, 42 insertions, 10 deletions
diff --git a/config/Makefile.am b/config/Makefile.am index 12f27ea..36410f4 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -1,4 +1,4 @@ -# $Id$ +# $XdotOrg: $ # include $(top_srcdir)/cpprules.in @@ -46,11 +46,15 @@ XPMDEFINES = -DXPM -DBITMAPDIR=$(XDM_PIXMAPDIR) -DXDM_PIXMAP=$(XDM_PIXMAP) \ -DXDM_BWPIXMAP=$(XDM_BWPIXMAP) #endif +#if HAVE_MKTEMP_COMMAND +MKTEMP_DEFINES = -DMKTEMP_COMMAND=$(MKTEMP_COMMAND) +#endif + CPP_FILES_FLAGS = -DBINDIR=$(bindir) -DDEFAULTVT=$(DEFAULTVT) \ -DXDMDIR=$(XDMLIBDIR) -DXDMLOGDIR=$(XDMLOGDIR) -DXDMPIDDIR=$(XDMPIDDIR) \ -DXDMCONFIGDIR=$(XDMCONFIGDIR) -DXDMSCRIPTDIR=$(XDMSCRIPTDIR) \ -DSU=$(SU) -DCHOOSERPATH=$(XDMLIBDIR)/chooser $(XPMDEFINES) \ - -DSHELL_CMD=$(SHELL_CMD) + -DSHELL_CMD=$(SHELL_CMD) $(MKTEMP_DEFINES) Xservers.ws: $(srcdir)/Xservers.ws.cpp $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $(srcdir)/Xservers.ws.cpp | $(CPP_SED_MAGIC) > $@ diff --git a/config/Xsession.cpp b/config/Xsession.cpp index 4f80d78..11ccd1e 100644 --- a/config/Xsession.cpp +++ b/config/Xsession.cpp @@ -1,17 +1,45 @@ XCOMM!SHELL_CMD XCOMM +XCOMM $XdotOrg: $ XCOMM $Xorg: Xsession,v 1.4 2000/08/17 19:54:17 cpqbld Exp $ XCOMM $XFree86: xc/programs/xdm/config/Xsession,v 1.2 1998/01/11 03:48:32 dawes Exp $ XCOMM redirect errors to a file in user's home directory if we can -for errfile in "$HOME/.xsession-errors" "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER" -do - if ( umask 077 && cp /dev/null "$errfile" 2> /dev/null ) - then - exec > "$errfile" 2>&1 - break - fi -done + +errfile="$HOME/.xsession-errors" +if ( umask 077 && cp /dev/null "$errfile" 2> /dev/null ) +then + exec > "$errfile" 2>&1 +else +#ifdef MKTEMP_COMMAND + mktemp=MKTEMP_COMMAND + for errfile in "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER" + do + if ef="$( umask 077 && $mktemp "$errfile.XXXXXX" 2> /dev/null)" + then + exec > "$ef" 2>&1 + mv "$ef" "$errfile" 2> /dev/null + break + fi + done +#else +XCOMM Since this system doesn't have a mktemp command to allow secure +XCOMM creation of files in shared directories, no fallback error log +XCOMM is being used. See https://bugs.freedesktop.org/show_bug.cgi?id=5898 +XCOMM +XCOMM for errfile in "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER" +XCOMM do +XCOMM if ( umask 077 && cp /dev/null "$errfile" 2> /dev/null ) +XCOMM then +XCOMM exec > "$errfile" 2>&1 +XCOMM break +XCOMM fi +XCOMM done + + exec > /dev/null 2>&1 + +#endif +fi case $# in 1) |