@@ -467,13 +467,10 @@ generate_xcommand() { # Generate command to start X server VcXsrv
467
467
case $Xauthentication in
468
468
yes)
469
469
case " $Xserver " in
470
- xwin) case " $Winsubsystem " in
471
- CYGWIN) Xcommand=" $Xcommand -auth '$Xservercookie '" ;;
472
- WSL1|WSL2) Xcommand=" $Xcommand -auth '/cygdrive${Xservercookie# $Winsubmount } '" ;;
473
- esac ;;
474
- vcxsrv) Xcommand=" $Xcommand -auth '$( convertpath windows " $Xservercookie " ) '" ;;
470
+ xwin) Xcommand=" $Xcommand -auth '$( convertpath subsystem " $Xcookie " ) '" ;;
471
+ vcxsrv) Xcommand=" $Xcommand -auth '$( convertpath windows " $Xcookie " ) '" ;;
475
472
esac ;;
476
- no) Xcommand=" $Xcommand -ac" ;;
473
+ no) Xcommand=" $Xcommand -ac" ;;
477
474
esac
478
475
479
476
# X server extensions
@@ -493,45 +490,36 @@ generate_xcommand() { # Generate command to start X server VcXsrv
493
490
setup_cookie () { # Generate X authentication cookie
494
491
local Cookie
495
492
496
- verbose " Cookies:
497
- server: $Xservercookie
498
- client: $Xclientcookie "
493
+ verbose " Cookie path: $Xcookie "
499
494
500
495
# remove old cookies if no VcXsrv is running yet
501
496
command -v tasklist.exe > /dev/null && {
502
497
tasklist.exe | rmcr | grep -q -E ' vcxsrv.exe|XWin.exe' || {
503
498
verbose " Removing old cookies."
504
- [ -e " $Xservercookie " ] && rm " $Xservercookie "
505
- [ -e " $Xclientcookie " ] && rm " $Xclientcookie "
499
+ [ -e " $Xcookie " ] && rm " $Xcookie "
506
500
}
507
501
}
508
502
509
- touch " $Xclientcookie "
510
- touch " $Xservercookie "
503
+ touch " $Xcookie "
511
504
512
505
command -v xauth > /dev/null && {
513
506
# generate fresh cookie
514
- xauth -i -f " $Xclientcookie " add :$Newdisplaynumber . $( mcookie)
507
+ xauth -i -f " $Xcookie " add :$Newdisplaynumber . $( mcookie)
515
508
# prepare cookie with localhost identification disabled by ffff. ffff means 'familiy wild'
516
- Cookie=" $( xauth -i -f " $Xclientcookie " nlist | sed -e ' s/^..../ffff/' ) "
517
- printf " $Cookie " | xauth -i -f " $Xclientcookie " nmerge -
518
- printf " $Cookie " | xauth -i -f " $Xservercookie " nmerge -
519
-
520
- verbose " Client cookie:
521
- $( xauth -v -f " $Xclientcookie " list) "
522
- verbose " Server cookie:
523
- $( xauth -v -f " $Xservercookie " list) "
509
+ Cookie=" $( xauth -i -f " $Xcookie " nlist | sed -e ' s/^..../ffff/' ) "
510
+ printf " $Cookie " | xauth -i -f " $Xcookie " nmerge -
511
+
512
+ verbose " Cookie: $( xauth -v -f " $Xcookie " list) "
524
513
} || {
525
514
note " Command xauth not found.
526
515
runx will try experimental code to bake an X cookie itself.
527
516
Feedback on success or failure is appreciated at:
528
517
https://github.com/mviereck/runx/issues/7
529
518
If it fails, you can use option --no-auth as a workaround."
530
- # cookiebaker $Hostip:$Newdisplaynumber > $Xclientcookie.tmp
531
- cookiebaker :$Newdisplaynumber > $Xclientcookie .tmp
532
- cat $Xclientcookie .tmp >> $Xclientcookie
533
- cat $Xclientcookie .tmp >> $Xservercookie
534
- rm $Xclientcookie .tmp
519
+ # cookiebaker $Hostip:$Newdisplaynumber > $Xcookie.tmp
520
+ cookiebaker :$Newdisplaynumber > $Xcookie .tmp
521
+ cat $Xcookie .tmp >> $Xcookie
522
+ rm $Xcookie .tmp
535
523
}
536
524
}
537
525
start_xserver () { # run X
@@ -593,8 +581,7 @@ cleanup() { # --cleanup: Terminate X servers, delete cookies
593
581
MSYS2_ARG_CONV_EXCL=' *' taskkill.exe /F /PID xwin.exe
594
582
# Remove cookies
595
583
Newdisplaynumber=0
596
- setup_cookie
597
- rm -v " $Xclientcookie " " $Xservercookie "
584
+ rm -v " $Xcookie "
598
585
}
599
586
600
587
# ## main
@@ -731,11 +718,10 @@ main() {
731
718
732
719
# set DISPLAY and XAUTHORITY, output on stdout
733
720
export DISPLAY=$Hostip :$Newdisplaynumber
721
+ Xcookie=" $( convertpath subsystem " $( MSYS2_ARG_CONV_EXCL=' *' cmd.exe /C " echo %userprofile%" ) " | rmcr) /Xauthority.runx"
734
722
case " $Xauthentication " in
735
723
yes)
736
- Xclientcookie=" $( convertpath subsystem " ~/runx_Xauthority" ) "
737
- Xservercookie=" $( convertpath subsystem " $( MSYS2_ARG_CONV_EXCL=' *' cmd.exe /C " echo %userprofile%" ) " | rmcr) /runx_Xauthority"
738
- export XAUTHORITY=" $Xclientcookie "
724
+ export XAUTHORITY=" $Xcookie "
739
725
verbose " DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "
740
726
note " If you get application error messages like 'Cannot open display'
741
727
or 'Invalid MIT-MAGIC-COOKIE', the X authentication cookie might be broken.
0 commit comments