Skip to content

Commit a6fc1c2

Browse files
committed
Adjustments to support xauth from VcXsrv #7
1 parent 0393bb4 commit a6fc1c2

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

runx

+12-11
Original file line numberDiff line numberDiff line change
@@ -488,28 +488,29 @@ generate_xcommand() { # Generate command to start X server VcXsrv
488488
$Xcommand"
489489
}
490490
setup_cookie() { # Generate X authentication cookie
491-
local Cookie
491+
local Cookie Xauthsystem
492492

493493
verbose "Cookie path: $Xcookie"
494494

495495
# remove old cookies if no VcXsrv is running yet
496496
command -v tasklist.exe >/dev/null && {
497497
tasklist.exe | rmcr | grep -q -E 'vcxsrv.exe|XWin.exe' || {
498498
verbose "Removing old cookies."
499-
[ -e "$Xcookie" ] && rm "$Xcookie"
499+
[ -e "$(convertpath subsystem "$Xcookie")" ] && rm "$(convertpath subsystem "$Xcookie")"
500500
}
501501
}
502502

503-
touch "$Xcookie"
503+
touch "$(convertpath subsystem "$Xcookie")"
504504

505505
command -v xauth >/dev/null && {
506+
grep -q "/usr/bin" <<< "$(command -v xauth)" && Xauthsystem="subsystem" || Xauthsystem="windows"
506507
# generate fresh cookie
507-
xauth -i -f "$Xcookie" add :$Newdisplaynumber . $(mcookie)
508+
xauth -i -f "$(convertpath $Xauthsystem "$Xcookie")" add :$Newdisplaynumber . $(mcookie)
508509
# prepare cookie with localhost identification disabled by ffff. ffff means 'familiy wild'
509-
Cookie="$(xauth -i -f "$Xcookie" nlist | sed -e 's/^..../ffff/')"
510-
printf "$Cookie" | xauth -i -f "$Xcookie" nmerge -
510+
Cookie="$(xauth -i -f "$(convertpath $Xauthsystem "$Xcookie")" nlist | sed -e 's/^..../ffff/')"
511+
printf "$Cookie" | xauth -i -f "$(convertpath $Xauthsystem "$Xcookie")" nmerge -
511512

512-
verbose "Cookie: $(xauth -v -f "$Xcookie" list)"
513+
verbose "Cookie: $(xauth -v -f "$(convertpath $Xauthsystem "$Xcookie")" list)"
513514
} || {
514515
note "Command xauth not found.
515516
runx will try experimental code to bake an X cookie itself.
@@ -518,7 +519,7 @@ setup_cookie() { # Generate X authentication cookie
518519
If it fails, you can use option --no-auth as a workaround."
519520
#cookiebaker $Hostip:$Newdisplaynumber > $Xcookie.tmp
520521
cookiebaker :$Newdisplaynumber > $Xcookie.tmp
521-
cat $Xcookie.tmp >> $Xcookie
522+
cat $Xcookie.tmp >> "$(convertpath subsystem "$Xcookie")"
522523
rm $Xcookie.tmp
523524
}
524525
}
@@ -581,7 +582,7 @@ cleanup() { # --cleanup: Terminate X servers, delete cookies
581582
MSYS2_ARG_CONV_EXCL='*' taskkill.exe /F /PID xwin.exe
582583
# Remove cookies
583584
Newdisplaynumber=0
584-
rm -v "$Xcookie"
585+
rm -v "$(convertpath subsystem "$Xcookie")"
585586
}
586587

587588
### main
@@ -718,10 +719,10 @@ main() {
718719

719720
# set DISPLAY and XAUTHORITY, output on stdout
720721
export DISPLAY=$Hostip:$Newdisplaynumber
721-
Xcookie="$(convertpath subsystem "$(MSYS2_ARG_CONV_EXCL='*' cmd.exe /C "echo %userprofile%")" | rmcr)/Xauthority.runx"
722+
Xcookie="$(convertpath windows "$(MSYS2_ARG_CONV_EXCL='*' cmd.exe /C "echo %userprofile%")" | rmcr)/Xauthority.runx"
722723
case "$Xauthentication" in
723724
yes)
724-
export XAUTHORITY="$Xcookie"
725+
export XAUTHORITY="$(convertpath subsystem "$Xcookie")"
725726
verbose "DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
726727
note "If you get application error messages like 'Cannot open display'
727728
or 'Invalid MIT-MAGIC-COOKIE', the X authentication cookie might be broken.

0 commit comments

Comments
 (0)