`/usr/local/bin/startx` does not correctly calculate the `$displayname` value used by `xauth`. Specifically the `xauth` man page states that same-machine connections should use the form `$hostname/unix:$display`. The following patch should fix the behaviour. @@ -192,9 +193,9 @@ # now add the same credentials to the client authority file # if '$displayname' already exists do not overwrite it as another # server man need it. Add them to the '$xserverauthfile' instead. - for displayname in $authdisplay $hostname$authdisplay; do + for displayname in $authdisplay $hostname/unix$authdisplay; do authcookie=`xauth list "$displayname" \ - | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null; + | sed -n "s|.*$displayname[[:space:]*].*[[:space:]*]||p"` 2>/dev/null; if [ "z${authcookie}" = "z" ] ; then xauth -q << EOF add $displayname . $mcookie
Thank you for your report and patch Duane. Could you please: - Include the patch in comment 0 as an attachment - Detail what the impact/results/symptoms are of the incorrect calculation - Provide confirmation (if possible) of the patch fixing the problem
Created attachment 184314 [details] Patch to remove warnings and align displayname with `xauth`
Before the patch, running `startx` results in the following output: ======== 8< ======== # startx xauth: file /home/username/.serverauth.30545 does not exist xauth: (argv):1: bad display name "hostname:1" in "list" command xauth: (stdin):1: bad display name "hostname:1" in "add" command X.Org X Server 1.18.4 Release Date: 2016-07-19 X Protocol Version 11, Revision 0 Build Operating System: FreeBSD 11.0-RELEASE-p10 amd64 Current Operating System: FreeBSD shuttle 11.1-RC1 FreeBSD 11.1-RC1 #0 r320486: Fri Jun 30 02:25:16 UTC 2017 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 Build Date: 06 July 2017 02:02:56AM Current version of pixman: 0.34.0 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.1.log", Time: Wed Jul 12 17:41:54 2017 (==) Using config file: "/usr/local/etc/X11/xorg.conf" xinit: connection to X server lost waiting for X server to shut down (II) Server terminated successfully (0). Closing log file. xauth: (argv):1: bad display name "hostname:1" in "remove" command ======== 8< ======== After applying the patch the output is as follows: ======== 8< ======== # startx X.Org X Server 1.18.4 Release Date: 2016-07-19 X Protocol Version 11, Revision 0 Build Operating System: FreeBSD 11.0-RELEASE-p10 amd64 Current Operating System: FreeBSD shuttle 11.1-RC1 FreeBSD 11.1-RC1 #0 r320486: Fri Jun 30 02:25:16 UTC 2017 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 Build Date: 06 July 2017 02:02:56AM Current version of pixman: 0.34.0 Before reporting problems, check http://wiki.x.org to make sure that you have the latest version. Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown. (==) Log file: "/var/log/Xorg.1.log", Time: Wed Jul 12 17:43:30 2017 (==) Using config file: "/usr/local/etc/X11/xorg.conf" xinit: connection to X server lost waiting for X server to shut down (II) Server terminated successfully (0). Closing log file. ======== 8< ======== I don't know enough about `xauth` and all the rest to know the significance of the changes, and I'm not even sure when the different authority files come into play. I do know the existing behaviour doesn't function as intended, but I cannot attest to whether the intended behaviour is correct.
Created attachment 184458 [details] Additionally fix `expr` bashism This also fixes a bashism (I think) in the vtarg expression which was `expr match $i <regex>` and is now instead `expr $i : <regex>`.
(In reply to Duane from comment #4) Sorry, not a bashism, a gnuism.
(In reply to Duane from comment #4) > `expr $i : <regex>`. 1. Parenthesises should be placed around $i to screen leading dashes in startx parameters: `expr \( $i \) : <regex>` 2. startx.cpp inside ${WRKSRC} directory is a right file to patch, not /usr/local/bin/startx
I am not a programmer, but have been suspicious that this bug might exist; according to searches, many people are having trouble with it, especially since it is so unpredictable, in many Nixes. In Freebsd11.0, it has arisen for me every time that I load xfce. It generates an mtrr error as well. As it is pointed out here, the variable fails to reset. I had not wanted to trouble you in this technical forum, but is there any way for a "user" with enough experience of Freebsd (5 years), vi, and Unix to enter into some file and repair it? I am frightened to do so without guidance. So, if possible, would you be kind enough to provide specific instructions, starting in root (this is, x@y:/ #) and with the correct file path, to the file or files in question, and what to do when vi filename be invoked? This would help many people. Many thanks.
Duane, Thank you for pointing out these problems and suggesting fixes. It is not necessary to create the xserverauthfile with touch; xauth will create it on add / generate. The "does not exist" message is an expected informational message from the init function in xauth. Vladimir, You are correct on both points. Additionally, the regex needs to be translated to a BRE for BSD expr, i.e. '^vt[0-9]\+$' -> 'vt[0-9][0-9]*$'. There is an upstream commit which corrects the syntax in both regards (removes match and use of ERE syntax) but neglects the guard parenthesis.
(In reply to Matthew Rezny from comment #8) > There is an upstream commit which corrects the syntax in both regards (removes match and use of ERE syntax) but neglects the guard parenthesis. If I run startx with -nolisten tcp option and without parenthesis applied I get following error as expr treats -nolisten as own option: $ /usr/local/bin/startx -- -nolisten tcp expr: illegal option -- n expr: usage: expr [-e] expression This error is harmless but I dislike the message. Other way to fix it is to place "x" before both string and regex: if expr "x$i" : '^xvt[0-9]\+$'
Created attachment 184847 [details] fixup x11/xinit Try with this patch.
A commit references this bug: Author: rezny Date: Sun Aug 27 19:27:38 UTC 2017 New revision: 448838 URL: https://svnweb.freebsd.org/changeset/ports/448838 Log: Set correct $displayname and remove expr GNUisms PR: 220668 Reported by: parakleta@darkreality.org, wulf Changes: head/x11/xinit/Makefile head/x11/xinit/files/ head/x11/xinit/files/patch-startx.cpp