The substitution expands to an absolute path before the check, so this opts
back in with eyes open.
+To inspect the effective merged values, use
+[`--show-config`](options.md#configuration-debug-options).
+
### Notes
* Default layouts:
// Search global config to locate local config
boot_innie.set_fallback(m_global);
- // Now we can load local configuration data
+ // Now we can load local configuration data.
+ // Like the global config filename, the local config filename must be
+ // absolute. A filename living on the target filesystem itself is a
+ // security hazard — any config knob (thread counts, transid lag, etc.)
+ // can be turned into a DoS vector by an attacker controlling that
+ // filesystem. Use ${ROOT}/relative/path/on/target/filesystem.conf if
+ // you really want to opt in.
static const auto lcf_key = "config.local-config-filename";
const auto local_config_filename = subst(boot_innie.get(lcf_key));
if (!local_config_filename.empty()) {
return m_name;
}
-void
-BeesStringFile::allow_symlink(bool do_allow)
-{
- m_allow_symlink = do_allow;
-}
-
string
BeesStringFile::read()
{
}
BEESNOTE("opening " << m_name << " in " << name_fd(m_dir_fd));
- Fd fd;
const auto fdcwd = (!m_dir_fd) ? AT_FDCWD : m_dir_fd.operator int();
- if (m_allow_symlink) {
- fd = openat(fdcwd, m_name.c_str(), FLAGS_OPEN_FILE);
- } else {
- fd = bees_openat2(fdcwd, m_name.c_str(), FLAGS_OPEN_FILE);
- }
+ Fd fd = openat(fdcwd, m_name.c_str(), FLAGS_OPEN_FILE);
if (!fd) {
// ENOENT means the file simply doesn't exist
if (errno == ENOENT) {
THROW_ERROR(runtime_error, "BeesStringFile write on inert handle: m_dir_fd unset and relative name '" << m_name << "'");
}
- // Path components not allowed - this code can't implement m_allow_symlink with them
+ // Atomic-rename below renames within m_dir_fd; path components in
+ // m_name would name a different directory and break that invariant.
THROW_CHECK1(invalid_argument, m_name, m_name.find_first_of("/") == string::npos);
THROW_CHECK2(out_of_range, contents.size(), m_limit, contents.size() < m_limit);
{
const auto reports_dir = bc->get_config().subst(
bc->get_config().get("path.reports", [](const string &s) { return s; }));
- BEESLOGINFO("paths.reports = '" << reports_dir << "' [path.reports]");
+ BEESLOGINFO("path.reports = '" << reports_dir << "' [path.reports]");
// Parse all report sections into a vector first
const auto parse_report_interval = [](const string &s) {
Fd m_dir_fd; ///< Directory containing the file.
string m_name; ///< Filename within m_dir_fd.
size_t m_limit; ///< Maximum number of bytes read() will return.
- bool m_allow_symlink = true; ///< If true, allow symlinks and paths outside of m_dir_fd.
public:
/// Construct referencing @p name within @p dir_fd; read() is capped at @p limit bytes.
void name(const string &new_name);
/// Return the current filename.
string name() const;
- /// Control whether to allow symlinks outside of m_dir_fd.
- void allow_symlink(bool do_allow);
};
/**