summaryrefslogtreecommitdiff
path: root/src/hostname
Commit message (Collapse)AuthorAgeFilesLines
* hostnamed: update to use new style sd-bus macrosSonali Srivastava2022-04-211-62/+45
|
* hostnamed: display firmware versionSonali Srivastava2022-04-192-21/+62
|
* virt: make virtualization enum a named typeLennart Poettering2022-04-041-1/+2
| | | | | | | | 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.
* tree-wide: add a space after if, switch, for, and whileYu Watanabe2022-04-011-1/+1
|
* hostnamed: properly reset hw model/vendor props before re-reading themLennart Poettering2022-03-241-1/+3
| | | | Follow-up for 4fc7e4f374bf4401330e90e267227267abf1dcac
* machine-info: rename VENDOR=/MODEL= → HARDWARE_VENDOR=/HARDWARE_MODEL=Lennart Poettering2022-03-241-11/+11
| | | | | | | | | | | | 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 4fc7e4f374bf4401330e90e267227267abf1dcac
* hostnamed: update chassis table to SMBIOS 3.5Lennart Poettering2022-03-141-7/+13
|
* hostnamectl: use u8 literal specifierYu Watanabe2022-03-111-8/+8
|
* hostnamed: trivial optimizationLennart Poettering2022-02-031-3/+4
|
* hostnamed: drop "iteractive" parameter from GetHardwareSerial()Lennart Poettering2022-02-031-8/+3
| | | | | | | | | | | | | | | 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: 9697662915e47a4797b05003cb1970fe2b01e530
* hostname: expose hardware serial through dbusYu Watanabe2022-01-242-4/+105
| | | | Closes #22119.
* hostname: allow to override hardware vendor and modelYu Watanabe2022-01-231-15/+36
| | | | | | | | | | 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.
* hostname: introduce context_get_chassis() and use it everywhereYu Watanabe2022-01-231-52/+61
| | | | Follow-up for 4b35eb2579b226785f0d94129a7652450f9723fd.
* hostname: Allow overriding the chassis type from hwdbBastien Nocera2022-01-211-5/+7
| | | | Closes: #7390
* policy files: adjust landing page linkZbigniew Jędrzejewski-Szmek2022-01-121-1/+1
|
* hostname: use _cleanup_ in one more placeZbigniew Jędrzejewski-Szmek2021-12-231-14/+11
|
* hostnamectl: add a chassis symbol in status outputZbigniew Jędrzejewski-Szmek2021-12-141-1/+27
| | | | | | | | | | | | | 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 ☐
* Change gendered terms to be gender-neutral (#21325)Emily Gonyer2021-11-121-1/+1
| | | Some typos are also fixed.
* hostnamed: use /proc/device-tree to get chassis typeYu Watanabe2021-11-111-1/+1
| | | | | | | | | | | | 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.
* tree-wide: do not print hint about -M if -M is already usedZbigniew Jędrzejewski-Szmek2021-11-041-1/+1
| | | | | | | | (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.
* hostnamed: add support for getting the chassis type from device-treeArnaud Ferraris2021-09-151-5/+23
| | | | | | | | | | | | | | 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>
* hostname: introduce gethostname_full() and use it in various gethostname() ↵Yu Watanabe2021-08-121-3/+4
| | | | variants
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | 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.
* hostnamed: correct variable with errno in fallback_chassisJan Palus2021-07-081-4/+4
| | | | | | fixes assertion failure on arm: systemd-hostnamed[642]: Assertion '(_error) != 0' failed at src/hostname/hostnamed.c:207, function fallback_chassis(). Aborting.
* hostnamectl: fix hyperlink in "Operating System" fieldYu Watanabe2021-05-041-9/+2
| | | | | | | | | This fixes a bug introduced by 822be62fb23ed0ec1062ffd18057e53f6c2f8c01. 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.
* hostnamectl: deprecate set-* methods and expose getters by only using nouns ↵Jakub Warczarek2021-05-031-32/+50
| | | | in commands
* hostnamectl: add --json= switch for JSON outputLennart Poettering2021-04-291-2/+47
| | | | This wraps the new Describe() bus call of hostnamed.
* hostnamed: add Describe() call to hostnamed, returning all props a JSONLennart Poettering2021-04-291-0/+108
|
* hostnamed: drop unused enumsLennart Poettering2021-04-291-3/+2
|
* hostnamed: split out how we determine the hostname a bitLennart Poettering2021-04-291-27/+32
| | | | | No changes in code, just some splitting out of code we want to use elsewhere soon.
* hostnamed: refactor vendor/model querying a bit, reuse functionLennart Poettering2021-04-291-25/+44
|
* hostnamed: use byte array when we need a byte arrayLennart Poettering2021-04-291-1/+1
| | | | it's more corect this way, but shouldn#t change a thing binary-wise
* hostnamed: retrieve product UUID after authentication, not beforeLennart Poettering2021-04-291-12/+12
|
* id128-util: use common implementation of helper to get/validate product IDLennart Poettering2021-04-291-12/+8
|
* hostnamed: rename FallbackHostname to DefaultHostnameZbigniew Jędrzejewski-Szmek2021-02-221-7/+7
| | | | | | | | | This follows the addition of DEFAULT_HOSTNAME= in os-release. The distinction between the value from os-release or the env var and the compile-time setting is not made in the api: HostnameSource is "default" is all cases. I think that this level of detail is not needed, because the users of this mostly care whether the hostname was set by user configuration or not.
* Allow the fallback hostname to be overriden using an environment variableZbigniew Jędrzejewski-Szmek2021-02-221-9/+31
| | | | | | | | | | | | | | See https://bugzilla.redhat.com/show_bug.cgi?id=1893417 for the back story: the fallback hostname matters a lot in certain environments. Right now the only way to configure the fallback hostname is by recompiling systemd, which is obviously problematic in case when the fallback hostname shall differ between different editions of the same distro that share a single compiled rpm. By making this overridable through an envvar, we're providing an escape hatch without making this a top-level api. Later on a way to set this through os-release is added, but I think the approach with the variable is still useful. It it very convenient for testing, or to override settings only in a particular service, etc.
* basic/os-util: make the sentinel implicitZbigniew Jędrzejewski-Szmek2021-02-221-2/+1
|
* basic/env-util: add strv_env_assign() helperZbigniew Jędrzejewski-Szmek2021-02-161-17/+3
|
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* hostnamectl: use TableYu Watanabe2021-02-091-49/+145
|
* hostnamectl: show hint when user try to set transient hostname but static ↵Yu Watanabe2021-02-091-3/+29
| | | | hostname is already used
* hostname: use free_and_strdup_and_warn()Yu Watanabe2021-02-091-2/+2
|
* hostname: re-read file later when failed to update fileYu Watanabe2021-02-091-8/+38
| | | | | | | | | | | | | | | | | | | | Previously, even when writing e.g. /etc/hostname fails, the static hostname in Context is not restored. So, the subsequent call of the same method succeeds: ``` $ sudo chattr +i /etc/hostname $ sudo hostnamectl --static set-hostname aaa Could not set static hostname: Access denied $ echo $? 1 $ sudo hostnamectl --static set-hostname aaa $ echo $? 0 ``` This makes when updating file is failed, the saved stat is cleared. So, the static hostname or machine information in the context are always consistent to the corresponding files.
* hostnamectl: unset pretty hostname only when no target is specifiedYu Watanabe2021-02-091-1/+1
|
* hostnamectl: try to set transient hostname even if updating static or pretty ↵Yu Watanabe2021-02-091-13/+44
| | | | | | | | hostname failed If no target (--pretty, --static, or --transient) is specified, then let's try to set transient hostname even if setting static or pretty hostname failed. This may be useful for read-only filesystem.
* hostname: introduce two bus errors for updating fileYu Watanabe2021-02-091-0/+8
|
* hostnamectl: improve log message on failureYu Watanabe2021-02-091-10/+10
|
* tree-wide: enable colorized logging for daemons when run in consoleYu Watanabe2021-02-012-2/+2
| | | | It may be useful when debugging daemons.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-6/+5
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* hostname: accept an empty hostname to unset transient hostnameYu Watanabe2021-01-221-1/+1
| | | | | | | | Follow-up for 60e4fb4240b24bdd2d4299d8d844f48093df8807. Before 60e4fb4240b24bdd2d4299d8d844f48093df8807, `hostnamectl --transient set-hostname ""` unsets the transient hostname. But after the commit, it is refused. This fixes the issue.