* [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" @ 2011-04-11 5:01 Josh Triplett 2011-04-11 12:39 ` Serge E. Hallyn ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Josh Triplett @ 2011-04-11 5:01 UTC (permalink / raw) To: David Miller, netdev, Serge E. Hallyn, Andrew Morton, Linus Torvalds The "hostname" tool falls back to setting the hostname to "localhost" if /etc/hostname does not exist. Distribution init scripts have the same fallback. However, if userspace never calls sethostname, such as when booting with init=/bin/sh, or otherwise booting a minimal system without the usual init scripts, the default hostname of "(none)" remains, unhelpfully appearing in various places such as prompts ("root@(none):~#") and logs. Furthrmore, "(none)" doesn't typically resolve to anything useful, while "localhost" does. Change the default hostname to "localhost". This removes the need for the standard fallback, provides a useful default for systems that never call sethostname, and makes minimal systems that much more useful with less configuration. Signed-off-by: Josh Triplett <josh@joshtriplett.org> --- Looked at "(none)" one too many times, and figured I ought to do something about it. Resending, and adding CCs for networking and UTS. include/linux/uts.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/linux/uts.h b/include/linux/uts.h index 73eb1ed..610bec2 100644 --- a/include/linux/uts.h +++ b/include/linux/uts.h @@ -9,7 +9,7 @@ #endif #ifndef UTS_NODENAME -#define UTS_NODENAME "(none)" /* set by sethostname() */ +#define UTS_NODENAME "localhost" /* set by sethostname() */ #endif #ifndef UTS_DOMAINNAME -- 1.7.4.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" 2011-04-11 5:01 [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" Josh Triplett @ 2011-04-11 12:39 ` Serge E. Hallyn 2011-04-11 15:02 ` Stephen Hemminger 2011-04-12 2:47 ` Valdis.Kletnieks 2 siblings, 0 replies; 6+ messages in thread From: Serge E. Hallyn @ 2011-04-11 12:39 UTC (permalink / raw) To: Josh Triplett Cc: David Miller, netdev, Andrew Morton, Linus Torvalds, linux-kernel Quoting Josh Triplett (josh@joshtriplett.org): > The "hostname" tool falls back to setting the hostname to "localhost" if > /etc/hostname does not exist. Distribution init scripts have the same > fallback. However, if userspace never calls sethostname, such as when > booting with init=/bin/sh, or otherwise booting a minimal system without > the usual init scripts, the default hostname of "(none)" remains, > unhelpfully appearing in various places such as prompts > ("root@(none):~#") and logs. Furthrmore, "(none)" doesn't typically > resolve to anything useful, while "localhost" does. > > Change the default hostname to "localhost". This removes the need for > the standard fallback, provides a useful default for systems that never > call sethostname, and makes minimal systems that much more useful with > less configuration. > > Signed-off-by: Josh Triplett <josh@joshtriplett.org> Seems good to me. I'd have no idea if there were valid reasons to object to such a thing so my ack means nothing, but Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com> thanks, -serge > --- > > Looked at "(none)" one too many times, and figured I ought to do > something about it. > > Resending, and adding CCs for networking and UTS. > > include/linux/uts.h | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/include/linux/uts.h b/include/linux/uts.h > index 73eb1ed..610bec2 100644 > --- a/include/linux/uts.h > +++ b/include/linux/uts.h > @@ -9,7 +9,7 @@ > #endif > > #ifndef UTS_NODENAME > -#define UTS_NODENAME "(none)" /* set by sethostname() */ > +#define UTS_NODENAME "localhost" /* set by sethostname() */ > #endif > > #ifndef UTS_DOMAINNAME > -- > 1.7.4.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" 2011-04-11 5:01 [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" Josh Triplett 2011-04-11 12:39 ` Serge E. Hallyn @ 2011-04-11 15:02 ` Stephen Hemminger 2011-04-11 15:12 ` Linus Torvalds 2011-04-12 2:47 ` Valdis.Kletnieks 2 siblings, 1 reply; 6+ messages in thread From: Stephen Hemminger @ 2011-04-11 15:02 UTC (permalink / raw) To: Josh Triplett Cc: David Miller, netdev, Serge E. Hallyn, Andrew Morton, Linus Torvalds, linux-kernel On Sun, 10 Apr 2011 22:01:59 -0700 Josh Triplett <josh@joshtriplett.org> wrote: > The "hostname" tool falls back to setting the hostname to "localhost" if > /etc/hostname does not exist. Distribution init scripts have the same > fallback. However, if userspace never calls sethostname, such as when > booting with init=/bin/sh, or otherwise booting a minimal system without > the usual init scripts, the default hostname of "(none)" remains, > unhelpfully appearing in various places such as prompts > ("root@(none):~#") and logs. Furthrmore, "(none)" doesn't typically > resolve to anything useful, while "localhost" does. > > Change the default hostname to "localhost". This removes the need for > the standard fallback, provides a useful default for systems that never > call sethostname, and makes minimal systems that much more useful with > less configuration. > > Signed-off-by: Josh Triplett <josh@joshtriplett.org> > --- > > Looked at "(none)" one too many times, and figured I ought to do > something about it. > > Resending, and adding CCs for networking and UTS. > > include/linux/uts.h | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/include/linux/uts.h b/include/linux/uts.h > index 73eb1ed..610bec2 100644 > --- a/include/linux/uts.h > +++ b/include/linux/uts.h > @@ -9,7 +9,7 @@ > #endif > > #ifndef UTS_NODENAME > -#define UTS_NODENAME "(none)" /* set by sethostname() */ > +#define UTS_NODENAME "localhost" /* set by sethostname() */ > #endif > > #ifndef UTS_DOMAINNAME It makes sense but this behavior has existed so long in Linux that some distro might actually be depending on it. -- ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" 2011-04-11 15:02 ` Stephen Hemminger @ 2011-04-11 15:12 ` Linus Torvalds 2011-04-11 18:53 ` Josh Triplett 0 siblings, 1 reply; 6+ messages in thread From: Linus Torvalds @ 2011-04-11 15:12 UTC (permalink / raw) To: Stephen Hemminger Cc: Josh Triplett, David Miller, netdev, Serge E. Hallyn, Andrew Morton, linux-kernel On Mon, Apr 11, 2011 at 8:02 AM, Stephen Hemminger <shemminger@vyatta.com> wrote: > > It makes sense but this behavior has existed so long in Linux > that some distro might actually be depending on it. Yes. Also, quite frankly, I do _not_ think that "localhost" is in any way a more correct hostname. I'd rather have an obviously invalid hostname for a machine that hasn't been set up correctly than one that might work by random chance. Linus ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" 2011-04-11 15:12 ` Linus Torvalds @ 2011-04-11 18:53 ` Josh Triplett 0 siblings, 0 replies; 6+ messages in thread From: Josh Triplett @ 2011-04-11 18:53 UTC (permalink / raw) To: Linus Torvalds Cc: Stephen Hemminger, David Miller, netdev, Serge E. Hallyn, Andrew Morton, linux-kernel On Mon, Apr 11, 2011 at 08:12:40AM -0700, Linus Torvalds wrote: > On Mon, Apr 11, 2011 at 8:02 AM, Stephen Hemminger > <shemminger@vyatta.com> wrote: > > It makes sense but this behavior has existed so long in Linux > > that some distro might actually be depending on it. I checked fairly thoroughly for evidence of userspace relying on "(none)", and found no instances of that. Userspace typically just says "I haven't set it yet, so nobody has set it yet", and unconditionally sets the hostname. dhclient doesn't rely on "(none)", distro networking scripts don't rely on "(none)", the hostname tool doesn't rely on "(none)", and nothing else I've found looks for "(none)". That said, I'll certainly acknowledge that some random userspace bits somewhere could have relied on this behavior. Would a transitional period help at all here? Alternatively, see below. > Yes. Also, quite frankly, I do _not_ think that "localhost" is in any > way a more correct hostname. > > I'd rather have an obviously invalid hostname for a machine that > hasn't been set up correctly than one that might work by random > chance. Choosing "localhost" for systems that don't configure a hostname at least makes it fairly likely that you can resolve the system hostname. So, "localhost" will have a tendency to Just Work, but seeing a hostname of "localhost" will still obviously remind a user that they ought to set the hostname to something more sensible on a network-connected box. On a non-networked box, localhost makes perfect sense, and the box need not configure anything else. Similarly, this default would also make sense for various types of virtual systems. Also, "(none)" doesn't necessarily represent an "invalid" hostname. In general, tools seem to assume the validity of the system hostname, and use it wherever the hostname appears. (For that matter, as some recent security vulnerabilities have demonstrated, "valid hostname" doesn't necessarily mean "alphanumeric"; both DNS and DHCP will happily hand out a hostname with crazy characters in it, including '(' and ')'.) I wrote this patch with the same motivation as the option to mount devtmpfs on /dev automatically: it makes systems behave more or less sanely in the absence of explicit setup, even though more explicit setup may produce a more optimal configuration (just as devtmpfs makes all devices root:root in the absence of a better configuration). It would often make sense for embedded or virtual systems. In general, I'd rather see the kernel provide a configuration that will work in at least some cases and do no worse in others (requiring explicit configuration), rather than a configuration which will not work in any cases and *always* requires explicit userspace configuration. If the above does not provide a sufficiently good argument for changing the default (perhaps with a transition period added), would you consider accepting a patch which added a CONFIG_DEFAULT_UTS_HOSTNAME, defaulting to "(none)"? Then systems could choose to use that configuration option if they know their userspace will work with it. - Josh Triplett ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" 2011-04-11 5:01 [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" Josh Triplett 2011-04-11 12:39 ` Serge E. Hallyn 2011-04-11 15:02 ` Stephen Hemminger @ 2011-04-12 2:47 ` Valdis.Kletnieks 2 siblings, 0 replies; 6+ messages in thread From: Valdis.Kletnieks @ 2011-04-12 2:47 UTC (permalink / raw) To: Josh Triplett Cc: David Miller, netdev, Serge E. Hallyn, Andrew Morton, Linus Torvalds, linux-kernel [-- Attachment #1: Type: text/plain, Size: 630 bytes --] On Sun, 10 Apr 2011 22:01:59 PDT, Josh Triplett said: > Change the default hostname to "localhost". This removes the need for > the standard fallback, provides a useful default for systems that never > call sethostname, and makes minimal systems that much more useful with > less configuration. Seems sane enough to me. Only possible objection I can think of is "if you're running with 'init=/bin/sh' or similar config too crippled to run /bin/hostname, maybe your network config *should* be intentionally toasted so you can't get further surprises". I personally don't agree - just saying somebody might hold that position. [-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-04-12 2:48 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-04-11 5:01 [PATCH RESEND] uts: Set default hostname to "localhost", rather than "(none)" Josh Triplett 2011-04-11 12:39 ` Serge E. Hallyn 2011-04-11 15:02 ` Stephen Hemminger 2011-04-11 15:12 ` Linus Torvalds 2011-04-11 18:53 ` Josh Triplett 2011-04-12 2:47 ` Valdis.Kletnieks
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).