Bug 59311

Summary: hostnamectl doesn't allow apostrophes in pretty hostname
Product: systemd Reporter: Philip Puryear <philippuryear>
Component: generalAssignee: nchen <nathaniel.chen>
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: normal    
Priority: medium CC: garyvdm, nathaniel.chen
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Philip Puryear 2013-01-13 08:33:33 UTC
Overview:
hostnamectl set-hostname rejects pretty hostnames which contain apostrophes, despite the example in hostnamectl's manpage ("Lennart's Laptop") containing an apostrophe.

Steps to Reproduce:
# hostnamectl set-hostname --pretty "Phil's Laptop"

Actual Results:
The error "Failed to issue method call: Invalid argument" is printed.

Expected Results:
No error; /etc/machine-info should contain the supplied pretty name.

Build Date & Platform:
systemd-196, Arch Linux

Additional Information:
I believe this occurs because systemd-hostnamed calls string_is_safe() on the new pretty hostname (hostnamed.c:554), which rejects apostrophes (along with backslashes and double quotes) (util.c:5562).
Comment 1 nchen 2013-03-01 22:13:02 UTC
Just wanted to confirm this bug on Arch, systemd 197

$ hostnamectl set-hostname --pretty "Nathaniel's Desktop"
Failed to issue method call: Invalid argument

$ hostnamectl set-hostname --pretty "Nathaniels Desktop"
$ hostnamectl status
..
Pretty hostname: Nathaniels Desktop

Works without the apostrophe.
Comment 2 nchen 2013-03-05 20:17:31 UTC
fixed with commit "ebe5d6d..."

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.