9 #ifndef __libutilxx__sella__util__Privilege_H__
10 #define __libutilxx__sella__util__Privilege_H__
12 #include "../../common.h"
13 #include "PrivilegeException.h"
16 #include <sys/types.h>
17 #include <sys/capability.h>
30 typedef std::shared_ptr<Privilege> shared;
39 bool operator==(
const Privilege &other)
const throw () =
delete;
40 bool operator!=(
const Privilege &other)
const throw () =
delete;
43 void applyIdentity(
void)
const throw (PrivilegeException);
44 void applyEffectiveIdentity(
void)
const throw (PrivilegeException);
45 void restoreIdentity(
void)
const throw (PrivilegeException);
46 void restoreEffectiveIdentity(
void)
const throw (PrivilegeException);
48 void setUID(uid_t &uid,
bool setGID =
true)
throw (PrivilegeException);
49 void setUID(
const std::string &user,
bool setGID =
true)
throw (PrivilegeException);
50 void setGID(gid_t &gid)
throw ();
51 void setGID(
const std::string &group)
throw (PrivilegeException);
53 const uid_t& getUID(
void)
const throw ();
54 const uid_t getCurrentUID(
void)
const throw ();
55 const uid_t getEffectiveUID(
void)
const throw ();
56 const uid_t& getOriginalUID(
void)
const throw ();
57 const gid_t& getGID(
void)
const throw ();
58 const gid_t getCurrentGID(
void)
const throw ();
59 const gid_t getEffectiveGID(
void)
const throw ();
60 const gid_t& getOriginalGID(
void)
const throw ();
62 bool isRoot(
void)
const throw ();
63 bool isRootGroup(
void)
const throw ();
64 bool wasRoot(
void)
const throw ();
65 bool wasRootGroup(
void)
const throw ();
67 void clear(
void)
throw ();
70 void applyCapabilities(
bool retain =
true)
const throw (PrivilegeException);
71 void clearRetain(
void)
const throw (PrivilegeException);
73 bool setAll(
void)
throw ();
74 bool setCapability(cap_value_t cap)
throw ();
75 bool setChown(
void)
throw ();
76 bool setSetGid(
void)
throw ();
77 bool setSetUid(
void)
throw ();
78 bool setProcessCapability(
void)
throw ();
79 bool setLinuxImmutable(
void)
throw ();
80 bool setNetBroadcast(
void)
throw ();
81 bool setNetAdmin(
void)
throw ();
82 bool setIPCOwner(
void)
throw ();
83 bool setSysModule(
void)
throw ();
84 bool setSysProcessTrace(
void)
throw ();
85 bool setSysProcessAccount(
void)
throw ();
86 bool setSysAdmin(
void)
throw ();
87 bool setSysBoot(
void)
throw ();
88 bool setSysTime(
void)
throw ();
89 bool setSysTTYConfig(
void)
throw ();
90 bool setMakeNode(
void)
throw ();
91 bool setLease(
void)
throw ();
92 bool setAuditWrite(
void)
throw ();
93 bool setAuditControl(
void)
throw ();
94 bool setSetFileCapability(
void)
throw ();
95 bool setMACOverride(
void)
throw ();
96 bool setMACAdmin(
void)
throw ();
97 bool setSyslog(
void)
throw ();
98 bool setWakeAlarm(
void)
throw ();
99 bool setBlockSuspend(
void)
throw ();
100 bool setDACOverride(
void)
throw ();
101 bool setDACReadSearch(
void)
throw ();
102 bool setFileOwner(
void)
throw ();
103 bool setFileSetId(
void)
throw ();
104 bool setIPCLock(
void)
throw ();
105 bool setKill(
void)
throw ();
106 bool setNetBindService(
void)
throw ();
107 bool setNetRaw(
void)
throw ();
108 bool setSetUID(
void)
throw ();
109 bool setSysChroot(
void)
throw ();
110 bool setSysNice(
void)
throw ();
111 bool setSysRawIO(
void)
throw ();
112 bool setSysResource(
void)
throw ();
114 bool clearAll(
void)
throw ();
115 bool clearCapability(
int capability)
throw ();
116 bool clearChown(
void)
throw ();
117 bool clearIPCLock(
void)
throw ();
118 bool clearKill(
void)
throw ();
119 bool clearNetBindService(
void)
throw ();
120 bool clearNetRaw(
void)
throw ();
121 bool clearSetUID(
void)
throw ();
122 bool clearSysChroot(
void)
throw ();
123 bool clearSysNice(
void)
throw ();
124 bool clearSysRawIO(
void)
throw ();
125 bool clearSysResource(
void)
throw ();
127 bool hasNone(
void)
const throw ();
128 bool hasCapability(
int capability)
const throw ();
129 bool hasChown(
void)
const throw ();
130 bool hasIPCLock(
void)
const throw ();
131 bool hasKill(
void)
const throw ();
132 bool hasNetBindService(
void)
const throw ();
133 bool hasNetRaw(
void)
const throw ();
134 bool hasSetUID(
void)
const throw ();
135 bool hasSysChroot(
void)
const throw ();
136 bool hasSysNice(
void)
const throw ();
137 bool hasSysRawIO(
void)
const throw ();
138 bool hasSysResource(
void)
const throw ();
140 static const Privilege::shared shared_ptr(
void)
throw ();
148 bool setFlags(cap_value_t capability[],
int ncap, cap_flag_value_t value)
throw ();
149 bool getFlag(cap_value_t capability, cap_flag_value_t &value)
const throw ();