Trust
A server does not start when an account other than its own can write to its configuration files.
A configuration file grants capabilities, so a person who can change the file can change what a program may do. The rule covers every file that the configuration reads, the directory of each file, and each secret file that it names. If the check fails for one of them, the start stops with the error E0607.
On Linux, a group that can only read the files passes the check. A group that can write them does not pass. After chmod 0664 on nvs.toml, the group can write the file, and the next start fails.
Good to know: the server applies this check. In this version, nvs run and nvs config check do not apply it. The chapter "Installing on a host" lists the permissions that pass on Windows and on Linux, the commands that set them, and the meaning of each error message.
Examples
The examples below run with this configuration file.
# This file gives the program its settings and its rights.# Only the account that runs the server may be able to change it.[limits]memory = "128M"
# The program may not write any file.[capabilities.fs]write = []What a program can change
<?nvs// Shows what a program can change in its own configuration, and what it cannot.
// The program reads its settings from `nvs.toml`. This prints `128M`.echo Core\Config::get('memory'), "\n";
// `Core\Config::set` changes a setting for this request only. The file stays the same.// This prints `yes` and then `64M`.echo Core\Config::set('memory', '64M') ? 'yes' : 'no', "\n";echo Core\Config::get('memory'), "\n";
// A program cannot give itself a new right.
// `Core\Config::set('capabilities.fs.write', ...)` does not compile,// because a program may not change `capabilities.fs.write`.
// This program keeps the name in a variable. The compiler does not check a variable, so `set` runs and returns `false`.// This prints `no`.string $right = 'capabilities.fs.write';echo Core\Config::set($right, '.') ? 'yes' : 'no', "\n";
// Writing a file needs `fs.write`. It is not granted, so this throws a `RuntimeError`.try { Core\IO::write('nvs.toml', "[limits]\nmemory = \"64G\"\n");} catch (RuntimeError $denied) { echo "not allowed to write nvs.toml\n";}128Myes64Mnonot allowed to write nvs.toml