diff --git a/man/custom-entities.ent.in b/man/custom-entities.ent.in
index 84a29f5de4..03fe05f1bc 100644
--- a/man/custom-entities.ent.in
+++ b/man/custom-entities.ent.in
@@ -6,6 +6,7 @@
+
diff --git a/man/org.freedesktop.hostname1.xml b/man/org.freedesktop.hostname1.xml
new file mode 100644
index 0000000000..a381cb8239
--- /dev/null
+++ b/man/org.freedesktop.hostname1.xml
@@ -0,0 +1,236 @@
+
+
+
+%entities;
+]>
+
+
+
+
+ org.freedesktop.hostname1
+ systemd
+
+
+
+ org.freedesktop.hostname1
+ 5
+
+
+
+ org.freedesktop.hostname1
+ The D-Bus interface of systemd-hostnamed
+
+
+
+ Introduction
+
+
+ systemd-hostnamed.service8
+ is a system service that can be used to control the host name and related machine meta data from user
+ programs. This page describes the hostname semantics and the D-Bus interface.
+
+
+
+ The D-Bus API
+
+ The service exposes the following interfaces on the bus:
+
+
+$ gdbus introspect --system \
+ --dest org.freedesktop.hostname1 \
+ --object-path /org/freedesktop/hostname1
+
+node /org/freedesktop/hostname1 {
+ interface org.freedesktop.hostname1 {
+ methods:
+ SetHostname(in s name,
+ in b user_interaction);
+ SetStaticHostname(in s name,
+ in b user_interaction);
+ SetPrettyHostname(in s name,
+ in b user_interaction);
+ SetIconName(in s name,
+ in b user_interaction);
+ SetChassis(in s name,
+ in b user_interaction);
+ signals:
+ properties:
+ readonly s Hostname = 'dhcp-192-168-47-11';
+ readonly s StaticHostname = 'lennarts-computer';
+ readonly s PrettyHostname = 'Lennart’s Computer';
+ readonly s IconName = 'computer-laptop';
+ readonly s Chassis = 'laptop';
+ };
+ interface org.freedesktop.DBus.Properties {
+ };
+ interface org.freedesktop.DBus.Introspectable {
+ };
+ interface org.freedesktop.DBus.Peer {
+ };
+};
+
+
+ Whenever the hostname or other meta data is changed via the daemon,
+ PropertyChanged signals are sent out to subscribed clients. Changing a hostname
+ using this interface is authenticated via PolicyKit.
+
+
+
+ Semantics
+
+ The static (configured) host name is the one configured in
+ /etc/hostname. It is chosen by the local user. It is not always in sync with the
+ current hostname as returned by the
+ gethostname3
+ system call. If no host name is configured this property will be the empty string. Setting this property
+ to the empty string will remove /etc/hostname. This hostname should be an
+ internet-style hostname, 7-bit lowercase ASCII, no special chars/spaces.
+
+ The transient (dynamic) host name is the one configured via the kernel's
+ sethostname3.
+ It can be different from the static hostname in case DHCP or mDNS have been configured to change the name
+ based on network information.
+ This property is never empty. If no hostname is set this will default to
+ &FALLBACK_HOSTNAME; (configurable at compilation time). Setting this property to the
+ empty string will reset the dynamic hostname to the static host name. If no static host name is
+ configured the dynamic host name will be reset to &FALLBACK_HOSTNAME;. This hostname
+ should be an internet-style hostname, 7-bit lowercase ASCII, no special chars/spaces.
+
+ The pretty host name is a free-form UTF-8 host name for presentation to the
+ user. User interfaces should ensure that the pretty hostname and the static hostname stay in sync.
+ I.e. when the former is Lennart’s Computer the latter should be
+ lennarts-computer. If no pretty host name is set this setting will be the empty
+ string. Applications should then find a suitable fallback, such as the dynamic hostname.
+
+ The icon name is a 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, returns the empty string. In that case an application
+ should fall back to a replacement icon, for example computer. If this property is set
+ to the empty string, this automatic fallback name selection is enabled again.
+
+ The chassis type should be one of the following that are currently defined:
+ 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 configure a chassis type if
+ none could be auto-detected. Set this property to the empty string to reenable the automatic detection of
+ the chassis type from firmware information.
+
+ A client which wants to change the local host name for DHCP/mDNS should invoke
+ SetHostname("newname", false) as soon as the name is available and afterwards reset it via
+ SetHostname("").
+
+ 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
+ actually intended behavior: manual configuration changes should require manual reloading of them.
+
+ The transient (dynamic) hostname directly maps to the kernel hostname. This hostname should be
+ assumed to be highly dynamic, and hence should be watched directly, without involving
+ PropertyChanged messages from systemd-hostnamed. For that, open
+ /proc/sys/kernel/hostname and
+ poll3
+ 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.
+
+ Applications may bypass the daemon to read the hostname data if notifications of host name changes
+ are not necessary. Use
+ gethostname3,
+ /etc/hostname (possibly with per-distribution fallbacks), and
+ machine-info3
+ for that. For more information on these files and syscalls see the respective man pages.
+
+ The user_interaction boolean parameters can be used to control whether PolicyKit should
+ interactively ask the user for authentication credentials if it needs to.
+
+ The PolicyKit action for SetHostname() is
+ org.freedesktop.hostname1.set-hostname. For
+ SetStaticHostname() and SetPrettyHostname() it is
+ org.freedesktop.hostname1.set-static-hostname. For
+ SetIconName() and SetChassis() it is
+ org.freedesktop.hostname1.set-machine-info.
+
+ Here are three examples how the pretty hostname and the icon name should be used:
+
+ When registering DNS-SD services: use the pretty host name in the service name, and
+ pass the icon name in the TXT data, if there is an icon name. Browsing clients can then show the server
+ icon on each service. Especially useful for WebDAV stuff. Similar for UPnP media
+ sharing.
+
+ Set the bluetooth name to the pretty host name.
+
+ When your file browser has a "Computer" icon, replace the name with the pretty hostname if set, and the icon with the icon name, if it is set.
+
+
+ To properly handle name lookups with changing local hostnames without having to edit
+ /etc/hosts for them, we recommend using systemd-hostnamed in
+ combination with nss-myhostname3.
+
+
+ Here are some recommendations to follow when generating a static (internet) hostname from a pretty
+ name:
+
+ Generate a single DNS label only, not an FQDN. That means no dots allowed. Strip them,
+ or replace them by -.
+
+ It's probably safer not to use any non-ASCII chars, even if DNS allows this in some way
+ these days. In fact, restrict your charset to a-zA-Z0-9 and -.
+ Strip other chars, or try to replace them in some smart way with chars from this set, for example
+ ä → ae, and use - as replacement for all kinds
+ of punctuation chars or spaces.
+
+ Try to avoid creating repeated -, as well as - as
+ the first or last char.
+
+ Limit the hostname to 63 chars, which is the length of a DNS label.
+
+ If after stripping special chars the empty string is the result, you can pass this
+ as-is to systemd-hostnamed in which case it will automatically make
+ &FALLBACK_HOSTNAME; out of this.
+
+ It probably is a good idea to replace uppercase by lowercase chars.
+
+
+ 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 I'd 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, I'd recommend not making use of this.
+
+ Here are a couple of example conversions:
+
+ Lennart's PC → lennarts-pc
+ Müllers Computer → muellers-computer
+ Voran! → voran
+ Es war einmal ein Männlein → es-war-einmal-ein-maennlein
+ Jawoll. Ist doch wahr! → jawoll-ist-doch-wahr
+ レナート → localhost
+ ...zack!!! zack!... → zack-zack
+
+
+ Oh, and 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.
+
+
+
+ Versioning
+
+ These D-Bus interfaces follow
+ the usual interface versioning guidelines.
+
+
+
+ See also
+
+ David Zeuthen's original Fedora
+ Feature page about xdg-hostname
+
+
diff --git a/man/rules/meson.build b/man/rules/meson.build
index 6beed3f6dd..d69286301b 100644
--- a/man/rules/meson.build
+++ b/man/rules/meson.build
@@ -44,6 +44,7 @@ manpages = [
['nss-mymachines', '8', ['libnss_mymachines.so.2'], 'ENABLE_NSS_MYMACHINES'],
['nss-resolve', '8', ['libnss_resolve.so.2'], 'ENABLE_NSS_RESOLVE'],
['nss-systemd', '8', ['libnss_systemd.so.2'], 'ENABLE_NSS_SYSTEMD'],
+ ['org.freedesktop.hostname1', '5', [], 'ENABLE_HOSTNAMED'],
['org.freedesktop.import1', '5', [], 'ENABLE_IMPORTD'],
['org.freedesktop.login1', '5', [], 'ENABLE_LOGIND'],
['org.freedesktop.machine1', '5', [], 'ENABLE_MACHINED'],
diff --git a/man/systemd-hostnamed.service.xml b/man/systemd-hostnamed.service.xml
index 19bd4c06f2..185e038809 100644
--- a/man/systemd-hostnamed.service.xml
+++ b/man/systemd-hostnamed.service.xml
@@ -18,7 +18,7 @@
systemd-hostnamed.service
systemd-hostnamed
- Host name bus mechanism
+ Daemon to control system hostname from programs
@@ -29,19 +29,35 @@
Description
- systemd-hostnamed is a system service
- that may be used as a mechanism to change the system's hostname.
- systemd-hostnamed is automatically activated
- on request and terminates itself when it is unused.
+ systemd-hostnamed.service is a system service that may be used to change the
+ system's hostname and related machine meta data from user programs. It is automatically activated on
+ request and terminates itself when unused.
+
+ It currently offers access to five variables:
+
+ The current host name (Example: dhcp-192-168-47-11)
+
+
+ The static (configured) host name (Example:
+ lennarts-computer)
+
+ The pretty host name (Example: Lennart's Computer)
+
+
+ A suitable icon name for the local host (Example:
+ computer-laptop)
+
+ A chassis type (Example: tablet)
+
+
The tool
hostnamectl1
is a command line client to this service.
- See the
- developer documentation for information about the APIs
- systemd-hostnamed provides.
+ See the
+ org.freedesktop.hostname11
+ for a description of the D-Bus API.