1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:07:35 +00:00

SystemServer: Allow specifying per-service socket file permissions

This commit is contained in:
Andreas Kling 2020-01-09 21:35:33 +01:00
parent f3dad64a3b
commit 7dd03b46ee
3 changed files with 6 additions and 1 deletions

View file

@ -104,7 +104,7 @@ void Service::setup_socket()
ASSERT_NOT_REACHED();
}
if (fchmod(m_socket_fd, 0600) < 0) {
if (fchmod(m_socket_fd, m_socket_permissions) < 0) {
perror("fchmod");
ASSERT_NOT_REACHED();
}
@ -270,6 +270,8 @@ Service::Service(const CConfigFile& config, const StringView& name)
m_socket_path = config.read_entry(name, "Socket");
if (!m_socket_path.is_null()) {
auto socket_permissions_string = config.read_entry(name, "SocketPermissions", "0600");
m_socket_permissions = strtol(socket_permissions_string.characters(), nullptr, 8) & 04777;
setup_socket();
}
}

View file

@ -38,6 +38,8 @@ private:
bool m_keep_alive { false };
// Path to the socket to create and listen on on behalf of this service.
String m_socket_path;
// File system permissions for the socket.
mode_t m_socket_permissions { 0 };
// Whether we should only spawn this service once somebody connects to the socket.
bool m_lazy;
// The name of the user we should run this service as.