2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 14:35:29 +00:00

[#3050] Added Umask RAII and use it

This commit is contained in:
Francis Dupont
2024-06-01 00:47:11 +02:00
parent 7d862a067c
commit 84c437e30f
4 changed files with 41 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
#ifndef KEA_UTIL_FILESYSTEM_H
#define KEA_UTIL_FILESYSTEM_H
#include <sys/stat.h>
#include <string>
namespace isc {
@@ -48,6 +49,23 @@ isDir(const std::string& path);
bool
isFile(const std::string& path);
/// \brief RAII device to limit access of created files.
struct Umask {
/// \brief Constructor
///
/// Set wanted bits in umask.
Umask(mode_t mask);
/// \brief Destructor.
///
/// Restore umask.
~Umask();
private:
/// \brief Original umask.
mode_t orig_umask_;
};
/// \brief Paths on a filesystem
struct Path {
/// \brief Constructor