Yu Watanabe
e61ac7cd27
network/address: drop duplicated address earlier
...
network_adjust_dhcp_server() searches network->addresses_by_section,
hence without this change, an address entry picked by
network_adjust_dhcp_server() may be detached and freed by the cleanup
function.
2026-05-18 06:40:29 +02:00
Yu Watanabe
a0177d96dc
dhcp-message: introduce dhcp_message_{payload,packet}_size()
2026-05-18 09:34:32 +09:00
Yu Watanabe
3e6c08b967
Introduce several more helper functions to read sysfs attributes and use them where applicable ( #41065 )
...
Let's not use sd_device_get_sysattr_value() unless the result is
sanitized, escaped, or filtered.
2026-05-18 07:26:44 +09:00
Yu Watanabe
9b768b5bf5
Apply "ruff format" and "ruff check --fix" for all python scripts ( #40758 )
2026-05-18 07:26:11 +09:00
Yu Watanabe
2a1a026d72
udev-builtin-input-id: drop unused value
2026-05-18 02:55:56 +09:00
Yu Watanabe
6f72bb7bc9
tree-wide: use device_get_sysattr_unsigned() and friends
2026-05-18 02:55:56 +09:00
Yu Watanabe
6ad682d70f
udev-builtin-usb_id: make set_usb_iftype() and friends return const char*
2026-05-18 02:55:56 +09:00
Yu Watanabe
23c93e2cd6
udev-builtin-usb_id: use device_get_sysattr_unsigned() and friends
...
This also fix the parser of bInterfaceClass from safe_atoi() to
safe_atou_full() as it is unsigned hex.
2026-05-18 02:55:56 +09:00
Yu Watanabe
247e4caa3c
sd-device: also add device_get_sysattr_streq()
2026-05-18 02:55:56 +09:00
Yu Watanabe
1e39d3eb08
sd-device: also add device_get_sysattr_u8() and _u16()
2026-05-18 02:55:56 +09:00
Yu Watanabe
3c230737f5
sd-device: use macro to define device_get_sysattr_int() and friends
2026-05-18 02:55:56 +09:00
Yu Watanabe
dbfe8b162b
test: add test cases for device_get_sysattr_int() and friends
2026-05-18 02:55:56 +09:00
Yu Watanabe
532276524f
sd-device: rename argument names for storing result
...
When a function takes only one argument for storing result, the argument
is not necessary to be named as ret_xyz, but ret should be enough.
2026-05-18 02:55:56 +09:00
Yu Watanabe
06d687ffac
tree-wide: use device_get_sysattr_safe_string()
...
The obtained strings are passed to another function, e,g, handled as a
path and opened, printed to the terminal, written to a file, saved to
udev database as udev property, exposed through DBus, passed to logger,
and so on. Hence, these should not contain any malicious characters.
2026-05-18 02:55:56 +09:00
Yu Watanabe
fdce4d4687
udev-builtin-net_id: quote strings in log messages
2026-05-18 02:55:56 +09:00
Yu Watanabe
35edd031b9
udev-builtin-net_id: use EINVAL when we get unexpected sysattr value
...
The results are completely ignored or only checked if it is negative or
not. Hence, this does not change anything.
2026-05-18 02:55:56 +09:00
Yu Watanabe
c5a04f59d9
udev: drop redundant checks
...
This partially reverts 16325b35fa ,
as bad characters are already filtered.
2026-05-18 02:55:56 +09:00
Yu Watanabe
c6ea72e39a
Revert "udev-builtin-net-id: print cescaped bad attributes"
...
This reverts commit 7c4047957e .
This is not necessary, as bad characters are already filtered.
2026-05-18 02:55:56 +09:00
Yu Watanabe
d0e48e2601
udev: use device_get_sysattr_safe_string() in device_get_sysattr_value_filtered()
...
Then, renamed to device_get_sysattr_safe_string_filtered().
2026-05-18 02:55:56 +09:00
Yu Watanabe
13ce62caba
sd-device: use device_get_sysattr_safe_string()
...
The read value are exposed by sd_device_get_subsystem() and friends.
Hence, it is better to filter invalid characters.
Of course, these should be always safe unless the kernel is buggy.
But, just for safety.
Note, even if uevent file contains invalid characters, then
device_read_uevent_file() should succeed without parsing the contents.
The caller should fail later with a proper error code if a necessary
field is unset. E.g. sd_device_get_ifindex() should still return -ENOENT
even when uevent file contains an invalid characters.
2026-05-18 02:55:56 +09:00
Yu Watanabe
0341058ee6
sd-device: introduce device_get_sysattr_safe_string()
...
This introduce a helper function that verifies read sysattr value.
Some sysattr value may come from firmware, and kernel may expose unsafe
string. The introduced function should be used when we use the result as
a string.
2026-05-18 02:55:56 +09:00
Yu Watanabe
b74f016e59
string-util: introduce STRING_ALLOW_NEWLINES switch for string_is_safe()
...
This also make StringSafeFlags defined in basic-forward.h so other
headers can use the enum.
2026-05-18 02:55:34 +09:00
Yu Watanabe
e184315aee
ci/linter: run ruff for all python scripts
2026-05-18 02:51:41 +09:00
Yu Watanabe
4c333638ad
proxy-echo: apply "ruff check --fix"
2026-05-18 02:51:35 +09:00
Yu Watanabe
06961b7c5f
fake-report-server: apply "ruff format" and "ruff check --fix"
2026-05-18 02:49:29 +09:00
Yu Watanabe
2a0eaff3a7
fake-imds: apply "ruff format" and "ruff check --fix"
2026-05-18 02:48:35 +09:00
Yu Watanabe
94f807be03
merge-bpf-compdb: apply "ruff format"
2026-05-18 02:47:09 +09:00
Yu Watanabe
9e15fad481
xml_helper: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
8fc2bde0db
update-man-rules: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
c1e31e12b4
update-dbus-docs: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:47 +09:00
Yu Watanabe
09e34716fc
sync-docs: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:47 +09:00
Yu Watanabe
3b690e2c7e
meson-render-jinja2: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
1fbb5e0ff1
meson-extract-unit-files: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
3675924f5b
make-man-index: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
8b24db05d4
make-directive-index: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
e0ac581a8b
list-discoverable-partitions: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
cc1373700b
generate-gperfs: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
86d3b07fba
gdb-sd_dump_hashmaps: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:47 +09:00
Yu Watanabe
30c87278d4
find-unused-library-symbols: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:47 +09:00
Yu Watanabe
2ab056cb7e
fetch-mkosi: apply "ruff format" and "ruff check --fix"
...
This also makes CONFIG is closed when not necessary.
2026-05-18 02:44:47 +09:00
Yu Watanabe
6c2bf5330b
fetch-distro: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
0df17e665b
elf2efi: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:47 +09:00
Yu Watanabe
7e62c9be6f
dump-auxv: apply "ruff format"
2026-05-18 02:44:47 +09:00
Yu Watanabe
5aa172e263
dbus-exporter: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:47 +09:00
Yu Watanabe
a5d54f52d6
check-version-history: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:47 +09:00
Yu Watanabe
53172028c8
check-efi-alignment: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
0965c5d719
catalog-report: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
ce9b618e46
analyze-dump-sort: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
b27bd1a399
TEST-69-SHUTDOWN: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
81b1f3dd9f
test-udev: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
f8a3f9d135
test-tmpfiles: apply "ruff format" and "ruff check --fix"
...
This also dropped unnecessary existence check for subprocess.run.
2026-05-18 02:44:46 +09:00
Yu Watanabe
6e4c7f91f9
test-shutdown: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
1b94d7d7ec
test-network: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
59199ec3bd
test-network: drop old ip command support
2026-05-18 02:44:46 +09:00
Yu Watanabe
9c0c203db4
test-network: assume the test is running with newer udevd
2026-05-18 02:44:46 +09:00
Yu Watanabe
cbc2990335
test-network: drop old kernel support and workaround for fixed kernel bug
...
- l3mdev in fib rules is supported since
https://github.com/torvalds/linux/commit/96c63fa7393d0a346acfe5a91e0c7d4c7782641b (v4.8).
- uid range in fib rules is supported since
https://github.com/torvalds/linux/commit/622ec2c9d52405973c9f1ca5116eb1c393adfc7d (v4.10).
- port range and ip proto in fib rules is supported since
https://github.com/torvalds/linux/commit/bfff4862653bb96001ab57c1edd6d03f48e5f035 (v4.17).
- interface alternative name is supported since
https://github.com/torvalds/linux/commit/36fbf1e52bd3ff8a5cb604955eedfc9350c2e6cc (v5.5).
- SRIOV on netdevsim is supported since
https://github.com/torvalds/linux/commit/79579220566cd33fe3b15ce8249c57e10251b258 (4.16).
- nexthop is supported since
https://github.com/torvalds/linux/commit/65ee00a9409f751188a8cdc0988167858eb4a536 (v5.3).
- bridge MDB entries on bridge master is supported since
https://github.com/torvalds/linux/commit/1bc844ee0faa1b92e3ede00bdd948021c78d7088 (v5.4).
2026-05-18 02:44:46 +09:00
Yu Watanabe
124bbf37de
sys-script: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
87c0cf15fe
sd-script: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
d89d23bc8f
run-unit-tests: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
2c73e5b973
rule-syntax-check: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
ba90ffaef2
networkd-test: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
f6b2a27e59
TEST-04-JOURNAL: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
a562d59fd9
generate-directives: apply "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
8fd2385709
create-sys-script: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
58aa8824f3
test_ukify: apply "ruff format"
...
Also drops unnecessary noqa attribute for importing pefile.
2026-05-18 02:44:46 +09:00
Yu Watanabe
d86df93f96
generate-syscall-list: apply "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
246e4594ed
generate-dns_type: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
4084459014
ethtool-link-mode: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
cd7bb96049
log-generator: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
b0a06e2a81
generate-syscall: apply "ruff format" and "ruff check --fix"
...
Also, this makes opened files closed when not necessary.
2026-05-18 02:44:46 +09:00
Yu Watanabe and Jörg Behrmann
c5abf64d37
fuzz-bootspec: apply "ruff format"
...
This also replaces open().read() with Path().read_text().
Co-authored-by: Jörg Behrmann <behrmann@physik.fu-berlin.de >
2026-05-18 02:44:46 +09:00
Yu Watanabe
a89c11b672
filesystem-sets: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
4758d1f71a
man/notify-example: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
5481961700
man/check-os-release: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
14848f1f71
man/check-os-release-simple: apply "ruff format"
2026-05-18 02:44:46 +09:00
Yu Watanabe
522fdd7d96
man/90-rearrange-path: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:46 +09:00
Yu Watanabe
4fa9302fa4
hwdb/parse_hwdb: apply "ruff format" and "ruff check --fix"
2026-05-18 02:44:40 +09:00
Yu Watanabe
1c98dff834
hwdb/ids_parser: apply "ruff format" and "ruff check --fix"
2026-05-18 02:32:42 +09:00
Yu Watanabe
a3dc3dc61b
hwdb/acpi-update: apply "ruff format"
2026-05-18 02:32:42 +09:00
Yu Watanabe
f74118be4f
ycm: apply "ruff format" and "ruff check --fix"
2026-05-18 02:32:42 +09:00
Yu Watanabe
75f7304512
ruff: do not warn about too long line and lambda assignment
2026-05-18 02:32:42 +09:00
Yu Watanabe
c54decc406
ruff: use single quotes for multiline strings
2026-05-18 02:32:39 +09:00
Yu Watanabe
8e8d3a22b2
sd-device: use string_is_safe() at one more place
2026-05-18 01:57:33 +09:00
Yu Watanabe
42c689f63d
sd-device: logs about refused property
...
Follow-up for a62cd5a153 .
2026-05-18 01:55:10 +09:00
Yu Watanabe
aa0f03eb03
networkctl: introduce 'dhcp-lease' command to dump acquired DHCP lease ( #42137 )
2026-05-18 01:28:11 +09:00
Yu Watanabe
ba22984544
sd-dhcp-client: use dhcp_message_send_{udp,raw}() and update BPF code ( #42138 )
2026-05-18 01:26:55 +09:00
Yu Watanabe
a72f23d2b8
sd-dhcp-client: drop unused data in sd_dhcp_client
...
With the previous commit, now sd_dhcp_client.link is not used anymore.
Let's drop it.
2026-05-17 22:44:17 +09:00
Yu Watanabe
0c69b24741
dhcp-client-send: move/update BPF code and socket initialization from dhcp-network.c
...
- BPF code now supports the case when IP header has IP packet options,
- also set socket priority to UDP socket.
Co-developed-by: Google Gemini Pro
2026-05-17 22:44:17 +09:00
Yu Watanabe
89cf6d81f7
dhcp-client-send: use dhcp_message_send_{udp,raw}()
2026-05-17 22:44:17 +09:00
Yu Watanabe
ddd535a424
NEWS: mention new 'networkctl dhcp-lease' command
2026-05-17 21:03:55 +09:00
Yu Watanabe
6cbf8222ca
networkctl: add dhcp-lease verb to dump DHCP lease
...
This shows the DHCP message of an acquired DHCP lease.
Example:
```
$ networkctl dhcp-lease eth0
Header:
KEY VALUE
Hardware Type: ETHER
Hardware Address: 41:42:43:31:32:33
Client Address: 192.0.2.123
Server Address: 192.0.2.1
Options:
CODE NAME DATA
1 subnet mask 255.255.255.0
3 router 192.0.2.1
6 domain name server 192.0.2.1
12 hostname test-node
15 domain name lan
28 broadcast address 192.0.2.255
42 NTP server 192.0.2.11
192.0.2.12
51 lease time 1d
53 message type 5
54 server identifier 192.0.2.1
58 renewal time 11h 5min 38s
59 rebinding time 20h 5min 38s
119 domain search hoge.example.com
foo.example.com
```
2026-05-17 21:02:20 +09:00
Yu Watanabe
9022ccc219
dhcp: cleanups for sd-dhcp-lease.c and rewrite test-dhcp-client ( #42135 )
2026-05-17 20:12:37 +09:00
Yu Watanabe
149adb2fdc
dhcp-message-dump: introduce dump_dhcp_message()
...
It dumps DHCP messages in a human friendly format.
It will be used in networkctl in a later commit.
2026-05-17 20:09:47 +09:00
Yu Watanabe
a192c67630
ci/alpine: do not install util-linux-login
...
For some reasons, after util-linux is bumped from 2.41.4-r0 to 2.42-r0,
the 'su' command from util-linux-login seems to not correctly run commands in
https://github.com/jirutka/setup-alpine/blob/v1.4.1/alpine.sh
and causes the following spurious failure:
```
2026-05-15T21:19:15.6539432Z ##[group]Set up user runner
2026-05-15T21:19:15.6981963Z /bin/sh: line 0: ��: not found
2026-05-15T21:19:15.6982503Z /bin/sh: line 1: ␡ELF␂␁␁␃: not found
2026-05-15T21:19:15.6985788Z /bin/sh: line 10: ␒␐␆␒B␈␒�␄␒y␄␒�␁␒␞␇␒:␁␒�␃␒�␄␒@␁␒9␈␒?␆␒␚␈␒x: not found
2026-05-15T21:19:15.7010731Z /bin/sh: line 33: can't open ␂␒-␂␒�: no such file
2026-05-15T21:19:15.7016026Z /bin/sh: line 33: syntax error: unexpected word (expecting ")")
2026-05-15T21:19:15.7049583Z
2026-05-15T21:19:15.7050199Z ␛[1;31mError occurred at line 338:␛[0m
2026-05-15T21:19:15.7050830Z 335 | echo 'permit nopass keepenv $SUDO_USER' | tee /etc/doas.d/root.conf
2026-05-15T21:19:15.7051287Z 336 | fi
2026-05-15T21:19:15.7051549Z 337 | SHELL
2026-05-15T21:19:15.7052039Z ␛[1;31m> 338 | abin/"$INPUT_SHELL_NAME" --root /.setup.sh␛[0m
2026-05-15T21:19:15.7052506Z 339 |
2026-05-15T21:19:15.7052796Z 340 | rm .setup.sh
2026-05-15T21:19:15.7053172Z 341 | endgroup
2026-05-15T21:19:15.7096322Z ##[error]Error occurred at line 338: abin/"$INPUT_SHELL_NAME" --root /.setup.sh (see the job log for more information)
2026-05-15T21:19:15.7101400Z ##[error]Process completed with exit code 1.
```
Let's not install the package. It seems no command provided by the
package is used.
2026-05-17 10:56:34 +01:00
Yu Watanabe
335ac4a71d
fuzz-dhcp-client: externally set socket fd, rather than override functions
2026-05-17 15:20:29 +09:00
Yu Watanabe
acdaee339f
test-dhcp-client: add test cases for discover attempt counter
2026-05-17 15:20:29 +09:00
Yu Watanabe
115c354b57
test-dhcp-client: add test cases for IPv6-only mode
2026-05-17 15:20:29 +09:00
Yu Watanabe
7df9210283
test-dhcp-client: add test case for BOOTP client mode
2026-05-17 15:20:29 +09:00
Yu Watanabe
9bd6b949d3
test-dhcp-client: add test case for INIT-REBOOT sequence
2026-05-17 15:20:29 +09:00
Yu Watanabe
f7c144b9c7
test-dhcp-client: add test case for rapid commit mode
2026-05-17 15:20:24 +09:00