Commit Graph
313 Commits
Author SHA1 Message Date
Lennart Poettering 4870133bfa basic: add RuntimeScope enum
In various tools and services we have a per-system and per-user concept.
So far we sometimes used a boolean indicating whether we are in system
mode, or a reversed boolean indicating whether we are in user mode, or
the LookupScope enum used by the lookup path logic.

Let's address that, in introduce a common enum for this, we can use all
across the board.

This is mostly just search/replace, no actual code changes.
2023-03-10 09:47:39 +01:00
Lennart Poettering 2b72626ee5 hostnamectl: show support and among output 2023-01-24 15:33:38 +01:00
Lennart Poettering b563d5ce6f hostnamed: expose support end timestamp as property on the bus 2023-01-24 15:32:43 +01:00
Lennart Poettering 02b7005e38 tree-wide: unify how we pick OS pretty name to display 2023-01-24 15:32:42 +01:00
Lennart Poettering 3bac48edfb hostnamectl: show firmware date with date only, without time
The source (usually DMI/SMBIOS) only has 24h granularity, hence don't
show time as well, it's useless.
2023-01-20 17:48:28 +01:00
Jelle van der Waa ad8858c1f7 hostnamed: expose FirmwareDate as timestamp in dbus
Offer the firmware date as an epoch instead of the literal DMI string.

Closes #25679
2023-01-19 21:57:06 +01:00
Jelle van der Waa ff4d26dff4 hostnamed: expose FirmwareDate dbus property
Expose /sys/class/dmi/id/bios_date as dbus property in hostnamed.
2022-12-07 20:35:56 +01:00
Jelle van der Waa f233bbd607 hostnamed: expose FirmwareVendor as dbus property
Expose /sys/class/dmi/id/bios_vendor as dbus property in hostnamed.
2022-12-07 20:34:30 +01:00
David Tardon fa09e36423 hostnamectl: port to vertical table 2022-11-13 20:22:34 +09:00
Zbigniew Jędrzejewski-Szmek 28db6fbff1 Rename def.h to constants.h
The name "def.h" originates from before the rule of "no needless abbreviations"
was established. Let's rename the file to clarify that it contains a collection
of various semi-related constants.
2022-11-08 18:21:10 +01:00
Zbigniew Jędrzejewski-Szmek 3ae6b3bf72 basic: rename util.h to logarithm.h
util.h is now about logarithms only, so we can rename it. Many files included
util.h for no apparent reason… Those includes are dropped.
2022-11-08 18:21:10 +01:00
Zbigniew Jędrzejewski-Szmek d6b4d1c7c4 basic: move version() to build.h+c 2022-11-08 13:41:14 +01:00
Lennart Poettering 32e2767080 tree-wide: use the term "initrd" at most places we so far used "initramfs"
In most cases we refernced the concept as "initrd". Let's convert most
remaining uses of "initramfs" to "initrd" too, to stay internally
consistent.

This leaves "initramfs" only where it's relevant to explain historical
concepts or where "initramfs" is part of the API (i.e. in
/run/initramfs).

Follow-up for: b66a6e1a58
2022-09-23 15:10:53 +02:00
Zbigniew Jędrzejewski-Szmek c8b62cf600 shared/format-table: use enum instead of Table.empty_string
All users were setting this to some static string (usually "-"), so let's
simplify things by not doing strdup, but instead limiting callers to a fixed
set of values. In preparation for the next commit, the function is renamed from
"empty" to "replacement", because it'll be used for more than empty fields. I
didn't do the whole string-table setup, because it's all used internally in one
file and this way we can immediately assert if an invalid value is passed in.

Some callers were (void)ing the error, others were ignoring it, and others
propagating. It's nicer to remove the boilerplate.
2022-09-22 10:16:05 +02:00
Zbigniew Jędrzejewski-Szmek 639405b934 hostnamectl,localectl: use "(unset)" in empty fields
"n/a" is more ambiguous: not available or not set or maybe we didn't check it.
Let's just say directly that the field is not set.
2022-09-21 14:48:28 +02:00
David Tardon 995340074e tree-wide: use ASSERT_PTR more 2022-09-13 08:13:27 +02:00
Yu Watanabe 471fdebfde hostname: make chassis type actually obtained from ACPI when nothing from DMI
Fixes a bug introduced by 8c8b1800e9.

Fixes #24384.
2022-08-22 13:38:26 +09:00
Michael Biebl 41d6f3bf4d Use https for freedesktop.org
grep -l -r http:// | xargs sed -E -i s'#http://(.*).freedesktop.org#https://\1.freedesktop.org#'
2022-06-28 13:10:05 +02:00
Sonali Srivastava 92c9f47d05 hostnamed: update to use new style sd-bus macros 2022-04-21 23:22:52 +02:00
Sonali Srivastava c52950c292 hostnamed: display firmware version 2022-04-19 13:54:16 +02:00
Lennart Poettering 1b86c7c59e virt: make virtualization enum a named type
These days we have a mechanism for safely returning errnos in enum
types, via definining -ERRNO_MAX as one special enu value. Let's use
that for Virtualization.

No change in behaviour, just some typesafety improvement.
2022-04-04 11:36:26 +02:00
Yu Watanabe 798931160e tree-wide: add a space after if, switch, for, and while 2022-04-01 22:48:42 +09:00
Lennart Poettering 38639aa28f hostnamed: properly reset hw model/vendor props before re-reading them
Follow-up for 4fc7e4f374
2022-03-24 21:29:13 +01:00
Lennart Poettering 0924ea2b26 machine-info: rename VENDOR=/MODEL= → HARDWARE_VENDOR=/HARDWARE_MODEL=
Let's be more precise here. Otherwise people might think this describes
the software system or so. We already expose this via hostnamed as
HardwareVendor/HardwareModel hence use the exact same wording.

(Note that the relevant props on the dmi device are just VENDOR/MODEL,
but that's OK given that DMI really is about hardware anyway,
unconditionally, hence no chance of confusion there.)

Follow-up for 4fc7e4f374
2022-03-24 21:29:13 +01:00
Lennart Poettering 67840dbf37 hostnamed: update chassis table to SMBIOS 3.5 2022-03-14 18:44:09 +00:00
Yu Watanabe e5ba040fb8 hostnamectl: use u8 literal specifier 2022-03-11 15:53:18 +09:00
Lennart Poettering e6fccf029b hostnamed: trivial optimization 2022-02-03 22:51:51 +00:00
Lennart Poettering ff28d259c0 hostnamed: drop "iteractive" parameter from GetHardwareSerial()
Since a long time the D-Bus spec knows a special bit in its message
header for indicating that "interactive" authentication is OK. The
original hostnamed API is before that was added hence most functions
expose that boolean as explicit argument.

For new added functions let's get rid of it, the message flag is good
enough and replaces it with complete functionality.

No new APIs should carry the "interactive" boolean flag explicitly as
argument anymore.

Follow-up for: 9697662915
2022-02-03 19:52:18 +00:00
Yu Watanabe 9697662915 hostname: expose hardware serial through dbus
Closes #22119.
2022-01-24 21:09:37 +00:00
Yu Watanabe 4fc7e4f374 hostname: allow to override hardware vendor and model
Sometimes hardware vendor does not set DMI info correctly.
Already there is a way that the dbus properties can be overriden by
using hwdb. But that is not user friendly.

This adds two new fields in /etc/machine-info.

Closes #22207.
2022-01-23 12:48:00 +09:00
Yu Watanabe 8c8b1800e9 hostname: introduce context_get_chassis() and use it everywhere
Follow-up for 4b35eb2579.
2022-01-23 03:11:29 +09:00
Bastien Nocera 4b35eb2579 hostname: Allow overriding the chassis type from hwdb
Closes: #7390
2022-01-21 21:59:09 +01:00
Zbigniew Jędrzejewski-Szmek d6e2c1ab71 policy files: adjust landing page link 2022-01-12 16:05:59 +01:00
Zbigniew Jędrzejewski-Szmek 68cdeab343 hostname: use _cleanup_ in one more place 2021-12-23 13:49:12 +01:00
Zbigniew Jędrzejewski-Szmek 285a6908eb hostnamectl: add a chassis symbol in status output
The idea is to be able to distinguish whether we're in a VM/container or something
more substantial at a glance.
         Chassis: laptop 💻
         Chassis: tablet 具
         Chassis: vm 🖴
         Chassis: server 🖳
         Chassis: handset 🕻
         Chassis: watch ⌚
         Chassis: desktop 🖥
         Chassis: container ☐
2021-12-14 16:49:26 +00:00
Emily Gonyer be7148ebed Change gendered terms to be gender-neutral (#21325)
Some typos are also fixed.
2021-11-12 16:09:56 +01:00
Yu Watanabe e6cbe6970f hostnamed: use /proc/device-tree to get chassis type
From https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-firmware-ofw
---
Userspace must not use the /sys/firmware/devicetree/base
path directly, but instead should follow /proc/device-tree
symlink. It is possible that the absolute path will change
in the future, but the symlink is the stable ABI.
---

Addresses the comment https://github.com/systemd/systemd/pull/20731#discussion_r744095262.
2021-11-11 04:42:50 +09:00
Zbigniew Jędrzejewski-Szmek 10a7340a97 tree-wide: do not print hint about -M if -M is already used
(Or when -H is used, since -H and -M are incompatible.)

Note that the slightly unusual form with separate boolean variables (hint_vars,
hint_addr) instead of e.g. a const char* variable to hold the message, because this
way we don't trigger the warning about non-literal format.
2021-11-04 11:00:54 +01:00
Arnaud Ferraris e6e6ca8251 hostnamed: add support for getting the chassis type from device-tree
Device-tree based devices can't get the chassis type from DMI or ACPI,
and so far need a custom `/etc/machine-info` to set this property right.

A new 'chassis-type' toplevel device tree property has recently been
approved into the DT specification, making it possible to automate
chassis type detection on such devices.

This patch therefore falls back to reading this device-tree property if
nothing is available through both DMI and ACPI.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
2021-09-15 16:46:07 +02:00
Yu Watanabe 0995accdfd hostname: introduce gethostname_full() and use it in various gethostname() variants 2021-08-12 13:48:15 +09:00
Zbigniew Jędrzejewski-Szmek 04499a70fb Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see
them very rarely, if ever. But either way, we just need something that users
can pass to the developers.

We have quite a few of those asserts, and some have fairly nice messages, but
many are like "WTF?" or "???" or "unexpected something". The error that is
printed includes the file location, and function name. In almost all functions
there's at most one assert, so the function name alone is enough to identify
the failure for a developer. So we don't get much extra from the message, and
we might just as well drop them.

Dropping them makes our code a tiny bit smaller, and most importantly, improves
development experience by making it easy to insert such an assert in the code
without thinking how to phrase the argument.
2021-08-03 10:05:10 +02:00
Jan Palus 105a4245ff hostnamed: correct variable with errno in fallback_chassis
fixes assertion failure on arm:

systemd-hostnamed[642]: Assertion '(_error) != 0' failed at src/hostname/hostnamed.c:207, function fallback_chassis(). Aborting.
2021-07-08 09:27:12 +02:00
Yu Watanabe 8fc1efa88f hostnamectl: fix hyperlink in "Operating System" field
This fixes a bug introduced by 822be62fb2.

Before this, if terminal width is not enough, the all subsequent lines
are included in the hyperlink.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1955475.
2021-05-04 15:27:20 +02:00
Jakub Warczarek 572c55ee3c hostnamectl: deprecate set-* methods and expose getters by only using nouns in commands 2021-05-03 20:19:19 +02:00
Lennart Poettering ac8a4f6b78 hostnamectl: add --json= switch for JSON output
This wraps the new Describe() bus call of hostnamed.
2021-04-29 16:39:09 +02:00
Lennart Poettering 7ecead8f08 hostnamed: add Describe() call to hostnamed, returning all props a JSON 2021-04-29 16:39:09 +02:00
Lennart Poettering f8da67cdf2 hostnamed: drop unused enums 2021-04-29 16:39:09 +02:00
Lennart Poettering f2a434a5b8 hostnamed: split out how we determine the hostname a bit
No changes in code, just some splitting out of code we want to use
elsewhere soon.
2021-04-29 16:39:09 +02:00
Lennart Poettering 61d44b6beb hostnamed: refactor vendor/model querying a bit, reuse function 2021-04-29 16:39:09 +02:00
Lennart Poettering c52e295d68 hostnamed: use byte array when we need a byte array
it's more corect this way, but shouldn#t change a thing binary-wise
2021-04-29 16:39:09 +02:00