@@ -488,28 +488,29 @@ generate_xcommand() { # Generate command to start X server VcXsrv
488
488
$Xcommand "
489
489
}
490
490
setup_cookie () { # Generate X authentication cookie
491
- local Cookie
491
+ local Cookie Xauthsystem
492
492
493
493
verbose " Cookie path: $Xcookie "
494
494
495
495
# remove old cookies if no VcXsrv is running yet
496
496
command -v tasklist.exe > /dev/null && {
497
497
tasklist.exe | rmcr | grep -q -E ' vcxsrv.exe|XWin.exe' || {
498
498
verbose " Removing old cookies."
499
- [ -e " $Xcookie " ] && rm " $Xcookie "
499
+ [ -e " $( convertpath subsystem " $ Xcookie" ) " ] && rm " $( convertpath subsystem " $ Xcookie" ) "
500
500
}
501
501
}
502
502
503
- touch " $Xcookie "
503
+ touch " $( convertpath subsystem " $ Xcookie" ) "
504
504
505
505
command -v xauth > /dev/null && {
506
+ grep -q " /usr/bin" <<< " $(command -v xauth)" && Xauthsystem=" subsystem" || Xauthsystem=" windows"
506
507
# generate fresh cookie
507
- xauth -i -f " $Xcookie " add :$Newdisplaynumber . $( mcookie)
508
+ xauth -i -f " $( convertpath $Xauthsystem " $ Xcookie" ) " add :$Newdisplaynumber . $( mcookie)
508
509
# 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 -
511
512
512
- verbose " Cookie: $( xauth -v -f " $Xcookie " list) "
513
+ verbose " Cookie: $( xauth -v -f " $( convertpath $Xauthsystem " $ Xcookie" ) " list) "
513
514
} || {
514
515
note " Command xauth not found.
515
516
runx will try experimental code to bake an X cookie itself.
@@ -518,7 +519,7 @@ setup_cookie() { # Generate X authentication cookie
518
519
If it fails, you can use option --no-auth as a workaround."
519
520
# cookiebaker $Hostip:$Newdisplaynumber > $Xcookie.tmp
520
521
cookiebaker :$Newdisplaynumber > $Xcookie .tmp
521
- cat $Xcookie .tmp >> $ Xcookie
522
+ cat $Xcookie .tmp >> " $( convertpath subsystem " $ Xcookie" ) "
522
523
rm $Xcookie .tmp
523
524
}
524
525
}
@@ -581,7 +582,7 @@ cleanup() { # --cleanup: Terminate X servers, delete cookies
581
582
MSYS2_ARG_CONV_EXCL=' *' taskkill.exe /F /PID xwin.exe
582
583
# Remove cookies
583
584
Newdisplaynumber=0
584
- rm -v " $Xcookie "
585
+ rm -v " $( convertpath subsystem " $ Xcookie" ) "
585
586
}
586
587
587
588
# ## main
@@ -718,10 +719,10 @@ main() {
718
719
719
720
# set DISPLAY and XAUTHORITY, output on stdout
720
721
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"
722
723
case " $Xauthentication " in
723
724
yes)
724
- export XAUTHORITY=" $Xcookie "
725
+ export XAUTHORITY=" $( convertpath subsystem " $ Xcookie" ) "
725
726
verbose " DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "
726
727
note " If you get application error messages like 'Cannot open display'
727
728
or 'Invalid MIT-MAGIC-COOKIE', the X authentication cookie might be broken.
0 commit comments