1
0
mirror of https://github.com/systemd/systemd synced 2025-10-04 19:24:44 +02:00

Compare commits

...

13 Commits

Author SHA1 Message Date
Yu Watanabe
3ea86aa673 TEST-64-UDEV-STORAGE: wait for partition devices being created before calling udevadm trigger
For some reasons, kernel or sfdisk once remove the created partitions
and recreated them. And if 'udevadm trigger' triggers devices currently
being removed, the udevd does not receive the triggered events, and the
command stuck.

```
[   33.150452] TEST-64-UDEV-STORAGE.sh[546]: + sfdisk --wipe=always /dev/md/mdmirpar
[   33.478336] systemd-udevd[442]: md127: Device is queued (SEQNUM=2163, ACTION=change)
[   33.480153] kernel:  md127: p1 p2 p3
[   33.483772] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2164, ACTION=add)
[   33.483914] systemd-udevd[442]: md127p2: Device is queued (SEQNUM=2165, ACTION=add)
[   33.484999] systemd-udevd[442]: md127p3: Device is queued (SEQNUM=2166, ACTION=add)
[   33.485564] systemd-udevd[442]: md127: Received inotify event of watch handle 164.
[   33.503016] TEST-64-UDEV-STORAGE.sh[546]: + SYSTEMD_LOG_LEVEL=debug
[   33.503016] TEST-64-UDEV-STORAGE.sh[546]: + timeout 30 udevadm trigger --settle --parent-match /dev/md/mdmirpar
[   33.485905] systemd-udevd[442]: Successfully forked off '(udev-synth)' as PID 3208.
[   33.486067] systemd-udevd[442]: md127: Removing watch handle 164.
[   33.489035] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2167, ACTION=remove)
[   33.489048] systemd-udevd[442]: Received inotify event about removal of watch handle 164.
[   33.489507] systemd-udevd[442]: md127p2: Device is queued (SEQNUM=2168, ACTION=remove)
[   33.496298] systemd-udevd[442]: md127p3: Device is queued (SEQNUM=2169, ACTION=remove)
[   33.500628] systemd-udevd[442]: md127: Device is queued (SEQNUM=2170, ACTION=change)
[   33.502355] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2171, ACTION=add)
[   33.509371] TEST-64-UDEV-STORAGE.sh[3211]: md127: Triggered device with action 'change'.
[   33.509371] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Triggered device with action 'change'.
[   33.509371] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Triggered device with action 'change'.
[   33.512532] systemd-udevd[442]: md127: Device is queued (SEQNUM=2172, ACTION=change, UUID=a0b75692-08ad-428a-859b-9ef8772874d7)
[   33.512666] systemd-udevd[442]: md127p1: Device is queued (SEQNUM=2173, ACTION=change, UUID=4cd75a91-aa5b-4678-878c-0420b6c2e1e9)
[   33.512796] systemd-udevd[442]: md127p2: Device is queued (SEQNUM=2174, ACTION=add)
[   33.512910] systemd-udevd[442]: md127p3: Device is queued (SEQNUM=2175, ACTION=add)
[   33.531834] TEST-64-UDEV-STORAGE.sh[3211]: md127: Got uevent without UUID, ignoring: No such file or directory
[   33.553563] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Got uevent without UUID, ignoring: No such file or directory
[   33.561262] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Got uevent without UUID, ignoring: No such file or directory
[   33.562468] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Got uevent without UUID, ignoring: No such file or directory
[   33.563143] TEST-64-UDEV-STORAGE.sh[3211]: md127p3: Got uevent without UUID, ignoring: No such file or directory
[   33.564174] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Got uevent without UUID, ignoring: No such file or directory
[   33.567614] TEST-64-UDEV-STORAGE.sh[3211]: md127p3: Got uevent without UUID, ignoring: No such file or directory
[   33.597750] TEST-64-UDEV-STORAGE.sh[3211]: md127: Got uevent without UUID, ignoring: No such file or directory
[   33.623522] TEST-64-UDEV-STORAGE.sh[3211]: md127p1: Got uevent without UUID, ignoring: No such file or directory
[   33.676268] TEST-64-UDEV-STORAGE.sh[3211]: md127p3: Got uevent without UUID, ignoring: No such file or directory
[   33.686088] TEST-64-UDEV-STORAGE.sh[3211]: md127p2: Got uevent without UUID, ignoring: No such file or directory
```

Let's wait for partition devices being actually created, and wait for
all queued events being processed. Then, call 'udevadm trigger'.
2025-07-26 11:20:16 +01:00
Luca Boccassi
b5a7f13a42
tree-wide: bunch of fixlets raised by coverity (#38341) 2025-07-26 11:10:00 +01:00
김인수
7157c7c4a5 po: Translated using Weblate (Korean)
Currently translated at 100.0% (264 of 264 strings)

Co-authored-by: 김인수 <simmon@nplob.com>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/main/ko/
Translation: systemd/main
2025-07-26 18:34:15 +09:00
Yu Watanabe
08cf7c70b9 fs-util: avoid overflow in MODE_TO_PTR() with MODE_INVALID
Note, currently MODE_TO_PTR() and PTR_TO_MODE() are only used in
src/udev/udev-rules.c .

Fixes CID#1548060.
2025-07-26 05:00:02 +09:00
Yu Watanabe
c119eb0edc install: skip later first_word() calls if one of earlier calls passes
Prompted by CID#1587764, that is false-positive.
2025-07-26 05:00:02 +09:00
Yu Watanabe
635894a493 fuzz-efi-string: add missing OOM check
Fixes CID#1610113 and CID#1610114.
2025-07-26 05:00:02 +09:00
Yu Watanabe
fa43d54b55 delta: add missing error check
Follow-up for 59829bb37a44a01c4394301fd65478037e6b01d8.
Fixes CID#1611425.
2025-07-26 05:00:02 +09:00
Yu Watanabe
2c3b3e2fd9 ordered-set: avoid overflow
Previously, ordered_set_put_strdupv() and friends returns the number of
pushed entries, but that is potentially larger than INT_MAX (of course,
realistically, OOM is triggered in that case).

No caller uses the number of the new entries. Let's return 1 when at
least one element is added.

Fixes CID#1611523.
2025-07-26 05:00:02 +09:00
Yu Watanabe
6ce3b1fa33 test: add explicit test cases for cpu_set_add() and cpu_set_add_range()
cpu_set_add_range() is used in parse_cpu_set(), hence already tested.
But it is better to test these functions explicitly.

For CID#1611787 and CID#1611788, that should be false-positive.
2025-07-26 05:00:02 +09:00
Yu Watanabe
d54f1e4329 cpu-set-util: check if cpu set is already allocated
Prompted by CID#1611789, CID#1611790, and CID#1611791.
2025-07-26 04:59:58 +09:00
Yu Watanabe
04a99c48d2 cpu-set-util: fix identical ternary expression
Follow-up for fe3ada076ea8799a4d75f2e63adf540992d6fbb2.
Fixes CID#1611792.
2025-07-26 03:44:49 +09:00
Yu Watanabe
1f4e9f6d60 core/exec-invoke: check size of read size
Even though we do not use the read data, it is better to check the size
to prevent something spurious going.

Fixes CID#1612155.
2025-07-26 03:44:49 +09:00
Yu Watanabe
4d13e4dcbb resolved: use usec_add() at one more place
Follow-up for 8458b7fb91ea5e5109b6f3c94f8a781a120c798b.
Fixes CID#1612580.
2025-07-26 03:44:49 +09:00
13 changed files with 77 additions and 56 deletions

View File

@ -4,12 +4,12 @@
# Seong-ho Cho <shcho@gnome.org>, 2015, 2021.
# Dongsu Park <dongsu@endocode.com>, 2015.
# simmon <simmon@nplob.com>, 2021.
# 김인수 <simmon@nplob.com>, 2022, 2023, 2024.
# 김인수 <simmon@nplob.com>, 2022, 2023, 2024, 2025.
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-07-23 15:38+0100\n"
"PO-Revision-Date: 2024-11-29 12:38+0000\n"
"PO-Revision-Date: 2025-07-26 09:04+0000\n"
"Last-Translator: 김인수 <simmon@nplob.com>\n"
"Language-Team: Korean <https://translate.fedoraproject.org/projects/systemd/"
"main/ko/>\n"
@ -18,7 +18,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Weblate 5.8.2\n"
"X-Generator: Weblate 5.12.2\n"
"X-Poedit-SourceCharset: UTF-8\n"
#: src/core/org.freedesktop.systemd1.policy.in:22
@ -143,13 +143,11 @@ msgstr "사용자의 홈 영역을 활성화에 인증이 필요합니다."
#: src/home/org.freedesktop.home1.policy:93
msgid "Manage Home Directory Signing Keys"
msgstr ""
msgstr "홈 디렉토리의 서명 키를 관리합니다"
#: src/home/org.freedesktop.home1.policy:94
#, fuzzy
#| msgid "Authentication is required to manage system services or other units."
msgid "Authentication is required to manage signing keys for home directories."
msgstr "시스템 서비스 또는 기타 단위를 관리하려면 인증이 필요합니다."
msgstr "홈 디렉토리를 위해 서명 키를 관리하려면 인증이 필요합니다."
#: src/home/pam_systemd_home.c:336
#, c-format
@ -841,18 +839,13 @@ msgid ""
msgstr "로컬 가상 장비 및 컨테이너를 생성하려면 인증이 필요합니다."
#: src/machine/org.freedesktop.machine1.policy:106
#, fuzzy
#| msgid "Create a local virtual machine or container"
msgid "Register a local virtual machine or container"
msgstr "로컬 가상 장비 및 컨테이너 생성"
msgstr "로컬 가상 장비나 컨테이너를 등록합니다"
#: src/machine/org.freedesktop.machine1.policy:107
#, fuzzy
#| msgid ""
#| "Authentication is required to create a local virtual machine or container."
msgid ""
"Authentication is required to register a local virtual machine or container."
msgstr "로컬 가상 장비 및 컨테이너를 생성하려면 인증이 필요합니다."
msgstr "로컬 가상 장비나 컨테이너를 등록하려면 인증이 필요합니다."
#: src/machine/org.freedesktop.machine1.policy:116
msgid "Manage local virtual machine and container images"
@ -1072,13 +1065,11 @@ msgstr "질의 결과를 승락하려면 인증이 필요합니다."
#: src/resolve/org.freedesktop.resolve1.policy:154
msgid "Subscribe to DNS configuration"
msgstr ""
msgstr "DNS 구성으로 등록하다"
#: src/resolve/org.freedesktop.resolve1.policy:155
#, fuzzy
#| msgid "Authentication is required to subscribe query results."
msgid "Authentication is required to subscribe to DNS configuration."
msgstr "질의 결과를 승락하려면 인증이 필요합니다."
msgstr "DNS 구성으로 등록하려면 인증이 필요합니다."
#: src/resolve/org.freedesktop.resolve1.policy:165
msgid "Dump cache"
@ -1216,14 +1207,10 @@ msgid ""
msgstr "'$(unit)'의 처리에 유닉스 신호를 전송하려면 인증이 필요합니다."
#: src/core/dbus-unit.c:620
#, fuzzy
#| msgid ""
#| "Authentication is required to send a UNIX signal to the processes of "
#| "'$(unit)'."
msgid ""
"Authentication is required to send a UNIX signal to the processes of "
"subgroup of '$(unit)'."
msgstr "'$(unit)'의 처리에 유닉스 신호를 전송하려면 인증이 필요합니다."
msgstr "'$(unit)'의 하위그룹 처리로 유닉스 신호를 전송하려면 인증이 필요합니다."
#: src/core/dbus-unit.c:648
msgid "Authentication is required to reset the \"failed\" state of '$(unit)'."

View File

@ -6,8 +6,12 @@
/* The following macros add 1 when converting things, since 0 is a valid mode, while the pointer
* NULL is special */
#define PTR_TO_MODE(p) ((mode_t) ((uintptr_t) (p)-1))
#define MODE_TO_PTR(u) ((void *) ((uintptr_t) (u)+1))
static inline mode_t PTR_TO_MODE(void *p) {
return p ? (mode_t) ((uintptr_t) p - 1) : MODE_INVALID;
}
static inline void* MODE_TO_PTR(mode_t m) {
return m == MODE_INVALID ? NULL : (void *) ((uintptr_t) m + 1);
}
int rmdir_parents(const char *path, const char *stop);

View File

@ -61,7 +61,7 @@ int ordered_set_put_strdup_full(OrderedSet **s, const struct hash_ops *hash_ops,
}
int ordered_set_put_strdupv_full(OrderedSet **s, const struct hash_ops *hash_ops, char **l) {
int n = 0, r;
int r, ret = 0;
assert(s);
@ -70,14 +70,14 @@ int ordered_set_put_strdupv_full(OrderedSet **s, const struct hash_ops *hash_ops
if (r < 0)
return r;
n += r;
ret = ret || r > 0;
}
return n;
return ret;
}
int ordered_set_put_string_set_full(OrderedSet **s, const struct hash_ops *hash_ops, OrderedSet *l) {
int n = 0, r;
int r, ret = 0;
char *p;
assert(s);
@ -89,10 +89,10 @@ int ordered_set_put_string_set_full(OrderedSet **s, const struct hash_ops *hash_
if (r < 0)
return r;
n += r;
ret = ret || r > 0;
}
return n;
return ret;
}
void ordered_set_print(FILE *f, const char *field, OrderedSet *s) {

View File

@ -31,10 +31,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
DO_NOT_OPTIMIZE(parse_number8(str8, &(uint64_t){ 0 }, size % 2 == 0 ? NULL : &tail8));
const char16_t *tail16 = NULL;
_cleanup_free_ char16_t *str16 = memdup_str16(data, size);
_cleanup_free_ char16_t *str16 = ASSERT_SE_PTR(memdup_str16(data, size));
DO_NOT_OPTIMIZE(parse_number16(str16, &(uint64_t){ 0 }, size % 2 == 0 ? NULL : &tail16));
_cleanup_free_ char16_t *pattern = memdup_str16(data, len), *haystack = memdup_str16(data + len, len2);
_cleanup_free_ char16_t
*pattern = ASSERT_SE_PTR(memdup_str16(data, len)),
*haystack = ASSERT_SE_PTR(memdup_str16(data + len, len2));
DO_NOT_OPTIMIZE(efi_fnmatch(pattern, haystack));
return 0;

View File

@ -2244,8 +2244,11 @@ static int setup_private_users_child(int unshare_ready_fd, const char *uid_map,
/* Wait until the parent unshared the user namespace */
uint64_t c;
if (read(unshare_ready_fd, &c, sizeof(c)) < 0)
ssize_t n = read(unshare_ready_fd, &c, sizeof(c));
if (n < 0)
return log_debug_errno(errno, "Failed to read from signaling eventfd: %m");
if (n != sizeof(c))
return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Short read from signaling eventfd.");
/* Disable the setgroups() system call in the child user namespace, for good, unless PrivateUsers=full
* and using the system service manager. */

View File

@ -286,6 +286,8 @@ static int enumerate_dir_d(
log_debug("Adding to drops: %s %s %s %s %s/%s",
unit, glyph(GLYPH_ARROW_RIGHT), *file, glyph(GLYPH_ARROW_RIGHT), path, *file);
r = path_put(&h, path, *file, /* override = */ false);
if (r < 0)
return r;
}
return 0;
}

View File

@ -198,7 +198,7 @@ int dns_add_new_service(DnsServiceBrowser *sb, DnsResourceRecord *rr, int owner_
/* If next_time is still in the past, the service is being added
* after it has already expired. Just schedule a 100%
* maintenance query. */
next_time = usec + USEC_PER_SEC;
next_time = usec_add(usec, USEC_PER_SEC);
s->rr_ttl_state = DNS_RECORD_TTL_STATE_100_PERCENT;
}

View File

@ -133,8 +133,10 @@ int cpu_set_realloc(CPUSet *c, size_t n) {
return -ERANGE;
n = CPU_ALLOC_SIZE(n);
if (n <= c->allocated)
if (n <= c->allocated) {
assert(c->set || n == 0);
return 0;
}
if (!GREEDY_REALLOC0(c->set, DIV_ROUND_UP(n, sizeof(cpu_set_t))))
return -ENOMEM;
@ -177,7 +179,7 @@ int cpu_set_add_set(CPUSet *c, const CPUSet *src) {
return 1;
}
static int cpu_set_add_range(CPUSet *c, size_t start, size_t end) {
int cpu_set_add_range(CPUSet *c, size_t start, size_t end) {
int r;
assert(c);
@ -222,7 +224,7 @@ int config_parse_cpu_set(
void *userdata) {
CPUSet *c = ASSERT_PTR(data);
int r, level = ltype ? LOG_DEBUG : LOG_DEBUG;
int r, level = ltype ? LOG_DEBUG : LOG_ERR;
bool critical = ltype;
assert(critical || lvalue);

View File

@ -24,6 +24,7 @@ void cpu_set_done(CPUSet *c);
int cpu_set_realloc(CPUSet *c, size_t n);
int cpu_set_add(CPUSet *c, size_t i);
int cpu_set_add_set(CPUSet *c, const CPUSet *src);
int cpu_set_add_range(CPUSet *c, size_t start, size_t end);
int cpu_set_add_all(CPUSet *c);
char* cpu_set_to_string(const CPUSet *c);

View File

@ -3350,8 +3350,7 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
if (strchr(COMMENTS, line[0]))
continue;
parameter = first_word(line, "enable");
if (parameter) {
if ((parameter = first_word(line, "enable"))) {
char *unit_name;
char **instances = NULL;
@ -3367,10 +3366,8 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
.action = PRESET_ENABLE,
.instances = instances,
};
}
parameter = first_word(line, "disable");
if (parameter) {
} else if ((parameter = first_word(line, "disable"))) {
char *pattern;
pattern = strdup(parameter);
@ -3381,10 +3378,8 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
.pattern = pattern,
.action = PRESET_DISABLE,
};
}
parameter = first_word(line, "ignore");
if (parameter) {
} else if ((parameter = first_word(line, "ignore"))) {
char *pattern;
pattern = strdup(parameter);
@ -3397,7 +3392,7 @@ static int read_presets(RuntimeScope scope, const char *root_dir, UnitFilePreset
};
}
if (rule.action) {
if (rule.action != 0) {
if (!GREEDY_REALLOC(ps.rules, ps.n_rules + 1))
return -ENOMEM;

View File

@ -262,4 +262,25 @@ TEST(print_cpu_alloc_size) {
log_info("CPU_ALLOC_SIZE(8191) = %zu", CPU_ALLOC_SIZE(8191));
}
TEST(cpu_set_add) {
_cleanup_(cpu_set_done) CPUSet c = {};
for (size_t i = 0; i < 8192; i++)
ASSERT_OK(cpu_set_add(&c, 8191));
ASSERT_ERROR(cpu_set_add(&c, 8192), ERANGE);
ASSERT_ERROR(cpu_set_add(&c, SIZE_MAX), ERANGE);
}
TEST(cpu_set_add_range) {
_cleanup_(cpu_set_done) CPUSet c = {};
ASSERT_ERROR(cpu_set_add_range(&c, 0, 8192), ERANGE);
ASSERT_ERROR(cpu_set_add_range(&c, 0, SIZE_MAX), ERANGE);
ASSERT_SIGNAL(cpu_set_add_range(&c, 100, 0), SIGABRT);
ASSERT_OK(cpu_set_add_range(&c, 0, 0));
ASSERT_OK(cpu_set_add_range(&c, 0, 8191));
}
DEFINE_TEST_MAIN(LOG_DEBUG);

View File

@ -90,18 +90,19 @@ TEST(set_put_string_set) {
_cleanup_ordered_set_free_ OrderedSet *m = NULL, *q = NULL;
_cleanup_free_ char **final = NULL; /* "just free" because the strings are in the set */
assert_se(ordered_set_put_strdup(&m, "1") == 1);
assert_se(ordered_set_put_strdup(&m, "22") == 1);
assert_se(ordered_set_put_strdup(&m, "333") == 1);
ASSERT_OK_POSITIVE(ordered_set_put_strdup(&m, "1"));
ASSERT_OK_POSITIVE(ordered_set_put_strdup(&m, "22"));
ASSERT_OK_POSITIVE(ordered_set_put_strdup(&m, "333"));
assert_se(ordered_set_put_strdup(&q, "11") == 1);
assert_se(ordered_set_put_strdup(&q, "22") == 1);
assert_se(ordered_set_put_strdup(&q, "33") == 1);
ASSERT_OK_POSITIVE(ordered_set_put_strdup(&q, "11"));
ASSERT_OK_POSITIVE(ordered_set_put_strdup(&q, "22"));
ASSERT_OK_POSITIVE(ordered_set_put_strdup(&q, "33"));
assert_se(ordered_set_put_string_set(&m, q) == 2);
ASSERT_OK_POSITIVE(ordered_set_put_string_set(&m, q));
ASSERT_OK_ZERO(ordered_set_put_string_set(&m, q));
assert_se(final = ordered_set_get_strv(m));
assert_se(strv_equal(final, STRV_MAKE("1", "22", "333", "11", "33")));
ASSERT_NOT_NULL(final = ordered_set_get_strv(m));
ASSERT_TRUE(strv_equal(final, STRV_MAKE("1", "22", "333", "11", "33")));
ordered_set_print(stdout, "BAR=", m);
}

View File

@ -1165,8 +1165,11 @@ uuid="deadbeef-dead-dead-beef-111111111111", name="mdpart1", size=8M
uuid="deadbeef-dead-dead-beef-222222222222", name="mdpart2", size=32M
uuid="deadbeef-dead-dead-beef-333333333333", name="mdpart3", size=16M
EOF
udevadm wait --settle --timeout=30 "$raid_dev" "${raid_dev}1" "${raid_dev}2" "${raid_dev}3"
# FIXME: For some reasons, the command sometimes stuck and the test will timeout.
# Let's enable debug logging and set a timeout to make not consume CI resource.
# UPDATE: The above 'udevadm wait' command should fix the issue.
# But, let's keep the debug option for a while.
SYSTEMD_LOG_LEVEL=debug timeout 30 udevadm trigger --settle --parent-match "$raid_dev"
udevadm wait --settle --timeout=30 "/dev/disk/by-id/md-uuid-$uuid-part2"
mkfs.ext4 -L "$part_name" "/dev/disk/by-id/md-uuid-$uuid-part2"