NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
privilege-helper.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25 #ifndef NFD_CORE_PRIVILEGE_HELPER_HPP
26 #define NFD_CORE_PRIVILEGE_HELPER_HPP
27 
28 #include "common.hpp"
29 
30 #include <unistd.h>
31 
32 namespace nfd {
33 
35 {
36 public:
37 
40  class Error
41  {
42  public:
43  explicit
44  Error(const std::string& what)
45  : m_whatMessage(what)
46  {
47  }
48 
49  const char*
50  what() const
51  {
52  return m_whatMessage.c_str();
53  }
54 
55  private:
56  const std::string m_whatMessage;
57  };
58 
59  static void
60  initialize(const std::string& userName, const std::string& groupName);
61 
62  static void
63  drop();
64 
65  static void
66  runElevated(function<void()> f);
67 
68 private:
69 
70  static void
71  raise();
72 
73 private:
74 
75  static uid_t s_normalUid;
76  static gid_t s_normalGid;
77 
78  static uid_t s_privilegedUid;
79  static gid_t s_privilegedGid;
80 };
81 
82 } // namespace nfd
83 
84 #endif // NFD_CORE_PRIVILEGE_HELPER_HPP
static void runElevated(function< void()> f)
PrivilegeHelper::Error represents a serious seteuid/gid failure and should only be caught by main in ...
Error(const std::string &what)
static void initialize(const std::string &userName, const std::string &groupName)
const char * what() const