Skip to content

Commit

Permalink
feat: Support socket path of KPXC 2.7.4 Flatpak
Browse files Browse the repository at this point in the history
To avoiding mounting everything into Flatpak sandbox, the socket was
moved into a separate path under Linux [1][2].

Note this does not affect other distributions under Linux as there is a
symbolic link from the old path [3].

[1] keepassxreboot/keepassxc#8030
[2] keepassxreboot/keepassxc@1009650
[3] https://github.com/keepassxreboot/keepassxc/blob/2.7.4/src/browser/BrowserShared.cpp#L49
  • Loading branch information
Frederick888 committed Oct 31, 2022
1 parent 43f49a8 commit 2e9e495
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/utils/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub fn get_socket_path() -> Result<PathBuf> {
Box::new(LinuxSocketPath260),
Box::new(MacSocketPath260),
Box::new(WindowsSocketPath260),
Box::new(LinuxSocketPath274),
Box::new(WindowsSocketPath262),
Box::new(WindowsSocketPathNatMsg),
];
Expand Down Expand Up @@ -97,6 +98,33 @@ impl SocketPath for LinuxSocketPath260 {
}
}

// https://github.com/keepassxreboot/keepassxc/commit/1009650b5c2697f5420c0f4398271652a4158c1a
struct LinuxSocketPath274;
impl SocketPath for LinuxSocketPath274 {
fn get_path(&self) -> Result<PathBuf> {
let base_dirs = directories_next::BaseDirs::new()
.ok_or_else(|| anyhow!("Failed to initialise base_dirs"))?;
let result = base_dirs
.runtime_dir()
.ok_or_else(|| anyhow!("Failed to locate runtime_dir automatically"))?
.join("app")
.join("org.keepassxc.KeePassXC")
.join(KEEPASS_SOCKET_NAME);
if result.exists() {
Ok(result)
} else {
Err(anyhow!(io::Error::new(
io::ErrorKind::NotFound,
format!("{} does not exist", result.to_string_lossy()),
)))
}
}

fn matches_os(&self) -> bool {
cfg!(target_os = "linux")
}
}

struct MacSocketPathLegacy;
impl SocketPath for MacSocketPathLegacy {
fn get_path(&self) -> Result<PathBuf> {
Expand Down

0 comments on commit 2e9e495

Please sign in to comment.