~danyspin97/xdgpp

3fc23f3bdafb3c6257550899c0ee961a3dde4ead — Danilo Spinella 1 year, 10 months ago 64af46f
xdg.hpp: Throw when XDG_RUNTIME_DIR has bad perms

XDG_RUNTIME_DIR directory must be 0700, throws
xdg::BaseDirectoryException otherwise.
1 files changed, 6 insertions(+), 4 deletions(-)

M xdg.hpp
M xdg.hpp => xdg.hpp +6 -4
@@ 111,11 111,13 @@ private:
                    std::filesystem::status(runtime_dir).permissions();
                using perms = std::filesystem::perms;
                // Check XDG_RUNTIME_DIR permissions are 0700
                if (((runtime_dir_perms & perms::owner_all) != perms::none) ||
                    ((runtime_dir_perms & perms::group_all) == perms::none) ||
                    ((runtime_dir_perms & perms::others_all) == perms::none)) {
                    runtime_.emplace(runtime_dir);
                if (((runtime_dir_perms & perms::owner_all) == perms::none) ||
                    ((runtime_dir_perms & perms::group_all) != perms::none) ||
                    ((runtime_dir_perms & perms::others_all) != perms::none)) {
                    throw BaseDirectoryException(
                        "$XDG_RUNTIME_DIR must have 0700 as permissions");
                }
                runtime_.emplace(runtime_dir);
            }
        }
    }