On Fri, 29.07.11 06:50, JB (jer...@silentdome.com) wrote: > I'm a happy Arch Linux user of systemd. I want to share a few of my > thoughts about systemd's interaction with the system hostname. > > Here's my understanding of how systemd currently sets the hostname > * hostnamed is included in the systemd package > > * During early boot systemd makes a call to hostnamed and the > hostname is > set to the value in /etc/hostname
No. systemd does that on its own. systemd-hostnamed is an optional component which adds a mechanism for UIs (such as GNOME 3.2) to change the hostname, but is otherwise unnecessary to merely initialize it at boot. > My proposal for systemd's interaction with the hostname > * hostnamed & nss-myhostname are packaged together in a > 'hostnamed' package Well, one of the reasons why hsotnamed is really small is that it can reuse a lot fo the code we already have in systemd, which makes this easy. There's little point in splitting this off. Packagers can split this off if they wish after compilation, but it doesn't really make a lot of sense to us to split the sources up. > * (Wishlist/Off topic) Has any thought been given to having the > various ttys > and syslogs listen via dbus for a hostname changed signal so they can > immediately change the hostname displayed and their log > messages. Are there > any other apps/daemons that could benefit from doing this? GNOME 3.2 can watch for this, and I have plans teaching Avahi the same. If you want other apps to listen for host name changes, too, then file a bug regarding the respective packages. > > My reasoning > * I have a use case where I need to change the hostname on each > boot at boot > time. I'm able to do this with a custom 'Set Hostname' unit but > my logs > always show the hostname from the previous boot because systemd > sets it to > the value in /etc/hostname before I can change it. I also loose > time at > boot because hostname is being set twice. If I could just set an > ExecStartPre on a systemd provided 'Set Hostname' unit my isues > would be > solved. systemd initializes the hostname only at boot, so that at all times there is a hostname configured. If you want to change it later you may do so, for example by issuing a bus request to trigger this. hostnamed distuingishes between a static and a transient hostname to make this nice. http://www.freedesktop.org/wiki/Software/systemd/hostnamed Invoke SetHostname() from that interface and the right thing will happen. (You can easily do this via dbus-send) > * There is absolutely nothing systemd specific about hostnamed > (Correct me if > I'm mistaken). Non-systemd distros/users can benefit from > hostnamed without > hassle if it's maintained outside of the systemd tree Well, we standardize /etc/hostname with this service, which is a configuration file otherwise not known outside Debian. And the key point here is that much of the code hsotnamed internally uses is shared with the rest of systemd. Hence having this in systemd itself is quite easy and can be done with minimal code. If we'd split this off we'd have to duplicate a lot of code and the code of hostnamed would become vastly more complex. > Downside to my method > * Hostname is set a few milliseconds later in the boot process The point of what we do hostname-setup.c is actually that we initialize it so early that for the entire userspace the hostname is properly initialized (though not necessarily with the 'final' hostname), and we can rely that gethostname() called from userspace always returns a somewhat useful value. Note again that systemd does not monopolize the hostname. It just does an initialization of it, but if it is changed later on this is completely fine. > > Upsides > * Flexibility to support my and yet to be forseen use cases for > a dynamic > hostname change at boot without effectively setting the hostname twice > and having an incorrect hostname in syslog messages Well, if you set the hostname only after setting up the network, then you cannot log any network configuration issues to syslog, can you? Hence: we need a sane hostname configured right from the beginning, which is why systemd does that. You are welcome to later on change it and we make that easy, and send out change notifications. Note again, that in systemd this is designed to initialize the hostname early, and you are welcome to change it, which is why we distuingish the transient and the static hostname. Lennart -- Lennart Poettering - Red Hat, Inc. _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel