From 2c85bbaa53da1c7c3becbcb969b9aa388498d388 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 19 Aug 2016 11:01:21 +0200 Subject: [PATCH 1/4] tests: add test from #3979 Let's add one more test that came up during the discussion of an issue. The selected name with 69 chars is above the Linux hostname limit of 64. --- src/test/test-hostname-util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/test-hostname-util.c b/src/test/test-hostname-util.c index 17fde9f27e..1c3d13ed1d 100644 --- a/src/test/test-hostname-util.c +++ b/src/test/test-hostname-util.c @@ -42,6 +42,7 @@ static void test_hostname_is_valid(void) { assert_se(!hostname_is_valid("foo..bar", false)); assert_se(!hostname_is_valid("foo.bar..", false)); assert_se(!hostname_is_valid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", false)); + assert_se(!hostname_is_valid("au-xph5-rvgrdsb5hcxc-47et3a5vvkrc-server-wyoz4elpdpe3.openstack.local", false)); assert_se(hostname_is_valid("foobar", true)); assert_se(hostname_is_valid("foobar.com", true)); From 7c9f396b8aa9346642d5bb163d305ce7127b1685 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 19 Aug 2016 11:02:24 +0200 Subject: [PATCH 2/4] man: document that static/transient hostnames may be 64 chars at max --- man/hostnamectl.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/man/hostnamectl.xml b/man/hostnamectl.xml index 60004e9d04..589a252ea8 100644 --- a/man/hostnamectl.xml +++ b/man/hostnamectl.xml @@ -71,10 +71,9 @@ set, and is valid (something other than localhost), then the transient hostname is not used. - Note that the pretty hostname has little restrictions on the - characters used, while the static and transient hostnames are - limited to the usually accepted characters of Internet domain - names. + Note that the pretty hostname has little restrictions on the characters and length used, while the static and + transient hostnames are limited to the usually accepted characters of Internet domain names, and 64 characters at + maximum (the latter being a Linux limitation). The static hostname is stored in /etc/hostname, see From 0cce63da781878f8e66c15c4b32a61b8d61d03d1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 19 Aug 2016 11:02:55 +0200 Subject: [PATCH 3/4] man: don't claim we replace spaces by dashes when cleaning up hostnames Let's make sure the man page actually documents what is implemented, i.e. "Lennart's PC" turns into "LennartsPC" when we clean up the name. --- man/hostnamectl.xml | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/man/hostnamectl.xml b/man/hostnamectl.xml index 589a252ea8..a7f89b918d 100644 --- a/man/hostnamectl.xml +++ b/man/hostnamectl.xml @@ -138,22 +138,14 @@ set-hostname NAME - Set the system hostname to - NAME. By default, this will alter - the pretty, the static, and the transient hostname alike; - however, if one or more of , - , are - used, only the selected hostnames are changed. If the pretty - hostname is being set, and static or transient are being set - as well, the specified hostname will be simplified in regards - to the character set used before the latter are updated. This - is done by replacing spaces with - and - removing special characters. This ensures that the pretty and - the static hostname are always closely related while still - following the validity rules of the specific name. This - simplification of the hostname string is not done if only the - transient and/or static host names are set, and the pretty - host name is left untouched. + Set the system hostname to NAME. By default, this will alter the + pretty, the static, and the transient hostname alike; however, if one or more of , + , are used, only the selected hostnames are changed. If + the pretty hostname is being set, and static or transient are being set as well, the specified hostname will be + simplified in regards to the character set used before the latter are updated. This is done by removing special + characters and spaces. This ensures that the pretty and the static hostname are always closely related while + still following the validity rules of the specific name. This simplification of the hostname string is not done + if only the transient and/or static host names are set, and the pretty host name is left untouched. Pass the empty string as the hostname to reset the selected hostnames to their default From 986cf85d9481866662ac8a3e1b11ff2b02e3b013 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 19 Aug 2016 11:04:13 +0200 Subject: [PATCH 4/4] man: minor wording fixes --- man/hostnamectl.xml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/man/hostnamectl.xml b/man/hostnamectl.xml index a7f89b918d..9e1b593e6d 100644 --- a/man/hostnamectl.xml +++ b/man/hostnamectl.xml @@ -106,15 +106,11 @@ - If status is used (or no - explicit command is given) and one of those fields is given, - hostnamectl will print out just this - selected hostname. + If status is invoked (or no explicit command is given) and one of these + switches is specified, hostnamectl will print out just this selected hostname. - If used with set-hostname, only the - selected hostname(s) will be updated. When more than one of - those options is used, all the specified hostnames will be - updated. + If used with set-hostname, only the selected hostname(s) will be updated. When more + than one of these switches are specified, all the specified hostnames will be updated.