ux_x11.c 766 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * ux_x11.c: fetch local auth data for X forwarding.
  3. */
  4. #include <ctype.h>
  5. #include <unistd.h>
  6. #include <assert.h>
  7. #include <stdlib.h>
  8. #include <errno.h>
  9. #include "putty.h"
  10. #include "ssh.h"
  11. #include "network.h"
  12. void platform_get_x11_auth(struct X11Display *disp, Conf *conf)
  13. {
  14. char *xauthfile;
  15. int needs_free;
  16. /*
  17. * Find the .Xauthority file.
  18. */
  19. needs_free = FALSE;
  20. xauthfile = getenv("XAUTHORITY");
  21. if (!xauthfile) {
  22. xauthfile = getenv("HOME");
  23. if (xauthfile) {
  24. xauthfile = dupcat(xauthfile, "/.Xauthority", NULL);
  25. needs_free = TRUE;
  26. }
  27. }
  28. if (xauthfile) {
  29. x11_get_auth_from_authfile(disp, xauthfile);
  30. if (needs_free)
  31. sfree(xauthfile);
  32. }
  33. }
  34. const int platform_uses_x11_unix_by_default = TRUE;