32 lines
728 B
C++
32 lines
728 B
C++
// SPDX-FileCopyrightText: Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <shared_mutex>
|
|
#include <optional>
|
|
#include <unordered_map>
|
|
|
|
#include <unistd.h>
|
|
|
|
namespace malcontent {
|
|
|
|
class Resolver;
|
|
|
|
class UserPolicy {
|
|
public:
|
|
UserPolicy() = default;
|
|
UserPolicy(const UserPolicy&) = delete;
|
|
UserPolicy(UserPolicy&&) = delete;
|
|
~UserPolicy() noexcept = default;
|
|
|
|
auto resolver(std::optional<uid_t> uid = {}) const -> std::shared_ptr<Resolver>;
|
|
|
|
private:
|
|
mutable std::unordered_map<uid_t, std::shared_ptr<Resolver>> _resolver_cache;
|
|
mutable std::shared_mutex _cache_mutex;
|
|
};
|
|
|
|
} // ~ namespace malcontent
|