Skip to content

Single instance detection doesn't work when USER env var is a non-standard value #12049

@RalfMoehse

Description

@RalfMoehse

Have you searched for an existing issue?

  • Yes, I tried searching and reviewed the pinned issues

Brief Summary

The Option "Start only a single instance of KeePassXC" does not work. Even if I enabled it, I can start a second, third etc. session.

I think it's because on my computer there exists an environment variable "USER" with a stupid value (like "/../../ABC123/user/..") and this takes priority over the environment variable "USERNAME". As a result the ".lock"-File can not be created.

Unfortunately the "USER"-Variable is needed by an important other application, so i can not delete it.

My proposal ist to insert something like this to "gui\Application.cpp":
#if defined (Q_OS_WIN)
QString userName = qgetenv("USERNAME");
#else
QString userName = qgetenv("USER");
if (userName.isEmpty()) {
userName = qgetenv("USERNAME");
}
#endif

This way the behaviour only changes on Windows. Linux, MaxOS and others are not affected.

Steps to Reproduce

  1. Create an environment variable "USER" with value like "/../../ABC123/user/.." at user level
  2. Start KeePassXC
  3. Start KeePassXC again
  4. search for %temp%\keepassxc-%username%.lock"

Expected Versus Actual Behavior

If I enable the option "Start only a single instance of KeePassXC" only one instane of KeePassXC should run. All other starts should bring up this instance.

KeePassXC Debug Information


Operating System

Windows

Linux Desktop Environment

None

Linux Windowing System

None

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions