geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
SecurePath.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2024 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef SECUREPATH_HPP_INCLUDE
7 #define SECUREPATH_HPP_INCLUDE
8 
9 
10 #include <sys/stat.h>
11 
12 #include <string>
13 #include <memory>
14 
15 namespace geopm
16 {
18  // particular umask. This object will call open() on a file, and
19  // provide a path to the open file under procfs for secure reading/writing.
20  // The file will be closed on destruction of this object.
21  class SecurePath
22  {
23  public:
24  SecurePath() = delete;
25  SecurePath(const SecurePath &other) = delete;
26  SecurePath &operator=(const SecurePath &other) = delete;
27 
29  // the root user with a umask of (S_IWGRP | S_IWOTH) or 0o022.
30  SecurePath(const std::string &orig_path);
35  SecurePath(const std::string &orig_path, mode_t umask, bool enforce);
36 
37  virtual ~SecurePath();
38 
40  std::string secure_path(void) const;
41 
42  private:
43  int m_fd;
44  };
45 }
46 #endif
Helper object to optionally verify that a file was created with a.
Definition: SecurePath.hpp:22
virtual ~SecurePath()
Definition: SecurePath.cpp:75
SecurePath(const SecurePath &other)=delete
SecurePath & operator=(const SecurePath &other)=delete
std::string secure_path(void) const
Accessor for path under procfs.
Definition: SecurePath.cpp:80
Definition: Agg.cpp:20