Skip to content
Snippets Groups Projects

Draft: Resolve "Unix Socket Server schreiben"

Merged Leon Dietrich requested to merge 3-unix-socket-server-schreiben into master
1 file
+ 2
2
Compare changes
  • Side-by-side
  • Inline
@@ -23,7 +23,7 @@ static std::string get_unix_socket_path(const socketaddr& addr) {
return std::string(((sockaddr_un*) addr.ptr())->sun_path);
}
static auto_fd construct_server_fd(const socketaddr& addr) {
static auto_fd construct_server_fd(const socketaddr& addr, bool use_explicit_authentication) {
if (addr.family() != AF_UNIX) {
throw netio_exception("Expected a UNIX socket file path.");
}
@@ -59,7 +59,7 @@ static auto_fd construct_server_fd(const socketaddr& addr) {
// FIXME SO_PASSCRED is platform specific (linux). For *BSD there are other APIs
int optval = 1;
if(setsockopt(socket_fd.get(), SOL_SOCKET, SO_PEERCRED, &optval, sizeof(optval)) == -1) {
unlink(get_usocket_path(addr).c_str());
unlink(get_unix_socket_path(addr).c_str());
throw netio_exception("Unable to enable password authentication for file socket. REASON: " + std::string(errno == EINVAL ? "EINVAL" : (errno == ENOPROTOOPT ? "ENOPROTOOPT" : "unexpected")));
// TODO might fail as not created with socketpair(). Check man2 socketpair
}
Loading