by default when combined with --scope, will be changed in a future
release to be enabled by default.
+ * The FileDescriptorName= setting for socket units is now honored by
+ Accept=yes sockets too, where it was previously silently ignored and
+ "connection" was used unconditionally.
+
* systemd-logind now always obeys inhibitor locks, where previously it
ignored locks taken by the caller or when the caller was root. A
privileged caller can always close the other sessions, remove the
<varlistentry>
<term><varname>FileDescriptorName=</varname></term>
- <listitem><para>Assigns a name to all file descriptors this
- socket unit encapsulates. This is useful to help activated
- services identify specific file descriptors, if multiple fds
- are passed. Services may use the
+ <listitem><para>Assigns a name to all file descriptors this socket unit encapsulates.
+ This is useful to help activated services identify specific file descriptors, if multiple fds are passed.
+ Services may use the
<citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>
- call to acquire the names configured for the received file
- descriptors. Names may contain any ASCII character, but must
- exclude control characters and <literal>:</literal>, and must
- be at most 255 characters in length. If this setting is not
- used, the file descriptor name defaults to the name of the
- socket unit, including its <filename>.socket</filename>
- suffix.</para>
+ call to acquire the names configured for the received file descriptors. Names may contain any ASCII character,
+ but must exclude control characters and <literal>:</literal>, and must be at most 255 characters in length.
+ If this setting is not used, the file descriptor name defaults to the name of the socket unit
+ (including its <filename>.socket</filename> suffix) when <varname>Accept=no</varname>,
+ <literal>connection</literal> otherwise.</para>
<xi:include href="version-info.xml" xpointer="v227"/></listitem>
</varlistentry>
assert(n_storage_fds);
if (s->socket_fd >= 0) {
+ Socket *sock = ASSERT_PTR(SOCKET(UNIT_DEREF(s->accept_socket)));
/* Pass the per-connection socket */
if (!rfds)
return -ENOMEM;
- rfd_names = strv_new("connection");
+ rfd_names = strv_new(socket_fdname(sock));
if (!rfd_names)
return -ENOMEM;
s->n_accepted++;
r = service_set_socket_fd(SERVICE(service), cfd, s, p, s->selinux_context_from_net);
+ if (ERRNO_IS_NEG_DISCONNECT(r))
+ return;
if (r < 0) {
- if (ERRNO_IS_DISCONNECT(r))
- return;
-
log_unit_warning_errno(UNIT(s), r, "Failed to set socket on service: %m");
goto fail;
}
return 1;
}
-char* socket_fdname(Socket *s) {
+const char* socket_fdname(Socket *s) {
assert(s);
- /* Returns the name to use for $LISTEN_NAMES. If the user
- * didn't specify anything specifically, use the socket unit's
- * name as fallback. */
+ /* Returns the name to use for $LISTEN_FDNAMES. If the user didn't specify anything specifically,
+ * use the socket unit's name as fallback for Accept=no sockets, "connection" otherwise. */
+
+ if (s->fdname)
+ return s->fdname;
+
+ if (s->accept)
+ return "connection";
- return s->fdname ?: UNIT(s)->id;
+ return UNIT(s)->id;
}
-static PidRef *socket_control_pid(Unit *u) {
+static PidRef* socket_control_pid(Unit *u) {
return &ASSERT_PTR(SOCKET(u))->control_pid;
}
int socket_load_service_unit(Socket *s, int cfd, Unit **ret);
-char* socket_fdname(Socket *s);
+const char* socket_fdname(Socket *s);
extern const UnitVTable socket_vtable;