QtCraft API C++ classes QML types Handbook

QcSecretFile Namespace

Files that hold secrets (the player key, the server's TLS key, the known servers, a server's settings and identities; decisions E-252, E-872, E-901): written atomically (QSaveFile) and readable only by the user. More...

Header: #include <common/auth/QcSecretFile.h>

Functions

bool othersMayRead(const QString &path)
QcStatus write(const QString &path, const QByteArray &bytes)

Detailed Description

On macOS and Linux that holds from the moment the file exists, before any byte of the secret is in it; on Windows the file gets an owner-only access list right after it is written, until then the access list of its folder applies (the folder in the user's profile is private to the user, a folder in the root of a drive is not).

Function Documentation

bool QcSecretFile::othersMayRead(const QString &path)

Returns whether the group or others may read the file at path (a key copied with the wrong permissions); on Windows whether its access list lets Everyone, Users or Authenticated Users read it.

QcStatus QcSecretFile::write(const QString &path, const QByteArray &bytes)

Writes bytes to path with owner-only permissions; returns an error with the reason only (the caller names the file). Fails when the permissions cannot be set: nothing is written then. On Windows a failed owner-only access list (a drive without access lists) only warns.