Nix
2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Toggle main menu visibility
Loading...
Searching...
No Matches
unix-socket-server.hh
Go to the documentation of this file.
1
#pragma once
3
4
#include "
nix/util/file-descriptor.hh
"
5
6
#include <filesystem>
7
#include <functional>
8
#include <optional>
9
#include <sys/types.h>
10
11
namespace
nix::unix {
12
16
struct
PeerInfo
17
{
18
std::optional<pid_t> pid;
19
std::optional<uid_t> uid;
20
std::optional<gid_t> gid;
21
};
22
26
PeerInfo
getPeerInfo
(
Descriptor
remote);
27
36
using
UnixSocketHandler
=
fun
<void(
AutoCloseFD
socket)>;
37
43
struct
ServeUnixSocketOptions
44
{
48
std::filesystem::path
socketPath
;
49
53
mode_t
socketMode
= 0666;
54
55
#ifndef _WIN32
61
std::string
activationName
=
""
;
62
67
Descriptor
auxiliaryFd
= INVALID_DESCRIPTOR;
68
72
std::function<void()>
onAuxiliaryFdPollin
=
nullptr
;
73
#endif
74
};
75
76
MakeError(AbortServeSocket,
BaseError
);
77
98
[[noreturn]]
void
serveUnixSocket
(
const
ServeUnixSocketOptions
& options,
UnixSocketHandler
handler);
99
100
}
// namespace nix::unix
nix::AutoCloseFD
Definition
file-descriptor.hh:265
nix::BaseError
Definition
error.hh:136
nix::fun
Definition
fun.hh:19
file-descriptor.hh
File descriptor operations for almost arbitrary file descriptors.
nix::Descriptor
int Descriptor
Definition
file-descriptor.hh:36
nix::unix::PeerInfo
Definition
unix-socket-server.hh:17
nix::unix::ServeUnixSocketOptions
Definition
unix-socket-server.hh:44
nix::unix::ServeUnixSocketOptions::socketPath
std::filesystem::path socketPath
Definition
unix-socket-server.hh:48
nix::unix::ServeUnixSocketOptions::auxiliaryFd
Descriptor auxiliaryFd
Definition
unix-socket-server.hh:67
nix::unix::ServeUnixSocketOptions::activationName
std::string activationName
Definition
unix-socket-server.hh:61
nix::unix::ServeUnixSocketOptions::socketMode
mode_t socketMode
Definition
unix-socket-server.hh:53
nix::unix::ServeUnixSocketOptions::onAuxiliaryFdPollin
std::function< void()> onAuxiliaryFdPollin
Definition
unix-socket-server.hh:72
nix::unix::UnixSocketHandler
fun< void(AutoCloseFD socket)> UnixSocketHandler
Definition
unix-socket-server.hh:36
nix::unix::getPeerInfo
PeerInfo getPeerInfo(Descriptor remote)
Definition
unix-socket-server.cc:27
nix::unix::serveUnixSocket
void serveUnixSocket(const ServeUnixSocketOptions &options, UnixSocketHandler handler)
Definition
unix-socket-server.cc:70
libcmd
include
nix
cmd
unix-socket-server.hh
Generated by
1.18.0