Re: X session and hostname changing policy
2010/6/17 Dan Williams : > On Mon, 2010-06-14 at 23:16 +0300, Fırat Birlik wrote: >> Hi there, >> >> I experience a problem with hostname manipulation of NetworkManager >> and the X session. DHCP server sends a hostname within the dhcp >> offer, which is different the current one. There is no persistent >> hostname definition within the 'nm-system-settings.conf' as this is a >> default installation. NetworkManager just changes the hostname and as >> new hostname is not authenticated (xhost cookie MIT-MAGIC-COOKIE-1 for >> new hostname does not exist) no new application can be started >> afterwards. > > The solution is *not* to use hostname for local X authentication at all. > Instead, you want to allow all connections via Unix sockets from the > session user, which means that your X init should be doing something > like this: > > [ -x /usr/bin/xhost ] && [ -x /usr/bin/id ] && > xhost +si:localuser:`id -un` >& /dev/null > > which normally goes in 'localuser.sh' in /etc/X11/xinit/xinitrc.d or > wherever scripts get executed during X init time. Hostnames do change > and relying on it for something like local authentication will certainly > break stuff. > Thanks for pointing that out, I think this is the solution for major part of the problem, instead of forcing a persistent hostname. But there is also SESSION_MANAGER variable and xauth list, because both depend on the previous hostname. Do you have any tips for these also? Firat > Most distros have had this fixed for a while now. > > Dan > >> To avoid this behavior, I can define a persistent hostname equal the >> content of /etc/HOSTNAME (this is a slackware system) as the >> following: >> >> --- /etc/NetworkManager/nm-system-settings.conf~ >> +++ /etc/NetworkManager/nm-system-settings.conf >> @@ -1,2 +1,5 @@ >> [main] >> plugins=keyfile >> + >> +[keyfile] >> +hostname=myhostname >> >> >> As persistent hostname has highest precedence, problem looks solved; >> but this should be repeated for each installation. >> >> What I'm asking is, is there any config option or some way to not let >> NetworkManager change the hostname? >> >> As a note, current precedence order for hostname (taken from >> NetworkManagerPolicy.c): >> >> * 1) a configured hostname (from system-settings) >> * 2) automatic hostname from the default device's config (DHCP, VPN, >> etc) >> * 3) the original hostname when NM started >> * 4) reverse-DNS of the best device's IPv4 address >> >> >> Thanks, >> >> Firat >> ___ >> networkmanager-list mailing list >> networkmanager-list@gnome.org >> http://mail.gnome.org/mailman/listinfo/networkmanager-list > > > ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: X session and hostname changing policy
2010/6/14 Robby Workman : > On Mon, 14 Jun 2010 15:26:06 -0500 > Robby Workman wrote: > >> On Mon, 14 Jun 2010 23:16:52 +0300 >> Fırat Birlik wrote: >> >> > Hi there, >> > >> > I experience a problem with hostname manipulation of NetworkManager >> > and the X session. DHCP server sends a hostname within the dhcp >> > offer, which is different the current one. There is no persistent >> > hostname definition within the 'nm-system-settings.conf' as this is >> > a default installation. NetworkManager just changes the hostname >> > and as new hostname is not authenticated (xhost cookie >> > MIT-MAGIC-COOKIE-1 for new hostname does not exist) no new >> > application can be started afterwards. >> > >> > To avoid this behavior, I can define a persistent hostname equal the >> > content of /etc/HOSTNAME (this is a slackware system) as the >> > following: >> > >> > --- /etc/NetworkManager/nm-system-settings.conf~ >> > +++ /etc/NetworkManager/nm-system-settings.conf >> > @@ -1,2 +1,5 @@ >> > [main] >> > plugins=keyfile >> > + >> > +[keyfile] >> > +hostname=myhostname >> > >> > >> > As persistent hostname has highest precedence, problem looks solved; >> > but this should be repeated for each installation. >> > >> > What I'm asking is, is there any config option or some way to not >> > let NetworkManager change the hostname? >> > >> > As a note, current precedence order for hostname (taken from >> > NetworkManagerPolicy.c): >> > >> > * 1) a configured hostname (from system-settings) >> > * 2) automatic hostname from the default device's config >> > (DHCP, VPN, etc) >> > * 3) the original hostname when NM started >> > * 4) reverse-DNS of the best device's IPv4 address >> > >> >> >> Do you have NM built to use dhcpcd? If so, dhcpcd should not change >> the system hostname unless you have force_hostname=(YES|TRUE|1) in >> /etc/dhcpcd.conf. From dhcpcd(8): >> >> If the hostname is currently blank, (null) or localhost, or >> force_hostname is YES or TRUE or 1 then dhcpcd sets the >> hostname to the one supplied by the DHCP server. >> >> -RW > I tested it with both dhcpcd and dhclient builds, but from the code trace what I understand is, dhcp client (both of them) do not change the hostname themselves. If I'm not mistaken, NetworkManager sets the hostname to the offered one (if any) with the following code: ---[ from NetworkManagerPolicy.c / update_system_hostname() ]--- /* Grab a hostname out of the device's DHCP4 config */ dhcp4_config = nm_device_get_dhcp4_config (best); if (dhcp4_config) { const char *dhcp4_hostname, *p; p = dhcp4_hostname = nm_dhcp4_config_get_option (dhcp4_config, "host_name"); if (dhcp4_hostname && strlen (dhcp4_hostname)) { /* Sanity check */ while (*p) { if (!isblank (*p++)) { set_system_hostname (dhcp4_hostname, "from DHCP"); return; } } nm_warning ("%s: DHCP-provided hostname '%s' looks invalid; ignoring it", __func__, dhcp4_hostname); } } --- By the way, if dhcp server does NOT offer a new hostname, then hostname is set to the system hostname when NetworkManager first started. As it is not changed after launch, it is just left alone by nm and everything is fine. Firat ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
X session and hostname changing policy
Hi there, I experience a problem with hostname manipulation of NetworkManager and the X session. DHCP server sends a hostname within the dhcp offer, which is different the current one. There is no persistent hostname definition within the 'nm-system-settings.conf' as this is a default installation. NetworkManager just changes the hostname and as new hostname is not authenticated (xhost cookie MIT-MAGIC-COOKIE-1 for new hostname does not exist) no new application can be started afterwards. To avoid this behavior, I can define a persistent hostname equal the content of /etc/HOSTNAME (this is a slackware system) as the following: --- /etc/NetworkManager/nm-system-settings.conf~ +++ /etc/NetworkManager/nm-system-settings.conf @@ -1,2 +1,5 @@ [main] plugins=keyfile + +[keyfile] +hostname=myhostname As persistent hostname has highest precedence, problem looks solved; but this should be repeated for each installation. What I'm asking is, is there any config option or some way to not let NetworkManager change the hostname? As a note, current precedence order for hostname (taken from NetworkManagerPolicy.c): * 1) a configured hostname (from system-settings) * 2) automatic hostname from the default device's config (DHCP, VPN, etc) * 3) the original hostname when NM started * 4) reverse-DNS of the best device's IPv4 address Thanks, Firat ___ networkmanager-list mailing list networkmanager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list