mirror of
https://github.com/systemd/systemd.git
synced 2026-08-09 01:20:53 +00:00
nresourced: add user.userbd.* xattrs to nsresourced userdb socket
This commit is contained in:
@@ -33,10 +33,12 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "time-util.h"
|
||||
#include "uid-classification.h"
|
||||
#include "umask-util.h"
|
||||
#include "unaligned.h"
|
||||
#include "userns-registry.h"
|
||||
#include "userns-restrict.h"
|
||||
#include "xattr-util.h"
|
||||
|
||||
#define LISTEN_TIMEOUT_USEC (25 * USEC_PER_SEC)
|
||||
|
||||
@@ -450,6 +452,16 @@ static int manager_make_listen_socket(Manager *m) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to symlink userdb socket: %m");
|
||||
|
||||
/* Reduce the noise routed to us: advertise that only look-ups for the higher UID range */
|
||||
char text[2 * (DECIMAL_STR_MAX(uid_t) + 1 + DECIMAL_STR_MAX(uid_t) + 1)];
|
||||
xsprintf(text, UID_FMT "-" UID_FMT "," UID_FMT "-" UID_FMT,
|
||||
CONTAINER_UID_MIN, CONTAINER_UID_MAX,
|
||||
(uid_t) DYNAMIC_UID_MIN, (uid_t) DYNAMIC_UID_MAX);
|
||||
FOREACH_STRING(xattr, "user.userdb.uid", "user.userdb.gid")
|
||||
(void) xsetxattr(AT_FDCWD, sockaddr.un.sun_path, /* at_flags= */ 0, xattr, text);
|
||||
(void) xsetxattr(AT_FDCWD, sockaddr.un.sun_path, /* at_flags= */ 0, "user.userdb.username", "ns-*");
|
||||
(void) xsetxattr(AT_FDCWD, sockaddr.un.sun_path, /* at_flags= */ 0, "user.userdb.groupname", "ns-*");
|
||||
|
||||
if (listen(m->listen_fd, SOMAXCONN) < 0)
|
||||
return log_error_errno(errno, "Failed to listen on socket: %m");
|
||||
|
||||
|
||||
@@ -1040,7 +1040,7 @@ units = [
|
||||
'conditions' : ['ENABLE_NSRESOURCED'],
|
||||
},
|
||||
{
|
||||
'file' : 'systemd-nsresourced.socket',
|
||||
'file' : 'systemd-nsresourced.socket.in',
|
||||
'conditions' : ['ENABLE_NSRESOURCED'],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -22,6 +22,10 @@ FileDescriptorName=varlink
|
||||
SocketMode=0666
|
||||
XAttrEntryPoint=user.varlink=entrypoint
|
||||
XAttrListen=user.varlink=listen
|
||||
XAttrEntryPoint=user.userdb.uid={{DYNAMIC_UID_MIN}}-{{DYNAMIC_UID_MAX}},{{CONTAINER_UID_BASE_MIN}}-{{CONTAINER_UID_BASE_MAX+65535}}
|
||||
XAttrEntryPoint=user.userdb.gid={{DYNAMIC_UID_MIN}}-{{DYNAMIC_UID_MAX}},{{CONTAINER_UID_BASE_MIN}}-{{CONTAINER_UID_BASE_MAX+65535}}
|
||||
XAttrEntryPoint=user.userdb.username=ns-*
|
||||
XAttrEntryPoint=user.userdb.groupname=ns-*
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
||||
Reference in New Issue
Block a user