From 68134f03af376d103f2ab4a3ec654199842f855d Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 30 May 2024 15:37:27 +0200 Subject: Use $XDG_STATE_HOME for known hosts storage This is an often changed database, so it is better suited for $XDG_STATE_HOME rather than the more static $XDG_DATA_HOME. --- common/rfb/CSecurityTLS.cxx | 4 ++-- java/com/tigervnc/rfb/CSecurityTLS.java | 4 ++-- java/com/tigervnc/vncviewer/FileUtils.java | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/rfb/CSecurityTLS.cxx b/common/rfb/CSecurityTLS.cxx index cc0ca89f..11e6dfe3 100644 --- a/common/rfb/CSecurityTLS.cxx +++ b/common/rfb/CSecurityTLS.cxx @@ -384,9 +384,9 @@ void CSecurityTLS::checkSession() /* Certificate has some user overridable problems, so TOFU time */ - hostsDir = os::getvncdatadir(); + hostsDir = os::getvncstatedir(); if (hostsDir == NULL) { - throw AuthFailureException("Could not obtain VNC data directory " + throw AuthFailureException("Could not obtain VNC state directory " "path for known hosts storage"); } diff --git a/java/com/tigervnc/rfb/CSecurityTLS.java b/java/com/tigervnc/rfb/CSecurityTLS.java index ab221427..39d1f541 100644 --- a/java/com/tigervnc/rfb/CSecurityTLS.java +++ b/java/com/tigervnc/rfb/CSecurityTLS.java @@ -277,12 +277,12 @@ public class CSecurityTLS extends CSecurity { "do you want to continue?")) throw new AuthFailureException("server certificate has expired"); } - File vncDir = new File(FileUtils.getVncDataDir()); + File vncDir = new File(FileUtils.getVncStateDir()); if (!vncDir.exists()) { try { vncDir.mkdir(); } catch(SecurityException e) { - throw new AuthFailureException("Could not obtain VNC data directory "+ + throw new AuthFailureException("Could not obtain VNC state directory "+ "path for known hosts storage"); } } diff --git a/java/com/tigervnc/vncviewer/FileUtils.java b/java/com/tigervnc/vncviewer/FileUtils.java index 95fec3e6..6b82d3e2 100644 --- a/java/com/tigervnc/vncviewer/FileUtils.java +++ b/java/com/tigervnc/vncviewer/FileUtils.java @@ -98,6 +98,10 @@ public class FileUtils { return getVncDir("XDG_DATA_HOME", ".local" + getFileSeparator() + "share"); } + public static String getVncStateDir() { + return getVncDir("XDG_STATE_HOME", ".local" + getFileSeparator() + "state"); + } + public static String getFileSeparator() { String separator = null; try { -- cgit v1.2.3