| ORG.FREEDESKTOP.HOSTNAME1(5) | org.freedesktop.hostname1 | ORG.FREEDESKTOP.HOSTNAME1(5) |
.SH "NAME" org.freedesktop.hostname1 - The D-Bus interface of
systemd-hostnamed
.SH "INTRODUCTION"
.PP systemd-hostnamed.service(8) is a system service that can be used
to control the hostname and related machine metadata from user programs.
This page describes the hostname semantics and the D-Bus interface.
.SH "THE D-BUS API"
.PP The service exposes the following interfaces on the bus:
node /org/freedesktop/hostname1 {
interface org.freedesktop.hostname1 {
methods:
SetHostname(in s hostname,
in b interactive);
SetStaticHostname(in s hostname,
in b interactive);
SetPrettyHostname(in s hostname,
in b interactive);
SetIconName(in s icon,
in b interactive);
SetChassis(in s chassis,
in b interactive);
SetDeployment(in s deployment,
in b interactive);
SetLocation(in s location,
in b interactive);
SetTags(in as tags);
AddAndRemoveTags(in as add,
in as remove);
GetProductUUID(in b interactive,
out ay uuid);
GetHardwareSerial(out s serial);
Describe(out s json);
GetMachineInfo(in s field,
out s value);
properties:
readonly s Hostname = '...';
readonly s StaticHostname = '...';
readonly s PrettyHostname = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s DefaultHostname = '...';
readonly s HostnameSource = '...';
readonly s IconName = '...';
readonly s Chassis = '...';
readonly s Deployment = '...';
readonly s Location = '...';
readonly as Tags = ['...', ...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s KernelName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s KernelRelease = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s KernelVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemPrettyName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemFancyName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemCPEName = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t OperatingSystemSupportEnd = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HomeURL = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemImageID = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s OperatingSystemImageVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareVendor = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareModel = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareSKU = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s HardwareVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s FirmwareVersion = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s FirmwareVendor = '...';
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly t FirmwareDate = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly ay MachineID = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly ay BootID = [...];
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly u VSockCID = ...;
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
readonly s ChassisAssetTag = '...';
};
interface org.freedesktop.DBus.Peer { ... };
interface org.freedesktop.DBus.Introspectable { ... };
interface org.freedesktop.DBus.Properties { ... };
};
.PP Whenever the hostname or other metadata is changed via the daemon,
PropertyChanged signals are sent out to subscribed clients. Changing
a hostname using this interface is authenticated via polkit[1].
.SH "SEMANTICS"
.PP The StaticHostname property exposes the "static"
hostname configured in /etc/hostname. It is not always in sync with the
current hostname as returned by the gethostname(3) system call. If no
static hostname is configured this property will be the empty string.
.PP When systemd(1) or systemd-hostnamed.service(8) set the
hostname, this static hostname has the highest priority.
.PP The Hostname property exposes the actual hostname configured in
the kernel via sethostname(2). It can be different from the static
hostname. This property is never empty.
.PP The PrettyHostname property exposes the pretty hostname
which is a free-form UTF-8 hostname for presentation to the user. User
interfaces should ensure that the pretty hostname and the static hostname
stay in sync. E.g. when the former is Lennart’s Computer the latter
should be lennarts-computer. If no pretty hostname is set this setting will
be the empty string. Applications should then find a suitable fallback, such
as the dynamic hostname.
.PP The DefaultHostname property exposes the default hostname
(configured through os-release(5), or a fallback set at compilation
time).
.PP The HostnameSource property exposes the origin of the currently
configured hostname. One of static (set from /etc/hostname), transient (a
non-permanent hostname from an external source), default (the value from
os-release or the compiled-in fallback).
.PP The IconName property exposes the icon name following the
XDG icon naming spec. If not set, information such as the chassis type (see
below) is used to find a suitable fallback icon name (i.e. computer-laptop
vs. computer-desktop is picked based on the chassis information). If no such
data is available, the empty string is returned. In that case an application
should fall back to a replacement icon, for example computer. If this
property is set to the empty string, the automatic fallback name selection
is enabled again.
.PP The Chassis property exposes a chassis type, one of the
currently defined chassis types: desktop, laptop, server, tablet, handset,
as well as the special chassis types vm and container for virtualized
systems. Note that in most cases the chassis type will be determined
automatically from DMI/SMBIOS/ACPI firmware information. Writing to this
setting is hence useful only to override misdetected chassis types, or to
configure the chassis type if it could not be auto-detected. Set this
property to the empty string to reenable the automatic detection of the
chassis type from firmware information.
.PP The Tags property exposes a list of machine tags: short
labels that may be used to classify and group machines for management
purposes, for example to identify the role a machine plays in a deployment,
the fleet or organizational unit it belongs to, or any other
administrator-defined attribute. Each individual tag is 1...255 characters
long and consists only of the ASCII alphanumeric characters, - and .. The
tags are stored as a colon-separated list in the TAGS= field of
/etc/machine-info, see machine-info(5) for details. If no tags are
configured this property is the empty list.
.PP Note that systemd-hostnamed starts only on request and terminates after a
short idle period. This effectively means that PropertyChanged
messages are not sent out for changes made directly on the files (as in:
administrator edits the files with vi). This is the intended behavior:
manual configuration changes should require manual reloading.
.PP The transient (dynamic) hostname exposed by the Hostname property
maps directly to the kernel hostname. This hostname should be assumed to be
highly dynamic, and hence should be watched directly, without depending on
PropertyChanged messages from systemd-hostnamed. To accomplish this,
open /proc/sys/kernel/hostname and poll(3) for SIGHUP which is
triggered by the kernel every time the hostname changes. Again: this is
special for the transient (dynamic) hostname, and does not apply to the
configured (fixed) hostname.
.PP Applications may read the hostname data directly if hostname change
notifications are not necessary. Use gethostname(2), /etc/hostname
(possibly with per-distribution fallbacks), and machine-info(5) for
that. For more information on these files and syscalls see the respective
man pages.
.PP KernelName, KernelRelease, and KernelVersion expose
the kernel name (e.g. Linux), release (e.g. 5.0.0-11), and version (i.e. the
build number, e.g. #11) as reported by uname(2).
.PP OperatingSystemPrettyName, OperatingSystemFancyName,
OperatingSystemCPEName, and HomeURL expose the
PRETTY_NAME=, FANCY_NAME=, CPE_NAME= and
HOME_URL= fields from os-release(5). The purpose of those
properties is to allow remote clients to access this information over D-Bus.
Local clients can access the information directly.
.PP MachineID expose the 128bit machine ID, see machine-id(5)
for details.
.PP BootID expose the 128bit boot ID, as per
/proc/sys/kernel/random/boot_id.
.PP VSockCID exposes the system's local AF_VSOCK CID (Context
Identifier, i.e. address) for the system, if one is available in the virtual
machine environment. Set to UINT32_MAX otherwise. See vsock(7)
for details.
.PP OperatingSystemSupportEnd exposes when the OS' vendor support
ends, if this information is known. It's an unsigned 64bit value, in
µs since the UNIX epoch, UTC. If this information is not known
carries the value 2^64-1, i.e. UINT64_MAX.
.PP OperatingSystemImageID and OperatingSystemImageVersion
expose the OS image name and version if available, or contain empty strings
otherwise. This mostly corresponds to the IMAGE_ID= and
IMAGE_VERSION= fields of the os-release file.
.PP HardwareVendor, HardwareModel, HardwareSKU, and
HardwareVersion expose vendor information about the hardware of the
system. The stock keeping unit (SKU) describes a distinct type of hardware
for sale, purchase or inventory management. The SKU and version are only
available if they deviate from the model and among each other. Thereby the
version is more specific and only available if it differs from the model and
SKU. If no such information can be determined these properties are set to
empty strings.
.PP FirmwareVersion and FirmwareVendor expose information about
the system's firmware, i.e. a version string and a vendor name. If no such
information can be determined these properties are set to empty strings.
.PP FirmwareDate exposes the firmware build date, if that information
is known. It's an unsigned 64bit value, in µs since the UNIX epoch,
UTC. If not known UNIT64_MAX.
.PP ChassisAssetTag exposes an unique identifier of the system
chassis. If this information is not known this property is set to an empty
string.
.SS "Methods"
.PP SetHostname() sets the transient (dynamic) hostname, which is used
if no static hostname is set. This value must be an internet-style hostname,
7-bit lowercase ASCII, no special chars/spaces. An empty string will unset
the transient hostname.
.PP SetStaticHostname() sets the static hostname which is exposed by
the StaticHostname property. When called with an empty argument, the
static configuration in /etc/hostname is removed. Since the static hostname
has the highest priority, calling this function usually affects also the
Hostname property and the effective hostname configured in the
kernel.
.PP SetPrettyHostname() sets the pretty hostname which is exposed by
the PrettyHostname property.
.PP SetIconName(), SetChassis(), SetDeployment(), and
SetLocation() set the properties IconName (the name of the
icon representing for the machine), Chassis (the machine form
factor), Deployment (the system deployment environment), and
Location (physical system location), respectively.
.PP SetTags() sets the machine tags exposed by the Tags
property. It takes a list of strings, each of which must be a valid machine
tag (1...255 ASCII alphanumeric characters, - and .). Passing an empty list
removes the TAGS= field from /etc/machine-info.
.PP AddAndRemoveTags() incrementally updates the Tags property
instead of replacing it. It takes two lists of machine tags: the tags in
add are added to the current list, and the tags in remove are
dropped from it (the resulting list is (current ∪ add) \
remove, sorted and deduplicated). This is useful when several
independent agents each manage a subset of the tags without racing on a
read-modify-write of the full list. Each tag must be a valid machine tag, as
for SetTags().
.PP PrettyHostname, IconName, Chassis,
Deployment, Location, and Tags are stored in
/etc/machine-info. See machine-info(5) for the semantics of those
settings.
.PP GetProductUUID() returns the "product UUID" as exposed
by the kernel based on DMI information in /sys/class/dmi/id/product_uuid.
Reading the file directly requires root privileges, and this method allows
access to unprivileged clients through the polkit framework.
.PP GetHardwareSerial() returns the "hardware serial" as
exposed by the kernel based on DMI information. Reading the file directly
requires root privileges, and this method allows access to unprivileged
clients through the polkit framework.
.PP Describe() returns a JSON representation of all properties in
one.
.PP GetMachineInfo() returns the value of the given field from
/etc/machine-info. For well-known fields, this method reads values from the
same internal cache used by the corresponding D-Bus property getters, but
returns only the raw /etc/machine-info values (i.e. without property-level
fallback logic such as DMI/chassis-based detection). Custom (non-standard)
fields are read directly from the file. An error is returned if the field
name is empty, invalid, or not set in the file.
.SS "Security"
.PP The interactive boolean parameters can be used to control whether
polkit should interactively ask the user for authentication credentials if
required.
.PP The polkit action for SetHostname() is
org.freedesktop.hostname1.set-hostname. For SetStaticHostname() and
SetPrettyHostname() it is
org.freedesktop.hostname1.set-static-hostname. For SetIconName(),
SetChassis(), SetDeployment(), SetLocation(),
SetTags() and AddAndRemoveTags() it is
org.freedesktop.hostname1.set-machine-info.
.SH "RECOMMENDATIONS"
.PP Here are three examples that show how the pretty hostname and the icon
name should be used:
.PP To properly handle name lookups with changing local hostnames without
having to edit /etc/hosts, we recommend using systemd-hostnamed in
combination with nss-myhostname(8).
.PP Here are some recommendations to follow when generating a static
(internet) hostname from a pretty name:
.PP Note that while systemd-hostnamed applies some checks to the hostname you
pass they are much looser than the recommendations above. For example,
systemd-hostnamed will also accept _ in the hostname, but we recommend not
using this to avoid clashes with DNS-SD service types. Also
systemd-hostnamed allows longer hostnames, but because of the DNS label
limitations, we recommend not making use of this.
.PP Here are a couple of example conversions:
.PP Of course, an already valid internet hostname label you enter and pass
through this conversion should stay unmodified, so that users have direct
control of it, if they want — by simply ignoring the fact that the
pretty hostname is pretty and just edit it as if it was the normal internet
name.
.SH "EXAMPLES"
.PP Example 1. Introspect org.freedesktop.hostname1 on the
bus
$ gdbus introspect --system \
--dest org.freedesktop.hostname1 \
--object-path /org/freedesktop/hostname1
.SH "VERSIONING"
.PP These D-Bus interfaces follow the usual interface versioning
guidelines[2].
.SH "HISTORY"
.SS "The D-Bus API"
.PP FirmwareVersion and GetHardwareSerial() were added in
version 251.
.PP OperatingSystemSupportEnd, FirmwareVendor, and
FirmwareDate were added in version 253.
.PP MachineID, BootID and VSockCID were added in version
256.
.PP ChassisAssetTag, OperatingSystemImageID,
OperatingSystemImageVersion, HardwareSKU, and
HardwareVersion were added in version 258.
.PP OperatingSystemFancyName was added in version 260.
.PP GetMachineInfo(), Tags and SetTags() were added in
version 261.
.PP AddAndRemoveTags() was added in version 262.
.SH "SEE ALSO"
.PP systemd(1), systemd-hostnamed.service(8),
hostnamectl(1), David Zeuthen's original Fedora Feature page about
xdg-hostname[3]
NOTES
- 1.
- polkit
- 2.
- the usual interface versioning guidelines
- 3.
- Feature page about xdg-hostname
| systemd 262.2 |