Commit Graph
6149 Commits
Author SHA1 Message Date
Sonali Srivastava 746cf8980b sleep: support multiple battery instead of only BAT0 2022-08-09 17:13:35 +01:00
gtwang01 b607fd3f32 tree-wide: use bus locator (#24252)
This modifies some sd_bus calls to equivalent bus calls.
2022-08-09 16:19:09 +09:00
Lennart Poettering 2361820e7b Merge pull request #24220 from yuwata/on-ac-power
udev-util: assume running on AC power when no battery found
2022-08-08 15:35:55 +02:00
undef 7b45d6b6f6 shared/generator: Ensure growfs unit runs after repart
When deploying an image using systemd-repart and systemd-growfs one
should have the image expanded entirely and ready to use after the first
boot. This ensures that growfs does not occur before repart, thus
requiring a second boot.
2022-08-08 15:20:36 +02:00
Yu Watanabe 96788d2aa4 udev-util: assume system is running on AC power when no battery found
Fixes #24214.
2022-08-06 03:42:32 +09:00
Yu Watanabe 1c6e17e5d1 udev-util: align string table 2022-08-06 03:35:04 +09:00
Michal Sekletar 03860190fe scope: allow unprivileged delegation on scopes
Previously it was possible to set delegate property for scope, but you
were not able to allow unprivileged process to manage the scope's cgroup
hierarchy. This is useful when launching manager process that  will run
unprivileged but is supposed to manage its own (scope) sub-hierarchy.

Fixes #21683
2022-08-04 17:01:13 +02:00
Daan De Meyer 35d40302af blockdev-util: Add block_device_remove_all_partitions()
This function takes a block device, uses sd-device to iterate all
the partitions, and removes them one by one.
2022-08-03 20:55:32 +02:00
Daan De Meyer 24d59aeed3 loop-util: Add loop_device_unrelinquish()
Allows taking ownership of a loop device which makes sure that
loop_device_unrefp() will try to destroy it when it runs.
2022-08-03 20:55:32 +02:00
Daan De Meyer d25697f578 blockdev-util: Introduce block_device_add/remove_partition()
Extracted from dissect-image.c.
2022-08-03 20:55:29 +02:00
Daan De Meyer 26aa4800f8 blockdev-util: Introduce fd_get_whole_disk()
Extracted from find_devno() in udevadm-lock.c.
2022-08-03 20:55:00 +02:00
Lennart Poettering 6977ea9975 bootctl: show stub feature set in status output 2022-08-02 10:28:49 +02:00
Daan De Meyer 71ec216e86 Merge pull request #24080 from rdtscp/feature/machinectl/copy-force-flag
Add --force flag to machinectl copy-[to|from]
2022-07-28 14:15:33 +02:00
Alexander Wilson 922409558e copy: Respect COPY_REPLACE flag for copy_tree
- Add a test that asserts that copy_tree on an existing file will fail without COPY_REPLACE
- Add a test that asserts that copy_tree with COPY_MERGE and COPY_REPLACE on an existing directory will overwrite files that already exist.
2022-07-27 08:40:59 -07:00
Alexander Wilson d3e2a7f7e6 copy.[ch]: Refactor
- Refactor: Move HardlinkContext to header file
- Refactor: Create `fd_copy_tree_generic` which isolates the functionality to check stat type and appropriately copy.
- Refactor: Create `fd_copy_leaf` which handles copying leaf nodes of a file tree.
2022-07-27 03:09:35 -07:00
Daan De Meyer 75db32dcd8 journal: Move more pattern matching logic into pcre2-util
To avoid having "#if HAVE_PCRE2" all throughout the code, let's
confine the pcre2 header specific stuff to pcre2-util.c. Instead of
exposing all the individual symbols from pcre2, let's only expose
three high level functions that do all we need:

- pcre2_pattern_compile(): Compile the regex
- pcre2_pattern_matches(): Check if the compiled regex matches a message
- pcre2_pattern_free(): Free the compiled regex

We expose the compiled pcre2 pattern (which is of type pcre2_code *) as
a void pointer to avoid having to include pcre2.h in all code where we
work with compiled pcre2 patterns. For readability, we typedef void
to pcre2_pattern and use that as the type specifier for compiled pcre2
patterns.
2022-07-25 14:16:17 +02:00
Frantisek Sumsal 05abe85033 boot: a couple of tweaks recommended by Coccinelle 2022-07-25 12:47:23 +02:00
Lennart Poettering 8f304b991c Merge pull request #23991 from yuwata/udev-reload
udev: reload rules and builtins only when mtime of a config changed
2022-07-25 11:20:08 +02:00
Rudi Heitbaum 3657d3a01c glibc: Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36 2022-07-24 20:52:35 +09:00
Yu Watanabe 573bb24df7 sd-netlink: introduce sd_nfnl_{send,call}_batch()
This also introduces sd_nfnl_message_new() which can be also used for
non-nftables subsystems.
2022-07-24 00:16:21 +09:00
Yu Watanabe 665bc9e6e2 firewall-util: introduce nfnl_close_expr_container() helper function
And merge nfnl_add_expr_lookup_set() and nfnl_add_expr_lookup_map().
2022-07-24 00:05:32 +09:00
Yu Watanabe df7371708e sd-netlink: merge sd_nfnl_nft_message_{new,del}_setelems_begin()
And this makes the new merged function `sd_nfnl_nft_message_new_setelems()`
not open container, as containers should be opened and closed in the
same function in general. Otherwise, it is hard to understand which
level we are in the nested attribute tree.
2022-07-24 00:05:09 +09:00
Yu Watanabe 2c08455eed sd-netlink: introduce sd_netlink_message_append_container_data() 2022-07-23 23:52:42 +09:00
Yu Watanabe 35cca046cf firewall-util: drop unnecessary string attribute
As `sd_netlink_message_open_container_union()` also appends the string
attribute.
2022-07-23 23:52:42 +09:00
Yu Watanabe 295942cb46 firewall-util-nft: various cleanups
- add missing assertions,
- align enum elements,
- use cleanup attribute, and so on.
2022-07-23 23:52:35 +09:00
Yu Watanabe acfbd71ccc udev: save stats of all udev rules file
The mtime of directory is not updated when an existing rule file is
changed. Hence, paths_check_timestamp() is not reliable.
2022-07-23 15:05:22 +09:00
Yu Watanabe 3f4dfd9d87 conf-parser: add a boolean flag for config_get_stats_by_path() to control if drop-in configs are checked
Preparation for later commits.
2022-07-23 15:03:48 +09:00
Yu Watanabe 1561db8ac2 json: use fpclassify() or its helper functions 2022-07-21 09:18:13 +09:00
Luca Boccassi 74c1cf6267 Merge pull request #23640 from cerebro1/week1
Estimate battery level
2022-07-20 18:07:22 +01:00
Sonali Srivastava 91ea7ebcdf sleep: store battery discharge rate/hour with hash
Estimated battery discharge rate per hour is stored in :
/var/lib/systemd/sleep/battery_discharge_percentage_rate_per_hour

This value is used to determine the initial suspend interval. In case
this file is not available or value is invalid, HibernateDelaySec
interval is used.
After wakeup from initial suspend, this value is again estimated and
written to file if value is in range of 1-199.

Logs for reference : HibernateDelaySec=15min
- Updated in /etc/systemd/sleep.conf

Jul 14 19:17:58 localhost systemd-sleep[567]: Current battery charge
percentage: 100%
Jul 14 19:17:58 localhost systemd-sleep[567]: Failed to read discharge
rate from /var/lib/systemd/sleep/batt
ery_discharge_percentage_rate_per_hour: No such file or directory
Jul 14 19:17:58 localhost systemd-sleep[567]: Set timerfd wake alarm
for 15min
Jul 14 19:33:00 localhost systemd-sleep[567]: Current battery charge
percentage after wakeup: 90%
Jul 14 19:33:00 localhost systemd-sleep[567]: Attempting to estimate
battery discharge rate after wakeup from 15min sleep
Jul 14 19:33:00 localhost systemd-sleep[567]: product_id does not
exist: No such file or directory
Jul 14 19:33:00 localhost systemd-sleep[567]: Estimated discharge rate
39 successfully updated to
/var/lib/systemd/sleep/battery_discharge_percentage_rate_per_hour
Jul 14 19:33:00 localhost systemd-sleep[567]: Current battery charge
percentage: 90%
Jul 14 19:33:00 localhost systemd-sleep[567]: product_id does not
exist: No such file or directory
Jul 14 19:33:00 localhost systemd-sleep[567]: Set timerfd wake alarm
for 1h 48min 27s
Jul 14 21:21:30 localhost systemd-sleep[567]: Current battery charge
percentage after wakeup: 90%
Jul 14 21:21:30 localhost systemd-sleep[567]: Battery was not
discharged during suspension
2022-07-20 17:39:07 +05:30
Sonali Srivastava 96d662fa4c sleep: use current charge level to decide suspension
If battery current charge percentage is below 5% hibernate directly.
Else initial suspend interval is set for HibernateDelaySec. On wakeup
estimate battery discharge rate per hour and if battery charge
percentage is not below 5% system is suspended else hibernated.
2022-07-20 14:46:43 +05:30
Yu Watanabe e1b45a756f tree-wide: fix typo 2022-07-20 13:15:37 +09:00
Yu Watanabe 59159aee20 Merge pull request #24018 from keszybz/generator-cleanups
Make generators easier to test, fix various corner issues
2022-07-16 05:11:49 +09:00
Zbigniew Jędrzejewski-Szmek 911017f052 generators: only redirect logging when invoked by systemd
We would always print output to the kmsg or journal, but that is only needed
and useful when invoked by systemd. So let's skip redirection unless we are
invoked by systemd. Otherwise, let's log normally. This makes test invocations
easier, and also helps when the generator is invoked by mistake. If redirection
is necessary, the generator can be invoked with SYSTEMD_LOG_TARGET=… even
during tests.
2022-07-15 15:48:05 +02:00
Zbigniew Jędrzejewski-Szmek 17021368fc generators: accept one or three args, do not write to /tmp
Since the general generator logic was established in the rewrite in
07719a21b6, generators would always write to /tmp
by default. I think this not a good default at all, because generators write a
bunch of files and would create a mess in /tmp. And for debugging, one
generally needs to remove all the files in the output directory, because
generators will complain in the output paths are already present. Thus the
approach of disabling console logging and writing many files to /tmp when
invoked with no arguments is not nice, so let's disallow operation with no
args.

But when debugging, one generally does not care about the separate output dirs
(most generators use only one). Thus the general pattern I use is something
like:
  rm -rf /tmp/x && mkdir /tmp/x && build/some-generator /tmp/{x,x,x}
This commit allows only one directory to be specified and simplifies this to:
  rm -rf /tmp/x && mkdir /tmp/x && build/some-generator /tmp/x
2022-07-15 13:10:39 +02:00
Lennart Poettering 4f80cfca5e pid1: add mechanism for conditionalizing units/network/netdev/link based on credentials passed in
This is useful when provisioning systems via nspawn/qemu and running
specific services only if specific data is passed into the system.
2022-07-15 10:53:45 +02:00
asavah c3d8a7e21c smack: fix build failure with -Dsmack=false 2022-07-15 04:19:36 +09:00
Lennart Poettering 93cbc9ca12 base-filesystem: pick more conservative access mode for /root/
Let's not allow anyone to look into /root/ if we create it via the
base-filesystem logic. i.e. change 0755 → 0750 as default access mode
for /root/, in case we create it if it happens to be missing.
2022-07-14 18:18:34 +02:00
Luca Boccassi 89f119b654 Merge pull request #23731 from bluca/bootctl_image
bootctl: add --root and --image
2022-07-08 21:59:16 +01:00
Luca Boccassi 80a2381d5c bootctl: add --root and --image
Operate on image/directory, and also take files to install from it
2022-07-08 16:58:15 +01:00
Lennart Poettering 03bc11d1c4 mac: rework labelling code to be simpler, and less racy
This merges the various labelling calls into a single label_fix_full(),
which can operate on paths, on inode fds, and in a dirfd/fname style
(i.e. like openat()). It also systematically separates the path to look
up in the db from the path we actually use to reference the inode to
relabel.

This then ports tmpfiles over to labelling by fd. This should make the
code a bit less racy, as we'll try hard to always operate on the very
same inode, pinning it via an fd.

User-visibly the behaviour should not change.
2022-07-08 17:43:49 +02:00
Lennart Poettering ebbbf44ab9 mkdir-label: don't use mkdirat_errno_wrapper() without reason
mkdirat_errno_wrapper(x,y,z) is identical to RET_NERRNO(mkdirat(x, y,
z)). Let's always use the latter when we can, because easier to read,
shorter.

The only reason to have mkdirat_errno_wrapper() at all is so that we can
pass a function pointer to it around. Otherwise, let's not use it.
2022-07-08 16:10:26 +02:00
Lennart Poettering ef8304de53 smack: catch more types of 'not supported' errors 2022-07-08 16:09:27 +02:00
Yu Watanabe d30d86b7ed dissect: refuse empty release ID 2022-07-06 19:16:24 +09:00
Yu Watanabe 8b2dcbbd00 Revert "dissect: ID from os-release should be non-empty, not just non-NULL"
This reverts commit a2cf73f0b6.

This is not necessary after 78ab2b5064.

Addresses https://github.com/systemd/systemd/pull/23454#discussion_r913611798.
2022-07-06 14:39:54 +09:00
Lennart Poettering 93258c7d72 json: actually use numeric C locale we just allocated
This fixes formatting of JSON real values, and uses C locale for them.
It's kinda interesting that this wasn't noticed before: the C locale
object we allocated was not used, hence doing the dance had zero effect.

This makes "test-varlink" pass again on systems with non-C locale.

(My guess: noone noticed this because "long double" was used before by
the JSON code and that had no locale supporting printer or so?)
2022-07-05 22:14:50 +02:00
Lennart Poettering ff25d3385d tree-wide: add global ascii_isdigit() + ascii_isalpha()
We now have a local implementation in string-util-fundamental.c, but
it's useful at a lot of other places, hence let's give it a more
expressive name and share it across the tree.

Follow-up for: 8d9156660d
2022-07-05 14:25:07 +02:00
nl6720 0e68582323 tree-wide: link to docs.kernel.org for kernel documentation
https://www.kernel.org/ links to https://docs.kernel.org/ for the documentation.
See https://git.kernel.org/pub/scm/docs/kernel/website.git/commit/?id=ebc1c372850f249dd143c6d942e66c88ec610520

These URLs are shorter and nicer looking.
2022-07-04 19:56:53 +02:00
Zbigniew Jędrzejewski-Szmek 025f1279c7 Merge pull request #23088 from yuwata/udev-event-blocker
udev: cleanups for event blocker
2022-07-02 17:08:45 +02:00
Yu Watanabe 3daf1f913c journalctl: fix to show user slice
Fixes #23867.
2022-07-01 09:29:16 +01:00