NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
privilege-helper.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NFD_CORE_PRIVILEGE_HELPER_HPP
27 #define NFD_CORE_PRIVILEGE_HELPER_HPP
28 
29 #include "common.hpp"
30 
31 #include <unistd.h>
32 
33 namespace nfd {
34 
36 {
37 public:
38 
44  class Error
45  {
46  public:
47  explicit
48  Error(const std::string& what)
49  : m_whatMessage(what)
50  {
51  }
52 
53  const char*
54  what() const
55  {
56  return m_whatMessage.c_str();
57  }
58 
59  private:
60  const std::string m_whatMessage;
61  };
62 
63  static void
64  initialize(const std::string& userName, const std::string& groupName);
65 
66  static void
67  drop();
68 
69  static void
70  runElevated(function<void()> f);
71 
73 
74  static void
75  raise();
76 
78 #ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
79  static uid_t s_normalUid;
80  static gid_t s_normalGid;
81 
82  static uid_t s_privilegedUid;
83  static gid_t s_privilegedGid;
84 #endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
85 };
86 
87 } // namespace nfd
88 
89 #endif // NFD_CORE_PRIVILEGE_HELPER_HPP
static void runElevated(function< void()> f)
represents a serious seteuid/gid failure
Error(const std::string &what)
static void initialize(const std::string &userName, const std::string &groupName)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:39