Commit Graph
50152 Commits
Author SHA1 Message Date
Lennart Poettering cfac09083b terminal-util: add new helper terminal_reset_defensive() that combines reset-by-ioctl and reset-by-sequence reasonably 2024-07-19 11:41:43 +02:00
Lennart Poettering ce3a1593bc terminal-util: add terminal_is_pty_fd() helper
The helper checks if an fd references a pty
2024-07-19 11:41:43 +02:00
Lennart Poettering 2736295ddb terminal-util: unify code that resets /dev/console in common helper
We have pretty much the same code at two places, let's make it one.
2024-07-19 11:41:43 +02:00
Lennart Poettering 963e25c23b terminal-util: reset /dev/console via ansi seq also in make_console_stdio()
This appears to have been the intention of
00bc83a275, judging by the comments on
that.
2024-07-19 11:41:43 +02:00
Lennart Poettering f6927e3c98 terminal-util: try to initialize rows/cols via ansi sequence in make_console_stdio()
Let's hook this up.
2024-07-19 11:41:43 +02:00
Lennart Poettering 63c631d7e2 terminal-util: add helper that adjust terminal width/height from data acquired via ANSI sequences 2024-07-19 11:41:43 +02:00
Lennart Poettering 3390be38d1 terminal-util: add helper that queries terminal sizes via ANSI sequence
When we are talking to a serial terminal quite commonly the dimensions
are not set properly, because the serial protocol has not handshake or
similar to transfer this information.

However, we can derive the dimensions via ANSI sequences too, which
should get us the right information, since ANSI sequences are
interpreted by the final terminal, rather than an intermediary local tty
driver (which is where TIOCGWINSZ is interpreted).

This adds a helper call that gets the dimensions this way.
2024-07-19 11:41:43 +02:00
Lennart Poettering 53f0ab5151 terminal-util: rename set_terminal_cursor_position() → terminal_set_cursor_position()
Let's prefix these functions with the subsystem name, and clean them up
a bit. Specifically, drop the error logging, it's entirely duplicative,
since every single caller does it anyway.
2024-07-19 11:41:43 +02:00
Lennart Poettering 445e57387e terminal-util: when querying bg color, ensure input fd and output fd refer to same tty
Let's add an extra safety check: before issuing the ansi sequence to
query the bg color, let's make sure input and output fd actually
reference the same tty. because otherwise it's unlikely we'll be able to
read back the response from the tty driver.

This is mostly just paranoia.
2024-07-19 11:41:43 +02:00
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