1
0
mirror of https://github.com/systemd/systemd synced 2026-03-30 03:34:49 +02:00

Compare commits

...

15 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
72cbc28347
meson: sort shell completions and exit earlier when shell completion is disabled (#39816) 2025-11-20 08:35:21 +01:00
Zbigniew Jędrzejewski-Szmek
0f7d3e34e1
Avoid multiple evaluations in STRERROR_XYZ() macros (#39794) 2025-11-20 08:29:32 +01:00
Yu Watanabe
d2b8e42742 meson: exit earlier from the subdirectory when bash/zshcompletiondir is 'no' 2025-11-20 14:50:30 +09:00
Yu Watanabe
c74dc8cf14 meson: sort shell completions 2025-11-20 14:48:33 +09:00
Luca Boccassi
f16518ce86 shell-completion: add bash script for varlinkctl 2025-11-20 14:34:40 +09:00
Yu Watanabe
70fa7d4ccc
core: SMACK label to Unix socket path and FD (#39772)
Currently, when a socket unit specifies SmackLabel=,
the label is not applied to the underlying Unix socket file or its file
descriptor.

This change ensures that the SMACK label is applied both to the
Unix socket path on the filesystem and to all associated socket FDs
when the socket is created.

Testing:

- Tested on Fedora 43 with kernel 6.17.7 with SMACK enabled.
- Created a systemd socket unit:

    [Unit]
    Description=UNIX socket

    [Socket]
    ListenStream=/run/test.sock
    SmackLabel=label

    [Install]
    WantedBy=sockets.target

- Created a corresponding service:

    [Unit]
    Description=UNIX socket service
    Requires=test.socket

    [Service]
    ExecStart=/usr/bin/socat -v - -
    StandardInput=socket

    [Install]
    WantedBy=multi-user.target

- Verified SMACK labels using getfattr:

  - Without SmackLabel:
    ```
    # file: run/test.sock
    security.SMACK64="_"
    # file: proc/<pid>/fd/*
    security.SMACK64="*"
    ```
  - With SmackLabel=label:
    ```
    # file: run/test.sock
    security.SMACK64="label"
    # file: proc/<pid>/fd/*
    security.SMACK64="label"
    ```
2025-11-20 13:23:51 +09:00
Yu Watanabe
5de39570c8
Simplify source lists in meson config (#39811) 2025-11-20 13:20:41 +09:00
Yu Watanabe
a7947d54db NEWS: fix typo 2025-11-20 10:08:38 +09:00
Zbigniew Jędrzejewski-Szmek
5220bb8c3f meson: automatically add 'extract' to 'sources'
In all cases, everything that we list in 'extract', we also list in
'sources'. We can simplify things by automatically appending the first
list to the second.

In the listings, move 'extract' key right below 'sources', since now
they are both "sources", just with slightly different meanings.
2025-11-20 10:03:48 +09:00
Marc-Antoine Riou
360f750b01 socket-label: apply SMACK label to socket and its file descriptor
When a socket unit specifies SmackLabel=, the label was previously
not applied to the underlying Unix socket file or its file descriptor.
This change ensures that the SMACK label is applied both to the
socket path on the filesystem and to the opened socket FD.
2025-11-20 09:59:37 +09:00
Yu Watanabe
cb4b36928a socket-label: move prototype of socket_address_listen() and string table for SocketAddressBindIPv6Only
The function socket_address_listen() is declared at shared/socket-label.c,
however its prototype was in basic/socket-util.h. This moves the
prototype to shared/socket-label.h.

Also, enum SocketAddressBindIPv6Only is not used anymore in basic/*.[ch].
Let's move the definition and its string table to shared/socket-label.[ch].

Follow-up for b25a930f0e2ebe77bc8b0f0acfac8a3b27ef1f0a.
2025-11-20 09:58:53 +09:00
Yu Watanabe
5feb65c5b1 user-util: avoid double evaluation in STRERROR_USER/GROUP()
Follow-up for 6e6e96f628d352b56fd396cffb311f16839f78fb.
2025-11-20 09:07:57 +09:00
Yu Watanabe
459000e8c5 errno-util: avoid double evaluation in STRERROR_OR_EOF()
Follow-up for f69ae8585f5ce6cd8d1e6f3ccd6c9c2cf153e846.
2025-11-20 09:04:35 +09:00
Yu Watanabe
18f280a478 test: fix tested function name
The test tests STRERROR_OR_EOF(), but logged as STRERROR_OR_ELSE.
2025-11-20 08:58:37 +09:00
Zbigniew Jędrzejewski-Szmek
6fc487564a meson: drop unnessary variable 2025-11-19 17:31:25 +01:00
48 changed files with 392 additions and 237 deletions

2
NEWS
View File

@ -80,7 +80,7 @@ CHANGES WITH 259 in spe:
conflict between /dev/disk/by-label/ symlinks is removed, as this conflict between /dev/disk/by-label/ symlinks is removed, as this
symlink is generated both for file system and LUKS superblock symlink is generated both for file system and LUKS superblock
labels. There's a new VolumeLabel= setting for partitions that can be labels. There's a new VolumeLabel= setting for partitions that can be
used to expicitly choose a LUKS superblock label, which can be used used to explicitly choose a LUKS superblock label, which can be used
to explicitly revert to the old naming, if required. to explicitly revert to the old naming, if required.
Service manager/PID1: Service manager/PID1:

View File

@ -2561,11 +2561,13 @@ foreach dict : executables
continue continue
endif endif
exe_sources = dict.get('sources', []) + dict.get('extract', [])
kwargs = {} kwargs = {}
foreach key, val : dict foreach key, val : dict
if key in ['name', 'dbus', 'public', 'conditions', if key in ['name', 'dbus', 'public', 'conditions',
'type', 'suite', 'timeout', 'parallel', 'type', 'suite', 'timeout', 'parallel',
'objects', 'extract'] 'objects', 'sources', 'extract']
continue continue
endif endif
@ -2596,12 +2598,17 @@ foreach dict : executables
if is_fuzz if is_fuzz
foreach key, val : fuzz_additional_kwargs foreach key, val : fuzz_additional_kwargs
kwargs += { key : [ kwargs.get(key, []), val ] } if key == 'sources'
exe_sources += val
else
kwargs += { key : [ kwargs.get(key, []), val ] }
endif
endforeach endforeach
endif endif
exe = executable( exe = executable(
name, name,
sources : exe_sources,
kwargs : kwargs, kwargs : kwargs,
implicit_include_directories : false, implicit_include_directories : false,
) )
@ -2609,7 +2616,7 @@ foreach dict : executables
executables_by_name += { name : exe } executables_by_name += { name : exe }
if not name.endswith('.standalone') if not name.endswith('.standalone')
sources += dict.get('sources', []) sources += exe_sources
endif endif
if dict.has_key('extract') if dict.has_key('extract')

View File

@ -1,7 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
bashcompletiondir = get_option('bashcompletiondir') bashcompletiondir = get_option('bashcompletiondir')
if bashcompletiondir == '' if bashcompletiondir == 'no'
subdir_done()
elif bashcompletiondir == ''
bash_completion = dependency('bash-completion', required : false) bash_completion = dependency('bash-completion', required : false)
if bash_completion.found() if bash_completion.found()
bashcompletiondir = bash_completion.get_variable(pkgconfig : 'completionsdir') bashcompletiondir = bash_completion.get_variable(pkgconfig : 'completionsdir')
@ -14,49 +16,51 @@ custom_target(
input : 'systemctl.in', input : 'systemctl.in',
output : 'systemctl', output : 'systemctl',
command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : bashcompletiondir != 'no', install : true,
install_dir : bashcompletiondir) install_dir : bashcompletiondir)
items = [['busctl', ''], foreach item : [
['journalctl', ''], ['bootctl', ''],
['systemd-analyze', ''], ['busctl', ''],
['systemd-cat', ''], ['coredumpctl', 'ENABLE_COREDUMP'],
['systemd-cgls', ''], ['homectl', 'ENABLE_HOMED'],
['systemd-cgtop', ''], ['hostnamectl', 'ENABLE_HOSTNAMED'],
['systemd-creds', ''], ['importctl', 'ENABLE_IMPORTD'],
['systemd-delta', ''], ['journalctl', ''],
['systemd-detect-virt', ''], ['kernel-install', 'ENABLE_KERNEL_INSTALL'],
['systemd-id128', ''], ['localectl', 'ENABLE_LOCALED'],
['systemd-nspawn', 'ENABLE_NSPAWN'], ['loginctl', 'ENABLE_LOGIND'],
['systemd-path', ''], ['machinectl', 'ENABLE_MACHINED'],
['systemd-run', ''], ['networkctl', 'ENABLE_NETWORKD'],
['systemd-vpick', ''], ['oomctl', 'ENABLE_OOMD'],
['udevadm', ''], ['portablectl', 'ENABLE_PORTABLED'],
['bootctl', ''], ['resolvectl', 'ENABLE_RESOLVE'],
['run0', ''], ['run0', ''],
['coredumpctl', 'ENABLE_COREDUMP'], ['systemd-analyze', ''],
['homectl', 'ENABLE_HOMED'], ['systemd-cat', ''],
['hostnamectl', 'ENABLE_HOSTNAMED'], ['systemd-cgls', ''],
['importctl', 'ENABLE_IMPORTD'], ['systemd-cgtop', ''],
['kernel-install', 'ENABLE_KERNEL_INSTALL'], ['systemd-confext', 'ENABLE_SYSEXT'],
['localectl', 'ENABLE_LOCALED'], ['systemd-creds', ''],
['loginctl', 'ENABLE_LOGIND'], ['systemd-cryptenroll', 'HAVE_LIBCRYPTSETUP'],
['machinectl', 'ENABLE_MACHINED'], ['systemd-delta', ''],
['networkctl', 'ENABLE_NETWORKD'], ['systemd-detect-virt', ''],
['oomctl', 'ENABLE_OOMD'], ['systemd-dissect', 'HAVE_BLKID'],
['portablectl', 'ENABLE_PORTABLED'], ['systemd-id128', ''],
['resolvectl', 'ENABLE_RESOLVE'], ['systemd-nspawn', 'ENABLE_NSPAWN'],
['systemd-cryptenroll', 'HAVE_LIBCRYPTSETUP'], ['systemd-path', ''],
['systemd-confext', 'ENABLE_SYSEXT'], ['systemd-resolve', 'ENABLE_RESOLVE'],
['systemd-dissect', 'HAVE_BLKID'], ['systemd-run', ''],
['systemd-resolve', 'ENABLE_RESOLVE'], ['systemd-sysext', 'ENABLE_SYSEXT'],
['systemd-sysext', 'ENABLE_SYSEXT'], ['systemd-vmspawn', 'ENABLE_VMSPAWN'],
['systemd-vmspawn', 'ENABLE_VMSPAWN'], ['systemd-vpick', ''],
['timedatectl', 'ENABLE_TIMEDATED'], ['timedatectl', 'ENABLE_TIMEDATED'],
['userdbctl', 'ENABLE_USERDB']] ['udevadm', ''],
['userdbctl', 'ENABLE_USERDB'],
['varlinkctl', ''],
]
foreach item : items if item[1] == '' or conf.get(item[1]) == 1
if bashcompletiondir != 'no' and (item[1] == '' or conf.get(item[1]) == 1)
install_data(item[0], install_data(item[0],
install_dir : bashcompletiondir) install_dir : bashcompletiondir)
endif endif

View File

@ -0,0 +1,117 @@
# shellcheck shell=bash
# varlinkctl(1) completion -*- shell-script -*-
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# systemd is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with systemd; If not, see <https://www.gnu.org/licenses/>.
__contains_word () {
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
}
__get_interfaces() {
local address=$1
local a
varlinkctl list-interfaces --no-pager "$address" 2>/dev/null |
{ while read -r a; do echo " $a"; done; }
}
__get_methods() {
local address=$1
local a
varlinkctl list-methods --no-pager "$address" 2>/dev/null |
{ while read -r a; do echo " $a"; done; }
}
_varlinkctl() {
local i n verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-h --help --version --no-pager -q --quiet
--oneway --collect --more --exec -j -E'
[ARG]='--graceful --timeout --push-fd --json'
)
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--json)
comps=$( varlinkctl --json=help 2>/dev/null )
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ "$cur" = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
local -A VERBS=(
[STANDALONE]='help'
[CALL]='call'
[FILE]='info list-interfaces validate-idl'
[ADDRESS_INTERFACES]='list-methods introspect'
)
for ((i=0; i < COMP_CWORD; i++)); do
if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
! __contains_word "${COMP_WORDS[i-1]}" ${OPTS[ARG]}; then
verb=${COMP_WORDS[i]}
break
fi
done
n=$((COMP_CWORD - i))
if [[ -z ${verb-} ]]; then
comps=${VERBS[*]}
elif __contains_word "$verb" ${VERBS[STANDALONE]}; then
comps=''
elif __contains_word "$verb" ${VERBS[FILE]}; then
comps=$(compgen -f -- "$cur")
compopt -o filenames
elif __contains_word "$verb" ${VERBS[ADDRESS_INTERFACES]}; then
if [[ $n -eq 1 ]] ; then
comps=$(compgen -f -- "$cur")
compopt -o filenames
elif [[ $n -eq 2 ]] ; then
comps=$( __get_interfaces ${COMP_WORDS[COMP_CWORD-1]})
else
comps=''
fi
elif __contains_word "$verb" ${VERBS[CALL]}; then
if [[ $n -eq 1 ]] ; then
comps=$(compgen -f -- "$cur")
compopt -o filenames
elif [[ $n -eq 2 ]] ; then
comps=$( __get_methods ${COMP_WORDS[COMP_CWORD-1]})
elif [[ $n -eq 3 ]] ; then
comps="'{}'"
elif [[ ${COMP_WORDS[COMP_CWORD-1]} == "--" ]] && __contains_word "--exec" ${COMP_WORDS[*]} ; then
comps=$(compgen -c -- "$cur")
else
comps=''
fi
fi
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
}
complete -F _varlinkctl varlinkctl

View File

@ -1,7 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
zshcompletiondir = get_option('zshcompletiondir') zshcompletiondir = get_option('zshcompletiondir')
if zshcompletiondir == '' if zshcompletiondir == 'no'
subdir_done()
elif zshcompletiondir == ''
zshcompletiondir = datadir / 'zsh/site-functions' zshcompletiondir = datadir / 'zsh/site-functions'
endif endif
@ -9,41 +11,42 @@ custom_target(
input : '_systemctl.in', input : '_systemctl.in',
output : '_systemctl', output : '_systemctl',
command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'], command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
install : zshcompletiondir != 'no', install : true,
install_dir : zshcompletiondir) install_dir : zshcompletiondir)
items = [['_busctl', ''], foreach item : [
['_journalctl', ''], ['_bootctl', ''],
['_systemd-analyze', ''], ['_busctl', ''],
['_systemd-delta', ''], ['_coredumpctl', 'ENABLE_COREDUMP'],
['_systemd-nspawn', ''], ['_hostnamectl', 'ENABLE_HOSTNAMED'],
['_systemd', ''], ['_journalctl', ''],
['_systemd-path', ''], ['_kernel-install', 'ENABLE_KERNEL_INSTALL'],
['_systemd-run', ''], ['_localectl', 'ENABLE_LOCALED'],
['_run0', ''], ['_loginctl', 'ENABLE_LOGIND'],
['_udevadm', ''], ['_machinectl', 'ENABLE_MACHINED'],
['_varlinkctl', ''], ['_networkctl', 'ENABLE_NETWORKD'],
['_kernel-install', 'ENABLE_KERNEL_INSTALL'], ['_oomctl', 'ENABLE_OOMD'],
['_sd_bus_address', ''], ['_resolvectl', 'ENABLE_RESOLVE'],
['_sd_hosts_or_user_at_host', ''], ['_run0', ''],
['_sd_outputmodes', ''], ['_sd_bus_address', ''],
['_sd_unit_files', ''], ['_sd_hosts_or_user_at_host', ''],
['_sd_machines', ''], ['_sd_machines', ''],
['_bootctl', ''], ['_sd_outputmodes', ''],
['_coredumpctl', 'ENABLE_COREDUMP'], ['_sd_unit_files', ''],
['_hostnamectl', 'ENABLE_HOSTNAMED'], ['_systemd', ''],
['_localectl', 'ENABLE_LOCALED'], ['_systemd-analyze', ''],
['_loginctl', 'ENABLE_LOGIND'], ['_systemd-delta', ''],
['_machinectl', 'ENABLE_MACHINED'], ['_systemd-inhibit', 'ENABLE_LOGIND'],
['_networkctl', 'ENABLE_NETWORKD'], ['_systemd-nspawn', ''],
['_oomctl', 'ENABLE_OOMD'], ['_systemd-path', ''],
['_systemd-inhibit', 'ENABLE_LOGIND'], ['_systemd-run', ''],
['_resolvectl', 'ENABLE_RESOLVE'], ['_systemd-tmpfiles', 'ENABLE_TMPFILES'],
['_systemd-tmpfiles', 'ENABLE_TMPFILES'], ['_timedatectl', 'ENABLE_TIMEDATED'],
['_timedatectl', 'ENABLE_TIMEDATED']] ['_udevadm', ''],
['_varlinkctl', ''],
]
foreach item : items if item[1] == '' or conf.get(item[1]) == 1
if zshcompletiondir != 'no' and (item[1] == '' or conf.get(item[1]) == 1)
install_data(item[0], install_data(item[0],
install_dir : zshcompletiondir) install_dir : zshcompletiondir)
endif endif

View File

@ -48,7 +48,7 @@ executables += [
executable_template + { executable_template + {
'name' : 'systemd-analyze', 'name' : 'systemd-analyze',
'public' : conf.get('ENABLE_ANALYZE') == 1, 'public' : conf.get('ENABLE_ANALYZE') == 1,
'sources' : systemd_analyze_sources + systemd_analyze_extract_sources, 'sources' : systemd_analyze_sources,
'extract' : systemd_analyze_extract_sources, 'extract' : systemd_analyze_extract_sources,
'include_directories' : core_includes, 'include_directories' : core_includes,
'link_with' : [ 'link_with' : [

10
src/basic/errno-util.c Normal file
View File

@ -0,0 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "errno-util.h"
const char* strerror_or_eof(int errnum, char *buf, size_t buflen) {
if (errnum != 0)
return strerror_r(ABS(errnum), buf, buflen);
return "Unexpected EOF";
}

View File

@ -15,10 +15,9 @@
* Note that we use the GNU variant of strerror_r() here. */ * Note that we use the GNU variant of strerror_r() here. */
#define STRERROR(errnum) strerror_r(ABS(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN) #define STRERROR(errnum) strerror_r(ABS(errnum), (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
/* A helper to print an error message or message for functions that return 0 on EOF. /* A helper to print an error message or message for functions that return 0 on EOF. */
* Note that we can't use ({ }) to define a temporary variable, so errnum is const char* strerror_or_eof(int errnum, char *buf, size_t buflen);
* evaluated twice. */ #define STRERROR_OR_EOF(errnum) strerror_or_eof(errnum, (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
#define STRERROR_OR_EOF(errnum) ((errnum) != 0 ? STRERROR(errnum) : "Unexpected EOF")
static inline void _reset_errno_(int *saved_errno) { static inline void _reset_errno_(int *saved_errno) {
if (*saved_errno < 0) /* Invalidated by UNPROTECT_ERRNO? */ if (*saved_errno < 0) /* Invalidated by UNPROTECT_ERRNO? */

View File

@ -31,6 +31,7 @@ basic_sources = files(
'env-file.c', 'env-file.c',
'env-util.c', 'env-util.c',
'errno-list.c', 'errno-list.c',
'errno-util.c',
'escape.c', 'escape.c',
'ether-addr-util.c', 'ether-addr-util.c',
'extract-word.c', 'extract-word.c',

View File

@ -669,26 +669,6 @@ static const char* const netlink_family_table[] = {
DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(netlink_family, int, INT_MAX); DEFINE_STRING_TABLE_LOOKUP_WITH_FALLBACK(netlink_family, int, INT_MAX);
static const char* const socket_address_bind_ipv6_only_table[_SOCKET_ADDRESS_BIND_IPV6_ONLY_MAX] = {
[SOCKET_ADDRESS_DEFAULT] = "default",
[SOCKET_ADDRESS_BOTH] = "both",
[SOCKET_ADDRESS_IPV6_ONLY] = "ipv6-only"
};
DEFINE_STRING_TABLE_LOOKUP(socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_or_bool_from_string(const char *n) {
int r;
r = parse_boolean(n);
if (r > 0)
return SOCKET_ADDRESS_IPV6_ONLY;
if (r == 0)
return SOCKET_ADDRESS_BOTH;
return socket_address_bind_ipv6_only_from_string(n);
}
bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b) { bool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b) {
assert(a); assert(a);
assert(b); assert(b);

View File

@ -53,14 +53,6 @@ typedef struct SocketAddress {
int protocol; int protocol;
} SocketAddress; } SocketAddress;
typedef enum SocketAddressBindIPv6Only {
SOCKET_ADDRESS_DEFAULT,
SOCKET_ADDRESS_BOTH,
SOCKET_ADDRESS_IPV6_ONLY,
_SOCKET_ADDRESS_BIND_IPV6_ONLY_MAX,
_SOCKET_ADDRESS_BIND_IPV6_ONLY_INVALID = -EINVAL,
} SocketAddressBindIPv6Only;
#define socket_address_family(a) ((a)->sockaddr.sa.sa_family) #define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
const char* socket_address_type_to_string(int t) _const_; const char* socket_address_type_to_string(int t) _const_;
@ -74,19 +66,6 @@ static inline int socket_address_unlink(const SocketAddress *a) {
bool socket_address_can_accept(const SocketAddress *a) _pure_; bool socket_address_can_accept(const SocketAddress *a) _pure_;
int socket_address_listen(
const SocketAddress *a,
int flags,
int backlog,
SocketAddressBindIPv6Only only,
const char *bind_to_device,
bool reuse_port,
bool free_bind,
bool transparent,
mode_t directory_mode,
mode_t socket_mode,
const char *label);
int socket_address_verify(const SocketAddress *a, bool strict) _pure_; int socket_address_verify(const SocketAddress *a, bool strict) _pure_;
int socket_address_print(const SocketAddress *a, char **p); int socket_address_print(const SocketAddress *a, char **p);
bool socket_address_matches_fd(const SocketAddress *a, int fd); bool socket_address_matches_fd(const SocketAddress *a, int fd);
@ -108,10 +87,6 @@ int getsockname_pretty(int fd, char **ret);
int socknameinfo_pretty(const struct sockaddr *sa, socklen_t salen, char **_ret); int socknameinfo_pretty(const struct sockaddr *sa, socklen_t salen, char **_ret);
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_or_bool_from_string(const char *s);
int netlink_family_to_string_alloc(int b, char **s); int netlink_family_to_string_alloc(int b, char **s);
int netlink_family_from_string(const char *s) _pure_; int netlink_family_from_string(const char *s) _pure_;

View File

@ -28,6 +28,26 @@
#include "user-util.h" #include "user-util.h"
#include "utf8.h" #include "utf8.h"
#define DEFINE_STRERROR_ACCOUNT(type) \
const char* strerror_##type( \
int errnum, \
char *buf, \
size_t buflen) { \
\
errnum = ABS(errnum); \
switch (errnum) { \
case ESRCH: \
return "Unknown " STRINGIFY(type); \
case ENOEXEC: \
return "Not a system " STRINGIFY(type); \
default: \
return strerror_r(errnum, buf, buflen); \
} \
}
DEFINE_STRERROR_ACCOUNT(user);
DEFINE_STRERROR_ACCOUNT(group);
bool uid_is_valid(uid_t uid) { bool uid_is_valid(uid_t uid) {
/* Also see POSIX IEEE Std 1003.1-2008, 2016 Edition, 3.436. */ /* Also see POSIX IEEE Std 1003.1-2008, 2016 Edition, 3.436. */

View File

@ -20,11 +20,11 @@
#define MAP_UID_MIN ((uid_t) 60514) #define MAP_UID_MIN ((uid_t) 60514)
#define MAP_UID_MAX ((uid_t) 60577) #define MAP_UID_MAX ((uid_t) 60577)
/* A helper to print an error message when user or group resolution fails. /* A helper to print an error message when user or group resolution fails. */
* Note that we can't use ({ }) to define a temporary variable, so errnum is const char* strerror_user(int errnum, char *buf, size_t buflen);
* evaluated multiple times. */ #define STRERROR_USER(errnum) strerror_user(errnum, (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
#define STRERROR_USER(errnum) ((errnum) == -ESRCH ? "Unknown user" : (errnum) == -ENOEXEC ? "Not a system user" : STRERROR(errnum)) const char* strerror_group(int errnum, char *buf, size_t buflen);
#define STRERROR_GROUP(errnum) ((errnum) == -ESRCH ? "Unknown group" : (errnum) == -ENOEXEC ? "Not a system group" : STRERROR(errnum)) #define STRERROR_GROUP(errnum) strerror_group(errnum, (char[ERRNO_BUF_LEN]){}, ERRNO_BUF_LEN)
static inline bool ERRNO_IS_NEG_BAD_ACCOUNT(intmax_t r) { static inline bool ERRNO_IS_NEG_BAD_ACCOUNT(intmax_t r) {
return IN_SET(r, return IN_SET(r,

View File

@ -11,7 +11,7 @@ executables += [
executable_template + { executable_template + {
'name' : 'busctl', 'name' : 'busctl',
'public' : true, 'public' : true,
'sources' : busctl_sources + busctl_extract_sources, 'sources' : busctl_sources,
'extract' : busctl_extract_sources, 'extract' : busctl_extract_sources,
}, },
test_template + { test_template + {

View File

@ -1504,7 +1504,7 @@ static int socket_determine_selinux_label(Socket *s, char **ret) {
static int socket_address_listen_do( static int socket_address_listen_do(
Socket *s, Socket *s,
const SocketAddress *address, const SocketAddress *address,
const char *label) { const char *selinux_label) {
assert(s); assert(s);
assert(address); assert(address);
@ -1520,7 +1520,8 @@ static int socket_address_listen_do(
s->transparent, s->transparent,
s->directory_mode, s->directory_mode,
s->socket_mode, s->socket_mode,
label); selinux_label,
s->smack);
} }
#define log_address_error_errno(u, address, error, fmt) \ #define log_address_error_errno(u, address, error, fmt) \

View File

@ -6,6 +6,7 @@
#include "execute.h" #include "execute.h"
#include "list.h" #include "list.h"
#include "pidref.h" #include "pidref.h"
#include "socket-label.h"
#include "socket-util.h" #include "socket-util.h"
#include "unit.h" #include "unit.h"

View File

@ -36,7 +36,7 @@ common_dependencies = [
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-coredump', 'name' : 'systemd-coredump',
'sources' : systemd_coredump_sources + systemd_coredump_extract_sources, 'sources' : systemd_coredump_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')], 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'extract' : systemd_coredump_extract_sources, 'extract' : systemd_coredump_extract_sources,
'link_with' : [libshared], 'link_with' : [libshared],

View File

@ -7,10 +7,7 @@ endif
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-hibernate-resume', 'name' : 'systemd-hibernate-resume',
'sources' : files( 'sources' : files('hibernate-resume.c'),
'hibernate-resume.c',
'hibernate-resume-config.c',
),
'extract' : files('hibernate-resume-config.c'), 'extract' : files('hibernate-resume-config.c'),
}, },
generator_template + { generator_template + {

View File

@ -61,10 +61,10 @@ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-homed', 'name' : 'systemd-homed',
'dbus' : true, 'dbus' : true,
'sources' : systemd_homed_sources + systemd_homed_extract_sources, 'sources' : systemd_homed_sources,
'extract' : systemd_homed_extract_sources,
'include_directories' : includes + 'include_directories' : includes +
include_directories('.'), include_directories('.'),
'extract' : systemd_homed_extract_sources,
'dependencies' : [ 'dependencies' : [
libcrypt, libcrypt,
libm, libm,

View File

@ -50,7 +50,7 @@ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-importd', 'name' : 'systemd-importd',
'dbus' : true, 'dbus' : true,
'sources' : systemd_importd_sources + systemd_importd_extract_sources, 'sources' : systemd_importd_sources,
'extract' : systemd_importd_extract_sources, 'extract' : systemd_importd_extract_sources,
'dependencies' : [common_deps, threads], 'dependencies' : [common_deps, threads],
}, },

View File

@ -7,10 +7,7 @@ endif
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-integritysetup', 'name' : 'systemd-integritysetup',
'sources' : files( 'sources' : files('integritysetup.c'),
'integrity-util.c',
'integritysetup.c',
),
'extract' : files('integrity-util.c'), 'extract' : files('integrity-util.c'),
'dependencies' : libcryptsetup, 'dependencies' : libcryptsetup,
}, },

View File

@ -39,7 +39,7 @@ executables += [
'ENABLE_REMOTE', 'ENABLE_REMOTE',
'HAVE_MICROHTTPD', 'HAVE_MICROHTTPD',
], ],
'sources' : systemd_journal_gatewayd_sources + systemd_journal_gatewayd_extract_sources, 'sources' : systemd_journal_gatewayd_sources,
'extract' : systemd_journal_gatewayd_extract_sources, 'extract' : systemd_journal_gatewayd_extract_sources,
'dependencies' : common_deps + [libmicrohttpd], 'dependencies' : common_deps + [libmicrohttpd],
}, },
@ -50,9 +50,9 @@ executables += [
# fuzz-journal-remote even when --auto-features=disabled (see tools/oss-fuzz.sh for why). # fuzz-journal-remote even when --auto-features=disabled (see tools/oss-fuzz.sh for why).
# Instead, we make sure we don't install it when the remote feature is disabled. # Instead, we make sure we don't install it when the remote feature is disabled.
'install' : conf.get('ENABLE_REMOTE') == 1, 'install' : conf.get('ENABLE_REMOTE') == 1,
'sources' : systemd_journal_remote_sources + systemd_journal_remote_extract_sources, 'sources' : systemd_journal_remote_sources,
'objects' : conf.get('HAVE_MICROHTTPD') == 1 ? ['systemd-journal-gatewayd'] : [],
'extract' : systemd_journal_remote_extract_sources, 'extract' : systemd_journal_remote_extract_sources,
'objects' : conf.get('HAVE_MICROHTTPD') == 1 ? ['systemd-journal-gatewayd'] : [],
'dependencies' : common_deps + [libmicrohttpd], 'dependencies' : common_deps + [libmicrohttpd],
}, },
libexec_template + { libexec_template + {
@ -62,9 +62,9 @@ executables += [
'ENABLE_REMOTE', 'ENABLE_REMOTE',
'HAVE_LIBCURL', 'HAVE_LIBCURL',
], ],
'sources' : systemd_journal_upload_sources + systemd_journal_upload_extract_sources, 'sources' : systemd_journal_upload_sources,
'objects' : ['systemd-journal-remote'],
'extract' : systemd_journal_upload_extract_sources, 'extract' : systemd_journal_upload_extract_sources,
'objects' : ['systemd-journal-remote'],
'dependencies' : common_deps + [libcurl], 'dependencies' : common_deps + [libcurl],
}, },
test_template + { test_template + {

View File

@ -64,9 +64,9 @@ journal_fuzz_template = fuzz_template + {
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-journald', 'name' : 'systemd-journald',
'sources' : systemd_journald_sources + systemd_journald_extract_sources, 'sources' : systemd_journald_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'extract' : systemd_journald_extract_sources, 'extract' : systemd_journald_extract_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'dependencies' : [ 'dependencies' : [
liblz4_cflags, liblz4_cflags,
libselinux_cflags, libselinux_cflags,

View File

@ -93,10 +93,7 @@ executables += [
'sources' : files('test-lldp-rx.c'), 'sources' : files('test-lldp-rx.c'),
}, },
network_test_template + { network_test_template + {
'sources' : files( 'sources' : files('test-ndisc-ra.c'),
'test-ndisc-ra.c',
'icmp6-test-util.c',
),
'extract' : files('icmp6-test-util.c'), 'extract' : files('icmp6-test-util.c'),
}, },
network_test_template + { network_test_template + {

View File

@ -29,7 +29,7 @@ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-localed', 'name' : 'systemd-localed',
'dbus' : true, 'dbus' : true,
'sources' : systemd_localed_sources + systemd_localed_extract_sources, 'sources' : systemd_localed_sources,
'extract' : systemd_localed_extract_sources, 'extract' : systemd_localed_extract_sources,
'dependencies' : libxkbcommon_deps, 'dependencies' : libxkbcommon_deps,
}, },

View File

@ -45,9 +45,9 @@ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-logind', 'name' : 'systemd-logind',
'dbus' : true, 'dbus' : true,
'sources' : systemd_logind_sources + systemd_logind_extract_sources, 'sources' : systemd_logind_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'extract' : systemd_logind_extract_sources, 'extract' : systemd_logind_extract_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'dependencies' : [ 'dependencies' : [
threads, threads,
], ],

View File

@ -25,7 +25,7 @@ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-machined', 'name' : 'systemd-machined',
'dbus' : true, 'dbus' : true,
'sources' : systemd_machined_sources + systemd_machined_extract_sources, 'sources' : systemd_machined_sources,
'extract' : systemd_machined_extract_sources, 'extract' : systemd_machined_extract_sources,
}, },
executable_template + { executable_template + {

View File

@ -198,7 +198,7 @@ executables += [
'name' : 'systemd-networkd', 'name' : 'systemd-networkd',
'dbus' : true, 'dbus' : true,
'conditions' : ['ENABLE_NETWORKD'], 'conditions' : ['ENABLE_NETWORKD'],
'sources' : systemd_networkd_sources + systemd_networkd_extract_sources, 'sources' : systemd_networkd_sources,
'extract' : systemd_networkd_extract_sources, 'extract' : systemd_networkd_extract_sources,
'include_directories' : network_includes, 'include_directories' : network_includes,
'link_with' : [ 'link_with' : [
@ -227,7 +227,7 @@ executables += [
}, },
libexec_template + { libexec_template + {
'name' : 'systemd-network-generator', 'name' : 'systemd-network-generator',
'sources' : files('generator/network-generator.c', 'generator/network-generator-main.c'), 'sources' : files('generator/network-generator-main.c'),
'extract' : files('generator/network-generator.c'), 'extract' : files('generator/network-generator.c'),
'link_with' : networkd_link_with, 'link_with' : networkd_link_with,
}, },

View File

@ -40,12 +40,12 @@ executables += [
executable_template + { executable_template + {
'name' : 'systemd-nspawn', 'name' : 'systemd-nspawn',
'public' : true, 'public' : true,
'sources' : nspawn_sources + nspawn_extract_sources, 'sources' : nspawn_sources,
'extract' : nspawn_extract_sources,
'include_directories' : [ 'include_directories' : [
executable_template['include_directories'], executable_template['include_directories'],
include_directories('.') include_directories('.')
], ],
'extract' : nspawn_extract_sources,
'dependencies' : [ 'dependencies' : [
libseccomp_cflags, libseccomp_cflags,
libselinux_cflags, libselinux_cflags,

View File

@ -30,9 +30,9 @@ endif
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-nsresourced', 'name' : 'systemd-nsresourced',
'sources' : systemd_nsresourced_sources + systemd_nsresourced_extract_sources, 'sources' : systemd_nsresourced_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'extract' : systemd_nsresourced_extract_sources, 'extract' : systemd_nsresourced_extract_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'dependencies' : threads, 'dependencies' : threads,
}, },
libexec_template + { libexec_template + {

View File

@ -18,7 +18,7 @@ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-oomd', 'name' : 'systemd-oomd',
'dbus' : true, 'dbus' : true,
'sources' : systemd_oomd_sources + systemd_oomd_extract_sources, 'sources' : systemd_oomd_sources,
'extract' : systemd_oomd_extract_sources, 'extract' : systemd_oomd_extract_sources,
'dependencies' : libatomic, 'dependencies' : libatomic,
}, },

View File

@ -81,9 +81,9 @@ executables += [
libexec_template + resolve_common_template + { libexec_template + resolve_common_template + {
'name' : 'systemd-resolved', 'name' : 'systemd-resolved',
'dbus' : true, 'dbus' : true,
'sources' : systemd_resolved_sources + systemd_resolved_extract_sources, 'sources' : systemd_resolved_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'extract' : systemd_resolved_extract_sources, 'extract' : systemd_resolved_extract_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
}, },
executable_template + resolve_common_template + { executable_template + resolve_common_template + {
'name' : 'resolvectl', 'name' : 'resolvectl',

View File

@ -8,10 +8,34 @@
#include "fs-util.h" #include "fs-util.h"
#include "log.h" #include "log.h"
#include "mkdir-label.h" #include "mkdir-label.h"
#include "parse-util.h"
#include "selinux-util.h" #include "selinux-util.h"
#include "smack-util.h"
#include "socket-label.h"
#include "socket-util.h" #include "socket-util.h"
#include "string-table.h"
#include "umask-util.h" #include "umask-util.h"
static const char* const socket_address_bind_ipv6_only_table[_SOCKET_ADDRESS_BIND_IPV6_ONLY_MAX] = {
[SOCKET_ADDRESS_DEFAULT] = "default",
[SOCKET_ADDRESS_BOTH] = "both",
[SOCKET_ADDRESS_IPV6_ONLY] = "ipv6-only"
};
DEFINE_STRING_TABLE_LOOKUP(socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_or_bool_from_string(const char *n) {
int r;
r = parse_boolean(n);
if (r > 0)
return SOCKET_ADDRESS_IPV6_ONLY;
if (r == 0)
return SOCKET_ADDRESS_BOTH;
return socket_address_bind_ipv6_only_from_string(n);
}
int socket_address_listen( int socket_address_listen(
const SocketAddress *a, const SocketAddress *a,
int flags, int flags,
@ -23,7 +47,8 @@ int socket_address_listen(
bool transparent, bool transparent,
mode_t directory_mode, mode_t directory_mode,
mode_t socket_mode, mode_t socket_mode,
const char *label) { const char *selinux_label,
const char *smack_label) {
_cleanup_close_ int fd = -EBADF; _cleanup_close_ int fd = -EBADF;
const char *p; const char *p;
@ -38,20 +63,26 @@ int socket_address_listen(
if (socket_address_family(a) == AF_INET6 && !socket_ipv6_is_supported()) if (socket_address_family(a) == AF_INET6 && !socket_ipv6_is_supported())
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
if (label) { if (selinux_label) {
r = mac_selinux_create_socket_prepare(label); r = mac_selinux_create_socket_prepare(selinux_label);
if (r < 0) if (r < 0)
return r; return r;
} }
fd = RET_NERRNO(socket(socket_address_family(a), a->type | flags, a->protocol)); fd = RET_NERRNO(socket(socket_address_family(a), a->type | flags, a->protocol));
if (label) if (selinux_label)
mac_selinux_create_socket_clear(); mac_selinux_create_socket_clear();
if (fd < 0) if (fd < 0)
return fd; return fd;
if (smack_label) {
r = mac_smack_apply_fd(fd, SMACK_ATTR_ACCESS, smack_label);
if (r < 0)
log_warning_errno(r, "Failed to apply SMACK label for socket FD, ignoring: %m");
}
if (socket_address_family(a) == AF_INET6 && only != SOCKET_ADDRESS_DEFAULT) { if (socket_address_family(a) == AF_INET6 && only != SOCKET_ADDRESS_DEFAULT) {
r = setsockopt_int(fd, IPPROTO_IPV6, IPV6_V6ONLY, only == SOCKET_ADDRESS_IPV6_ONLY); r = setsockopt_int(fd, IPPROTO_IPV6, IPV6_V6ONLY, only == SOCKET_ADDRESS_IPV6_ONLY);
if (r < 0) if (r < 0)
@ -107,6 +138,11 @@ int socket_address_listen(
if (r < 0) if (r < 0)
return r; return r;
} }
if (smack_label) {
r = mac_smack_apply(p, SMACK_ATTR_ACCESS, smack_label);
if (r < 0)
log_warning_errno(r, "Failed to apply SMACK label for socket path, ignoring: %m");
}
} else { } else {
if (bind(fd, &a->sockaddr.sa, a->size) < 0) if (bind(fd, &a->sockaddr.sa, a->size) < 0)
return -errno; return -errno;

30
src/shared/socket-label.h Normal file
View File

@ -0,0 +1,30 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "shared-forward.h"
typedef enum SocketAddressBindIPv6Only {
SOCKET_ADDRESS_DEFAULT,
SOCKET_ADDRESS_BOTH,
SOCKET_ADDRESS_IPV6_ONLY,
_SOCKET_ADDRESS_BIND_IPV6_ONLY_MAX,
_SOCKET_ADDRESS_BIND_IPV6_ONLY_INVALID = -EINVAL,
} SocketAddressBindIPv6Only;
const char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
SocketAddressBindIPv6Only socket_address_bind_ipv6_only_or_bool_from_string(const char *s);
int socket_address_listen(
const SocketAddress *a,
int flags,
int backlog,
SocketAddressBindIPv6Only only,
const char *bind_to_device,
bool reuse_port,
bool free_bind,
bool transparent,
mode_t directory_mode,
mode_t socket_mode,
const char *selinux_label,
const char *smack_label);

View File

@ -15,6 +15,7 @@
#include "netlink-sock-diag.h" #include "netlink-sock-diag.h"
#include "netlink-util.h" #include "netlink-util.h"
#include "parse-util.h" #include "parse-util.h"
#include "socket-label.h"
#include "socket-netlink.h" #include "socket-netlink.h"
#include "socket-util.h" #include "socket-util.h"
#include "string-util.h" #include "string-util.h"
@ -183,8 +184,18 @@ int make_socket_fd(int log_level, const char* address, int type, int flags) {
a.type = type; a.type = type;
fd = socket_address_listen(&a, type | flags, SOMAXCONN_DELUXE, SOCKET_ADDRESS_DEFAULT, fd = socket_address_listen(
NULL, false, false, false, 0755, 0644, NULL); &a,
type | flags,
SOMAXCONN_DELUXE, SOCKET_ADDRESS_DEFAULT,
/* bind_to_device= */ NULL,
/* reuse_port= */ false,
/* free_bind= */ false,
/* transparent= */ false,
0755,
0644,
/* selinux_label= */ NULL,
/* smack_label= */ NULL);
if (fd < 0 || log_get_max_level() >= log_level) { if (fd < 0 || log_get_max_level() >= log_level) {
_cleanup_free_ char *p = NULL; _cleanup_free_ char *p = NULL;

View File

@ -14,7 +14,7 @@ systemd_shutdown_extract_sources = files(
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-shutdown', 'name' : 'systemd-shutdown',
'sources' : systemd_shutdown_sources + systemd_shutdown_extract_sources, 'sources' : systemd_shutdown_sources,
'extract' : systemd_shutdown_extract_sources, 'extract' : systemd_shutdown_extract_sources,
'dependencies' : libmount_cflags, 'dependencies' : libmount_cflags,
}, },

View File

@ -1,18 +1,11 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
sleep_sources = files(
'sleep.c',
)
sleep_extract_sources = files(
'battery-capacity.c',
)
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-sleep', 'name' : 'systemd-sleep',
'sources' : sleep_sources + sleep_extract_sources, 'sources' : files('sleep.c'),
'extract' : files('battery-capacity.c'),
'include_directories' : [libexec_template['include_directories'], include_directories('.')], 'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'extract' : sleep_extract_sources,
}, },
test_template + { test_template + {
'sources' : files('test-battery-capacity.c'), 'sources' : files('test-battery-capacity.c'),

View File

@ -3,25 +3,16 @@
executables += [ executables += [
generator_template + { generator_template + {
'name' : 'systemd-ssh-generator', 'name' : 'systemd-ssh-generator',
'sources' : files( 'sources' : files('ssh-generator.c'),
'ssh-generator.c', 'extract' : files('ssh-util.c'),
'ssh-util.c',
),
'extract' : files(
'ssh-util.c',
),
}, },
libexec_template + { libexec_template + {
'name' : 'systemd-ssh-proxy', 'name' : 'systemd-ssh-proxy',
'sources' : files( 'sources' : files('ssh-proxy.c'),
'ssh-proxy.c',
),
}, },
libexec_template + { libexec_template + {
'name' : 'systemd-ssh-issue', 'name' : 'systemd-ssh-issue',
'sources' : files( 'sources' : files('ssh-issue.c'),
'ssh-issue.c',
),
'objects' : ['systemd-ssh-generator'], 'objects' : ['systemd-ssh-generator'],
}, },
] ]

View File

@ -52,7 +52,7 @@ executables += [
executable_template + { executable_template + {
'name' : 'systemctl', 'name' : 'systemctl',
'public' : true, 'public' : true,
'sources' : systemctl_sources + systemctl_extract_sources, 'sources' : systemctl_sources,
'extract' : systemctl_extract_sources, 'extract' : systemctl_extract_sources,
'link_with' : systemctl_link_with, 'link_with' : systemctl_link_with,
'dependencies' : [ 'dependencies' : [

View File

@ -25,7 +25,7 @@ executables += [
'name' : 'systemd-sysupdate', 'name' : 'systemd-sysupdate',
'public' : true, 'public' : true,
'conditions' : ['ENABLE_SYSUPDATE'], 'conditions' : ['ENABLE_SYSUPDATE'],
'sources' : systemd_sysupdate_sources + systemd_sysupdate_extract_sources, 'sources' : systemd_sysupdate_sources,
'extract' : systemd_sysupdate_extract_sources, 'extract' : systemd_sysupdate_extract_sources,
'link_with' : [ 'link_with' : [
libshared, libshared,

View File

@ -1,8 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
awkscript = 'test-hashmap-ordered.awk'
test_hashmap_ordered_c = custom_target( test_hashmap_ordered_c = custom_target(
input : [awkscript, 'test-hashmap-plain.c'], input : ['test-hashmap-ordered.awk', 'test-hashmap-plain.c'],
output : 'test-hashmap-ordered.c', output : 'test-hashmap-ordered.c',
command : [awk, '-f', '@INPUT0@', '@INPUT1@'], command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
capture : true, capture : true,
@ -382,10 +381,7 @@ executables += [
'type' : 'manual', 'type' : 'manual',
}, },
test_template + { test_template + {
'sources' : files( 'sources' : files('test-nss-hosts.c'),
'test-nss-hosts.c',
'nss-test-util.c',
),
'extract' : files('nss-test-util.c'), 'extract' : files('nss-test-util.c'),
'dependencies' : [ 'dependencies' : [
libdl, libdl,
@ -490,13 +486,13 @@ executables += [
# Symbol tests # Symbol tests
test_template + { test_template + {
'name' : 'test-libsystemd-sym', 'name' : 'test-libsystemd-sym',
'sources' : test_libsystemd_sym_c, 'sources' : [test_libsystemd_sym_c],
'link_with' : libsystemd, 'link_with' : libsystemd,
'suite' : 'libsystemd', 'suite' : 'libsystemd',
}, },
test_template + { test_template + {
'name' : 'test-libudev-sym', 'name' : 'test-libudev-sym',
'sources' : test_libudev_sym_c, 'sources' : [test_libudev_sym_c],
'include_directories' : libudev_includes, 'include_directories' : libudev_includes,
'c_args' : ['-Wno-deprecated-declarations'] + test_cflags, 'c_args' : ['-Wno-deprecated-declarations'] + test_cflags,
'link_with' : libudev, 'link_with' : libudev,
@ -654,7 +650,7 @@ if static_libsystemd != 'false'
executables += [ executables += [
test_template + { test_template + {
'name' : 'test-libsystemd-static-sym', 'name' : 'test-libsystemd-static-sym',
'sources' : test_libsystemd_sym_c, 'sources' : [test_libsystemd_sym_c],
'link_with' : install_libsystemd_static, 'link_with' : install_libsystemd_static,
'build_by_default' : want_tests != 'false', 'build_by_default' : want_tests != 'false',
'install' : install_tests, 'install' : install_tests,
@ -667,7 +663,7 @@ if static_libudev != 'false'
executables += [ executables += [
test_template + { test_template + {
'name' : 'test-libudev-static-sym', 'name' : 'test-libudev-static-sym',
'sources' : test_libudev_sym_c, 'sources' : [test_libudev_sym_c],
'include_directories' : libudev_includes, 'include_directories' : libudev_includes,
'c_args' : ['-Wno-deprecated-declarations'] + test_cflags, 'c_args' : ['-Wno-deprecated-declarations'] + test_cflags,
'link_with' : install_libudev_static, 'link_with' : install_libudev_static,

View File

@ -40,10 +40,10 @@ TEST(STRERROR) {
ASSERT_NOT_NULL(strstr(c, buf)); ASSERT_NOT_NULL(strstr(c, buf));
} }
TEST(STRERROR_OR_ELSE) { TEST(STRERROR_OR_EOF) {
log_info("STRERROR_OR_ELSE(0, \"EOF\") → %s", STRERROR_OR_EOF(0)); log_info("STRERROR_OR_EOF(0, \"EOF\") → %s", STRERROR_OR_EOF(0));
log_info("STRERROR_OR_ELSE(EPERM, \"EOF\") → %s", STRERROR_OR_EOF(EPERM)); log_info("STRERROR_OR_EOF(EPERM, \"EOF\") → %s", STRERROR_OR_EOF(EPERM));
log_info("STRERROR_OR_ELSE(-EPERM, \"EOF\") → %s", STRERROR_OR_EOF(-EPERM)); log_info("STRERROR_OR_EOF(-EPERM, \"EOF\") → %s", STRERROR_OR_EOF(-EPERM));
} }
TEST(PROTECT_ERRNO) { TEST(PROTECT_ERRNO) {

View File

@ -29,6 +29,7 @@
#include "service.h" #include "service.h"
#include "show-status.h" #include "show-status.h"
#include "socket.h" #include "socket.h"
#include "socket-label.h"
#include "socket-util.h" #include "socket-util.h"
#include "swap.h" #include "swap.h"
#include "test-tables.h" #include "test-tables.h"

View File

@ -32,9 +32,9 @@ endif
executables += [ executables += [
libexec_template + { libexec_template + {
'name' : 'systemd-timesyncd', 'name' : 'systemd-timesyncd',
'sources' : timesyncd_sources + timesyncd_extract_sources, 'sources' : timesyncd_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'extract' : timesyncd_extract_sources, 'extract' : timesyncd_extract_sources,
'include_directories' : [libexec_template['include_directories'], include_directories('.')],
'link_with' : timesyncd_link_with, 'link_with' : timesyncd_link_with,
'dependencies' : [ 'dependencies' : [
libm, libm,

View File

@ -15,7 +15,7 @@ executables += [
executable_template + { executable_template + {
'name' : 'systemd-tmpfiles', 'name' : 'systemd-tmpfiles',
'public' : true, 'public' : true,
'sources' : systemd_tmpfiles_sources + systemd_tmpfiles_extract_sources, 'sources' : systemd_tmpfiles_sources,
'extract' : systemd_tmpfiles_extract_sources, 'extract' : systemd_tmpfiles_extract_sources,
'dependencies' : libacl_cflags, 'dependencies' : libacl_cflags,
}, },

View File

@ -144,8 +144,8 @@ udev_binaries_dict = [
'name' : 'udevadm', 'name' : 'udevadm',
'public' : true, 'public' : true,
'sources' : udevadm_sources + 'sources' : udevadm_sources +
udevadm_extract_sources +
keyboard_keys_from_name_inc, keyboard_keys_from_name_inc,
'extract' : udevadm_extract_sources,
'include_directories' : [ 'include_directories' : [
libexec_template['include_directories'], libexec_template['include_directories'],
include_directories('.', 'net'), include_directories('.', 'net'),
@ -154,7 +154,6 @@ udev_binaries_dict = [
'link_with' : udev_link_with, 'link_with' : udev_link_with,
'install_rpath' : udev_rpath, 'install_rpath' : udev_rpath,
'install_tag' : 'udev', 'install_tag' : 'udev',
'extract' : udevadm_extract_sources,
}, },
udev_plugin_template + { udev_plugin_template + {
'name' : 'ata_id', 'name' : 'ata_id',
@ -171,10 +170,7 @@ udev_binaries_dict = [
}, },
udev_plugin_template + { udev_plugin_template + {
'name' : 'fido_id', 'name' : 'fido_id',
'sources' : files( 'sources' : files('fido_id/fido_id.c'),
'fido_id/fido_id.c',
'fido_id/fido_id_desc.c',
),
'extract' : files('fido_id/fido_id_desc.c'), 'extract' : files('fido_id/fido_id_desc.c'),
}, },
udev_plugin_template + { udev_plugin_template + {

View File

@ -19,7 +19,7 @@ executables += [
executable_template + { executable_template + {
'name' : 'systemd-vmspawn', 'name' : 'systemd-vmspawn',
'public' : true, 'public' : true,
'sources' : vmspawn_sources + vmspawn_extract_sources, 'sources' : vmspawn_sources,
'extract' : vmspawn_extract_sources, 'extract' : vmspawn_extract_sources,
}, },
test_template + { test_template + {

View File

@ -4,19 +4,11 @@ if conf.get('ENABLE_XDG_AUTOSTART') != 1
subdir_done() subdir_done()
endif endif
systemd_xdg_autostart_generator_sources = files(
'xdg-autostart-generator.c',
)
systemd_xdg_autostart_generator_extract_sources = files(
'xdg-autostart-service.c',
)
executables += [ executables += [
executable_template + { executable_template + {
'name' : 'systemd-xdg-autostart-generator', 'name' : 'systemd-xdg-autostart-generator',
'sources' : systemd_xdg_autostart_generator_sources + 'sources' : files('xdg-autostart-generator.c'),
systemd_xdg_autostart_generator_extract_sources, 'extract' : files('xdg-autostart-service.c'),
'extract' : systemd_xdg_autostart_generator_extract_sources,
'install_dir' : usergeneratordir, 'install_dir' : usergeneratordir,
}, },
libexec_template + { libexec_template + {