summaryrefslogtreecommitdiffstats
path: root/src/hostname (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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-221-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-101-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-01-312-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.
* hostname: fix build failureYu Watanabe2020-12-181-1/+0
| | | | | | Follow-up for b9d8069832425b34211a6812e06537e0c50d46b6. libudev.h was dropped from most of our binaries.
* Merge pull request #15531 from felipeborges/add-device-model-field-to-hostnamedLennart Poettering2020-12-182-0/+64
|\ | | | | hostnamed: Add "Model" field
| * hostnamed: Expose dmi "Vendor" and "Model" fieldsFelipe Borges2020-12-042-0/+64
| | | | | | | | See #15493
* | hostnamed,shared/hostname-setup: expose the origin of the current hostnameZbigniew Jędrzejewski-Szmek2020-12-161-43/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In hostnamed this is exposed as a dbus property, and in the logs in both places. This is of interest to network management software and such: if the fallback hostname is used, it's not as useful as the real configured thing. Right now various programs try to guess the source of hostname by looking at the string. E.g. "localhost" is assumed to be not the real hostname, but "fedora" is. Any such attempts are bound to fail, because we cannot distinguish "fedora" (a fallback value set by a distro), from "fedora" (received from reverse dns), from "fedora" read from /etc/hostname. /run/systemd/fallback-hostname is written with the fallback hostname when either pid1 or hostnamed sets the kernel hostname to the fallback value. Why remember the fallback value and not the transient hostname in /run/hostname instead? We have three hostname types: "static", "transient", fallback". – Distinguishing "static" is easy: the hostname that is set matches what is in /etc/hostname. – Distingiushing "transient" and "fallback" is not easy. And the "transient" hostname may be set outside of pid1+hostnamed. In particular, it may be set by container manager, some non-systemd tool in the initramfs, or even by a direct call. All those mechanisms count as "transient". Trying to get those cases to write /run/hostname is futile. It is much easier to isolate the "fallback" case which is mostly under our control. And since the file is only used as a flag to mark the hostname as fallback, it can be hidden inside of our /run/systemd directory. For https://bugzilla.redhat.com/show_bug.cgi?id=1892235.
* | hostnamed: stop discriminating against "localhost" in /etc/hostnameZbigniew Jędrzejewski-Szmek2020-12-161-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We would sometimes ignore localhost-style names in /etc/hostname. That is brittle. If the user configured some hostname, it's most likely because they want to use that as the hostname. If they don't want to use such a hostname, they should just not create the config. Everything becomes simples if we just use the configured hostname as-is. This behaviour seems to have been a workaround for Anaconda installer and other tools writing out /etc/hostname with the default of "localhost.localdomain". Anaconda PR to stop doing that: https://github.com/rhinstaller/anaconda/pull/3040. That might have been useful as a work-around for other programs misbehaving if /etc/hostname was not present, but nowadays it's not useful because systemd mostly controls the hostname and it is perfectly happy without that file. Apart from making things simpler, this allows users to set a hostname like "localhost" and have it honoured, if such a whim strikes them.
* | hostnamed: improve message about static hostnameZbigniew Jędrzejewski-Szmek2020-12-161-1/+4
| | | | | | | | Changed static hostname to 'n/a' is not very nice.