LogError("WA::FileLockerException::LockFailed: " << e.DumpToString());
std::cerr << "WA::FileLockerException::LockFailed: " << e.DumpToString() << std::endl;
return WAUTHN_ERROR_INVALID_STATE;
+ } catch (const SocketManagerException::InitFailed &e) {
+ LogError("WA::SocketManagerException::InitFailed: " << e.DumpToString());
+ std::cerr << "WA::SocketManagerException::InitFailed: " << e.DumpToString() << std::endl;
+ return WAUTHN_ERROR_INVALID_STATE;
} catch (const std::logic_error &e) {
LogError("Invalid logic: " << e.what());
std::cerr << "Invalid logic: " << e.what() << std::endl;
LogError("Memory allocation failed: " << e.what());
std::cerr << "Memory allocation failed: " << e.what() << std::endl;
return WAUTHN_ERROR_MEMORY;
- } catch (const Exception &e) {
- LogError("WA::Exception " << e.DumpToString());
- std::cerr << "WA::Exception " << e.DumpToString() << std::endl;
} catch (const std::system_error &e) {
LogError("STD system_error: " << e.code() << "-" << e.what());
std::cerr << "STD system_error: " << e.code() << "-" << e.what() << std::endl;
+ return WAUTHN_ERROR_UNKNOWN;
} catch (const std::exception &e) {
LogError("STD exception " << e.what());
std::cerr << "STD exception " << e.what() << std::endl;
+ return WAUTHN_ERROR_UNKNOWN;
} catch (...) {
LogError("Unknown exception occurred");
std::cerr << "Unknown exception occurred" << std::endl;
#include <webauthn-log.h>
#include <errno_string.h>
-
+#include <exception.h>
#include <service.h>
#include <socket-manager.h>
FD_ZERO(&m_readSet);
if ((m_notifyMe = eventfd(0, 0)) < 0)
- ThrowErrno(Exception::InitFailed, "eventfd");
+ ThrowErrno(SocketManagerException::InitFailed, "eventfd");
LogInfo("Eventfd desc: " << m_notifyMe);
RegisterFdForReading(m_notifyMe);
sigaddset(&set, SIGTERM);
sigaddset(&set, SIGCHLD);
if (auto err = pthread_sigmask(SIG_BLOCK, &set, nullptr))
- ThrowMsg(Exception::InitFailed, "Error in pthread_sigmask: " << err);
+ ThrowMsg(SocketManagerException::InitFailed, "Error in pthread_sigmask: " << err);
// add support for TERM signal (passed from systemd)
if ((m_signalFd = signalfd(-1, &set, 0)) < 0)
- ThrowErrno(Exception::InitFailed, "signalfd");
+ ThrowErrno(SocketManagerException::InitFailed, "signalfd");
RegisterFdForReading(m_signalFd);
}
if (n < 0) {
LogError("Error in sd_listen_fds");
- ThrowMsg(Exception::InitFailed, "Error in sd_listen_fds");
+ ThrowMsg(SocketManagerException::InitFailed, "Error in sd_listen_fds");
}
for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; ++fd) {
static_assert(1 == sizeof(*desc.serviceHandlerPath.c_str()));
if (desc.serviceHandlerPath.size() >= sizeof(static_cast<sockaddr_un*>(0)->sun_path)) {
LogError("Service handler path too long: " << desc.serviceHandlerPath.size());
- ThrowMsg(Exception::InitFailed,
+ ThrowMsg(SocketManagerException::InitFailed,
"Service handler path too long: " << desc.serviceHandlerPath.size());
}
if (-1 == (sockfd = socket(AF_UNIX, SOCK_STREAM, 0))) {
- LogAndThrowErrno(Exception::InitFailed, "socket");
+ LogAndThrowErrno(SocketManagerException::InitFailed, "socket");
}
int flags;
if (-1 == (flags = fcntl(sockfd, F_GETFL, 0)))
if (fcntl(sockfd, F_SETFL, flags | O_NONBLOCK)) {
int err = errno;
close(sockfd);
- LogAndThrowWithErrno(err, Exception::InitFailed, "fcntl");
+ LogAndThrowWithErrno(err, SocketManagerException::InitFailed, "fcntl");
}
sockaddr_un serverAddress;
if (bind(sockfd, (struct sockaddr*)&serverAddress, sizeof(serverAddress))) {
int err = errno;
close(sockfd);
- LogAndThrowWithErrno(err, Exception::InitFailed, "bind");
+ LogAndThrowWithErrno(err, SocketManagerException::InitFailed, "bind");
}
umask(originalUmask);
if (listen(sockfd, SOMAXCONN)) {
int err = errno;
close(sockfd);
- LogAndThrowWithErrno(err, Exception::InitFailed, "listen");
+ LogAndThrowWithErrno(err, SocketManagerException::InitFailed, "listen");
}
return sockfd;
if (-1 == sockfd)
{
- LogError("Creating domain socket because \
+ LogWarning("Creating domain socket because \
the server is not running with on-demand socket activation.");
sockfd = CreateDomainSocketHelp(desc);
}