I am using openwrt build in my AP. using the UCI set command I am able to configure the hostname string which accepts space character within single quote (')
But if I try to change the hostname in LUCI with space character it is not accepting. This looks like a bug to me since two different behaviors for configuring the same hostname.
Kindly let me if this needs to be fixed in Openwrt or LUCI code base?
uci utility will accept arbitrary values, even plain invalid or nonsensical ones.
Hi Jow, Thank you for the response. Did you mean the UCI utility will not be perfect and accepting space is hostname is not correct.
Also the behavior in LUCI is correct?
What he means is that UCI does not perform sanity checks and will accept whatever you give to it.
LuCI, on the other hand, has a lot of sanity check to prevent users from ruining their system with the GUI.
There's no perfect solution as both methods have their pros and cons.
What one considers an advantage is a limitation for the other.
Thanks NoTengoBattery, vgaetera.
In general what is the recommendation for the hostname string? Can it include spaces or any special characters.
I had googled and found the below details
Link : https://stackoverflow.com/questions/3523028/valid-characters-of-a-hostname
Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label must be between 1 and 63 characters long, and the entire hostname (including the delimiting dots but not a trailing dot) has a maximum of 253 ASCII characters.
The Internet standards (Requests for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted.
In terms of hostnames (or usernames), it's better to stay (very) conservative (as in RFC 952) or you will hit subtile problems sooner than later. Postel's Law applies, "Be liberal in what you accept, and conservative in what you send".
Thank Slh, we will check on it