Commit Graph
50143 Commits
Author SHA1 Message Date
Lennart Poettering 0e08325baa terminal-util: remember error code from tcsetattr() 2024-07-19 11:41:43 +02:00
Lennart Poettering 1c685216f4 terminal-util: turn off echo on stdin, not stdout
This doesn't make much of a different IRL, but it feels more right that
an operation that happens in input is turned off via the input fd.
2024-07-19 11:41:43 +02:00
Lennart Poettering 1df569b2e6 terminal-util: don't process the same data twice when reading back bg color info
If we only read partial information from the tty we ended up parsing it
again and again, confusing the state machine. hence, return how much
data we actually processed and drop it from the buffer.
2024-07-19 11:41:42 +02:00
Lennart Poettering 4c8c499e2c terminal-util: return correct error in chvt() 2024-07-19 11:41:42 +02:00
Lennart Poettering 9a5e421af5 terminal-util: refuse a few more unexpected open flags in open_terminal() 2024-07-19 11:41:42 +02:00
Lennart Poettering 845be16ffd terminal-util: trivial white space fix 2024-07-19 11:41:42 +02:00
Lennart Poettering cc915eefaf env-util: suppress unnecessary setenv() in setenvf() 2024-07-19 11:41:42 +02:00
Lennart Poettering 95a8308d53 vmspawn: make "-n" just work
The tap network device should be called "vt-", so that that the
80-vm-vt.network file we ship by default actually matches against it.

Also, turn off any qemu callout stuff, networkd is smart enough to
handle all this on its own, without ugly callouts.
2024-07-19 11:38:46 +02:00
Luca Boccassi 68d939350f Merge pull request #33591 from teknoraver/o_path
use O_PATH when possible
2024-07-19 11:01:01 +02:00
Luca Boccassi 433b9a6884 Merge pull request #33770 from bluca/polkit-root
polkit: map POLKIT_ALWAYS_QUERY to new polkit flag
2024-07-19 10:57:07 +02:00
Luca Boccassi d108c2d157 Merge pull request #33767 from keszybz/test-ukify-nicer
Make test_ukify not use a real initrd
2024-07-18 17:59:55 +02:00
Luca Boccassi b61d69fae0 polkit: fix typo in enum name 2024-07-18 16:43:56 +01:00
Luca Boccassi 5c48335ef4 polkit: map POLKIT_ALWAYS_QUERY to new polkit flag
polkitd by default just waves through requests from a root process.
A new POLKIT_CHECK_AUTHORIZATION_FLAGS_ALWAYS_CHECK flag was added
to main (will be part of v125 when it ships) that forces it to go
through the policy checks for root too. Previous versions will just
ignore it.

Change the flags handling slightly so that we pass this or the
interactive flags through, as the values match what polkit expects.
2024-07-18 16:11:26 +01:00
Lennart Poettering 46b89b83e3 ptyfwd: reset color after two tty reset sequences, too
When we patch in a bg color we must make sure that when certain "reset"
sequences are transferred we fix up the bg color again.

Do so for \033[!p ("soft terminal reset") and \033c ("reset to initial
state" aka "full reset").
2024-07-18 15:41:33 +02:00
Zbigniew Jędrzejewski-Szmek a669091a43 test_ukify: add instructions
Copied directly from a1d6dbb1c9.
2024-07-18 15:04:28 +02:00
Zbigniew Jędrzejewski-Szmek 87204601df test_ukify: use sha384 in the signing tests
On Fedora, with crypto policy TEST-FEDORA41, sha1 is not allowed:

$ SYSTEMD_LOG_LEVEL=debug build/systemd-measure sign
  --linux=/lib/modules/6.9.7-200.fc40.x86_64/vmlinuz
  --osrel=/tmp/tmp.osrelbl2sr77f
  --cmdline=/tmp/tmp.cmdlineouc7hqtj
  --uname=/tmp/tmp.unamecbjgesty
  --pcrpkey=/tmp/tmpufiadu8l
  --initrd=/boot/3a9d668b4db749398a4a5e78a03bffa5/6.9.7-200.fc40.x86_64/initrd
  --sbat=/tmp/tmp.sbataz9arpy0
  --private-key=/tmp/tmppyf0gx6w
  --public-key=/tmp/tmpufiadu8l
  --bank=sha1
Measuring boot phases: enter-initrd, enter-initrd:leave-initrd, enter-initrd:leave-initrd:sysinit, enter-initrd:leave-initrd:sysinit:ready
Loaded 'libtss2-esys.so.0' via dlopen()
Loaded 'libtss2-rc.so.0' via dlopen()
Loaded 'libtss2-mu.so.0' via dlopen()
PolicyPCR calculated digest: cec1a2ccb188ddd171a2be7bfa6b31cb9148776647354eb1069e0f891ed2dbe7
Failed to initialize signature context: error:03000098:digital envelope routines::invalid digest
Failed to sign PCR policy: Input/output error
2024-07-18 15:04:28 +02:00
Zbigniew Jędrzejewski-Szmek 987f4bce93 test_ukify: do not use files from /boot
They might not be readable to the unprivileged user running the tests
and it shouldn't really matter what is used. OTOH, we need a real kernel
because we look at the header.
2024-07-18 15:04:28 +02:00
Mike Yuan bbddfe5249 Merge pull request #33092 from YHNdnzj/freezer-cleanup
UnitFreezer: several cleanups
2024-07-17 23:45:32 +02:00
Lennart Poettering a68c97a545 sd-device: remove debug log message when dirs are missing
This is a common case, and nothing noteworthy at all. For example, if we
establish an enumerator for listing all devices tagged by some tag, then
the per-tag dir is not going to exist if there are currently no devices
tagged that way, but that's a really common case, and doesn't really
deserve any mention, not even at debug level.
2024-07-17 23:05:12 +02:00
Lennart Poettering f499191c2e main: show different welcome msg in initrd than on the host
It has bugged me for a while that we show the exact same welcome message
at boot twice: once in the initrd, and once after the initrd→host
transition. That's very confusing.

Let's change the text a bit, and tone down the initrd message a bit (by
removing the empty line before and after it), because it is the less
relevant one.
2024-07-17 23:04:46 +02:00
Lennart Poettering ddc6f19e93 varlink-util: minor tweak
Apparently I forgot that in the initial PR. Fix that.

https://github.com/systemd/systemd/pull/33714#pullrequestreview-2177885475
2024-07-17 23:04:28 +02:00
Adrian Vovk c82dfaf7e2 table: Fix JSON name mangling breaking changes
In previous commits, we've changed the JSON name mangling logic. This,
of course, will cause breaking changes to occur on anything that relied
on the JSON mangling logic.

This commit fixes those breaking changes by manually forcing the JSON
name back to what it was before.
2024-07-17 14:15:44 -04:00
Adrian Vovk c4cb49eb34 table: Improve mangling of JSON field names
First, when displaying JSON we convert dashes into underscores. We want
to avoid using dashes in JSON field names in new code, because some
JSON parsers don't support dashes very well.

Second, we make the first character of every word lower-case. This
better matches our JSON field name style, and makes the automatic
JSON name mangling a lot more useful for vertical tables, where fields
are given a display name. For example, "Foo Bar" would be converted into
"foo_bar" instead of "Foo_Bar", which much better matches our style.
We don't make the whole string lowercase to support cases like:
"fooBar" should stay as "fooBar".

Some situations don't behave quite perfectly, such as "Foo BarBaz" gets
converted into "foo_barBaz", or all-caps headings get mangled
incorrectly. In these situations, the JSON field should be overridden
manually. In most cases, or at least more cases than before, this
heuristic does good enough.
2024-07-17 14:15:43 -04:00
Adrian Vovk bf01601f11 table: Add TABLE_SET_JSON_FIELD_NAME
Lets you conveniently set JSON field names in table_add_many. Especially
useful for vertical tables. For example:

table_add_many(t,
               TABLE_FIELD, "Display Name",
               TABLE_STRING, obj->display_name,
               TABLE_SET_JSON_FIELD_NAME, "displayName",
               TABLE_FIELD, "Timestamp",
               TABLE_TIMESTAMP, obj->timestamp,
               TABLE_SET_JSON_FIELD_NAME, "timestampUSec");
2024-07-17 14:15:41 -04:00
Mike Yuan b1ed7e6749 sleep,home: always initialize UnitFreezer if used
Previously, unit_freezer_new_freeze() would only return
UnitFreezer object if FreezeUnit() succeeds. This is not
ideal though, as a failed bus call doesn't mean the action
actually failed. E.g. a timeout might occur because pid1
is waiting for cgroup event from kernel, while the bus call
timeout was exceeded (#33269). In such a case, ThawUnit()
will never be called, resulting in frozen units remain that
way after resuming from sleep.

Therefore, let's get rid of unit_freezer_new_freeze(),
and make sure as long as unit freezer is involved, we'll
call ThawUnit() when we're done. This should make things
a lot more robust.
2024-07-17 18:14:33 +02:00
Mike Yuan 1b5caddfee sleep: also log about errno when getenv_bool fails 2024-07-17 18:14:33 +02:00
Mike Yuan a99935557a sleep: explicitly list valid sleep operations in switch
To follow our usual coding style.
2024-07-17 18:14:32 +02:00
Mike Yuan 6798fa11d2 core/dbus-unit: add an explicit bus error when unit is frozen by parent
While at it, use more accurate errno (EDEADLK) instead of ECHILD.
2024-07-17 18:14:32 +02:00
Mike Yuan e1ac52594d core/unit: introduce unit_freezer_complete, correctly report end state 2024-07-17 18:14:32 +02:00
Mike Yuan 0064290a54 core/unit: introduce unit_set_freezer_state, make logging consistent
Also, emit PropertiesChanged signal for FreezerState too.

Fixes #31115
2024-07-17 18:14:32 +02:00
Mike Yuan a9dc196179 core/cgroup: skip freezer action wholly if current == objective 2024-07-17 18:14:31 +02:00
Mike Yuan 27344f9acf core/cgroup: replace hardcoded state set with freezer_state_finish()
This makes code simpler and more readable.
2024-07-17 18:14:31 +02:00
Mike Yuan 54e1f676a2 core/unit: rename a few more vars for unit_next_freezer_state() 2024-07-17 18:14:31 +02:00
Luca Boccassi 09edabe96a id128: add 'var-partition-uuid' verb
As per DPS the UUID for /var/ should be keyed by the local machine-id,
which is non-trivial to do in a script. Enhance 'systemd-id128' to
take 'var-partition-uuid' as a verb, and if so perform the
calculation.
2024-07-17 18:05:40 +02:00
Mike Yuan aba5e4660f core/unit: use switch for unit_next_freezer_state 2024-07-17 17:25:23 +02:00
Mike Yuan f27f461b01 core/unit: rename freezer "target" to "objective" 2024-07-17 17:25:23 +02:00
Mike Yuan f375a9686f core/slice: simplify slice_freezer_action a bit 2024-07-17 17:25:23 +02:00
Mike Yuan b21bebbe70 core: make unit_can_freeze take const Unit* 2024-07-17 17:25:22 +02:00
Mike Yuan 21fed6eaec core,unit-def: use our usual way of asserting enums 2024-07-17 17:25:22 +02:00
Mike Yuan e2f81f8d40 core/unit: drop pointless unit_freezer_state wrapper 2024-07-17 17:25:22 +02:00
Mike Yuan 4e8b11ca16 core/dbus-unit: use UNIT_IS_LOAD_ERROR where appropriate 2024-07-17 17:25:20 +02:00
Daan De Meyer d9b1ec27f7 Merge pull request #33714 from poettering/make-varlink-public
varlink: make API public as "sd-varlink.h"
2024-07-17 12:58:50 +02:00
Mike Yuan fa96c55b7b id128: refuse --app-specific= if we're listing GPT types
Prompted by #33737

The intention of b37e8184a5
is to expose sd_id128_get_app_specific() on command line.
But combining that with GPT type list makes little sense.
2024-07-17 09:35:58 +02:00
Luca Boccassi f0b151ce86 gpt: add more architecture aliases
Same as the other aliases. Allows chaining commands like:

$ systemd-id128 show -P root-$(dpkg-architecture --query DEB_HOST_ARCH)
4f68bce3e8cd4db196e7fbcaf984b709
2024-07-16 23:12:48 +02:00
Matteo Croce cfa477b615 homed: open blob dir with O_PATH
`sys_base_dfd` is only used as dirfd argument to *_at functions,
open it with O_PATH.
2024-07-16 15:03:37 +02:00
Matteo Croce 2bae668311 homed: use O_PATH for FDs
`Home->pin_fd` is used only for pinning, open it with O_PATH.
2024-07-16 15:03:37 +02:00
Matteo Croce e51d8e0aa4 use O_PATH to get the root fds
`switch_root()` opens two file descriptors to do the switch but never
reads from them. Open them with O_PATH.
2024-07-16 15:03:37 +02:00
Matteo Croce b22befa9f5 use O_PATH to obtain cgroupfs fd
We get a fd to cgroupfs just to avoid it being umounted, O_PATH
is enough, use it instead of O_RDONLY.
2024-07-16 15:03:37 +02:00
Matteo Croce 572e163ef5 use O_PATH when getting cgroup fd
O_PATH mode is enough to attach a bpf program to a cgroup, use it
instead of O_RDONLY
2024-07-16 15:03:37 +02:00
Lennart Poettering 15d19cf86f sd-json/sd-varlink: downgrade assert() → assert_ret()
Our usual rule is that we are more lenient towards misuse for public
users of our code than for ourselves. Or in other words: when validating
parameters of our public functions (those starting with sd_…) we prefer
assert_ret() over assert().
2024-07-16 11:57:32 +02:00