//
#include <security_utilities/errors.h>
#include <security_utilities/debugging.h>
+#include <security_utilities/utility_config.h>
+#include <security_utilities/debugging_internal.h>
#include <typeinfo>
#include <stdio.h>
#include <Security/SecBase.h>
+#include <Security/CSCommon.h>
#include <execinfo.h>
#include <cxxabi.h>
LogBacktrace();
}
-UnixError::UnixError(int err) : error(err)
+UnixError::UnixError(int err, bool suppresslogging) : error(err)
{
SECURITY_EXCEPTION_THROW_UNIX(this, err);
- snprintf(whatBuffer, whatBufferSize, "UNIX error exception: %d", this->error);
- secnotice("security_exception", "%s", what());
- LogBacktrace();
+ if(!suppresslogging || secinfoenabled("security_exception")) {
+ snprintf(whatBuffer, whatBufferSize, "UNIX error exception: %d", this->error);
+ secnotice("security_exception", "%s", what());
+ LogBacktrace();
+ }
}
const char *UnixError::what() const throw ()
int UnixError::unixError() const
{ return error; }
-void UnixError::throwMe(int err) { throw UnixError(err); }
+void UnixError::throwMe(int err) { throw UnixError(err, false); }
+void UnixError::throwMeNoLogging(int err) { throw UnixError(err, true); }
+
// @@@ This is a hack for the Network protocol state machine
-UnixError UnixError::make(int err) { return UnixError(err); }
+UnixError UnixError::make(int err) { return UnixError(err, false); }
//
SECURITY_EXCEPTION_THROW_OSSTATUS(this, err);
snprintf(whatBuffer, whatBufferSize, "MacOS error: %d", this->error);
- secnotice("security_exception", "%s", what());
- LogBacktrace();
+ switch (err) {
+ case errSecCSReqFailed:
+ // This 'error' isn't an actual error and doesn't warrant being logged.
+ break;
+ default:
+ secnotice("security_exception", "%s", what());
+ LogBacktrace();
+ }
}
const char *MacOSError::what() const throw ()
void MacOSError::throwMe(int error)
{ throw MacOSError(error); }
+void MacOSError::throwMe(int error, char const *message, ...)
+{
+ // Ignoring the message for now, will do something with it later.
+ throw MacOSError(error);
+}
+
MacOSError MacOSError::make(int error)
{ return MacOSError(error); }