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:
@@ -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
|
||||
|
Reference in New Issue
Block a user