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 
43  class Error
44  {
45  public:
46  explicit
47  Error(const std::string& what)
48  : m_whatMessage(what)
49  {
50  }
51 
52  const char*
53  what() const
54  {
55  return m_whatMessage.c_str();
56  }
57 
58  private:
59  const std::string m_whatMessage;
60  };
61 
62  static void
63  initialize(const std::string& userName, const std::string& groupName);
64 
65  static void
66  drop();
67 
68  static void
69  runElevated(function<void()> f);
70 
72 
73  static void
74  raise();
75 
77 #ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
78  static uid_t s_normalUid;
79  static gid_t s_normalGid;
80 
81  static uid_t s_privilegedUid;
82  static gid_t s_privilegedGid;
83 #endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
84 };
85 
86 } // namespace nfd
87 
88 #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:38
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:39
const char * what() const