version 1.5, 2008/12/02 09:01:48
|
version 1.6, 2009/03/27 11:52:22
|
|
|
// of the pthread_security on z/OS | // of the pthread_security on z/OS |
// For all other platforms this should be an empty class | // For all other platforms this should be an empty class |
// Targets: avoid ifdefs and keep code readable(clean) | // Targets: avoid ifdefs and keep code readable(clean) |
#ifndef PEGASUS_ZOS_THREADLEVEL_SECURITY |
#ifndef PEGASUS_ZOS_SECURITY |
| |
// not z/OS == empty class | // not z/OS == empty class |
class AutoPThreadSecurity | class AutoPThreadSecurity |
{ | { |
public: | public: |
AutoPThreadSecurity(const OperationContext& context) {}; |
AutoPThreadSecurity(const OperationContext& context, bool reverse=false) {}; |
}; | }; |
| |
#else | #else |
|
|
class AutoPThreadSecurity | class AutoPThreadSecurity |
{ | { |
public: | public: |
AutoPThreadSecurity(const OperationContext& context) |
AutoPThreadSecurity(const OperationContext& context, bool reverse=false): |
|
_reverse(reverse) |
|
{ |
|
if (!_reverse) |
{ | { |
int err_num=enablePThreadSecurity(context); | int err_num=enablePThreadSecurity(context); |
if (err_num!=0) | if (err_num!=0) |
{ | { |
// need a new CIMException for this | // need a new CIMException for this |
throw CIMException(CIM_ERR_ACCESS_DENIED,String(strerror(err_num))); |
throw CIMException( |
|
CIM_ERR_ACCESS_DENIED, |
|
String(strerror(err_num))); |
|
} |
|
} |
|
else |
|
{ |
|
// remember the context, it will be needed in the destructor |
|
internalOpContextReference = &(context); |
|
revDisablePThreadSecurity(); |
} | } |
}; | }; |
| |
~AutoPThreadSecurity() | ~AutoPThreadSecurity() |
{ | { |
|
if (!_reverse) |
|
{ |
disablePThreadSecurity(); | disablePThreadSecurity(); |
|
} |
|
else |
|
{ |
|
revEnablePThreadSecurity(*internalOpContextReference); |
|
} |
}; | }; |
|
private: |
|
const OperationContext * internalOpContextReference; |
|
bool _reverse; |
}; | }; |
| |
#endif | #endif |