Bug 440810 - Can't change hostname with the 'hostname' command.
Summary: Can't change hostname with the 'hostname' command.
Status: RESOLVED DUPLICATE of bug 440809
Alias: None
Product: openSUSE 11.1
Classification: openSUSE
Component: YaST2 (show other bugs)
Version: Beta 3
Hardware: i686 openSUSE 10.3
: P3 - Medium : Normal (vote)
Target Milestone: ---
Assignee: Katarina Machalkova
QA Contact: Jiri Srain
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-01 05:41 UTC by Geoff Farrell
Modified: 2008-11-24 15:05 UTC (History)
0 users

See Also:
Found By: Community User
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Geoff Farrell 2008-11-01 05:41:49 UTC
Note: this bug is the same as #440809 (Network), but has been submitted to address the YaST2 element.

Problem: hostname 'linux' persists despite attempts to rename it to something else.

When trying to change the hostname, it is not changed in all places that rely on definition of the hostname for system purposes. Changing it in YaST Network Services succeeds in changing /etc/HOSTNAME and the 127.0.0.2 entry in /etc/hosts, but not for the first field of the 127.0.0.1 entry, nor for the 'hostname' line in /etc/NetworkManager/nm-system-settings.conf. Changing it with the 'hostname' command results in changes to /etc/HOSTNAME, but not to /etc/hosts or etc/NetworkManager/nm-system-settings.conf.

The result is confusion within the system, where attempts to see what hostname is set will produce different results. For example, the 'hostname' command will show what it has been changed to ('MyHost.MyNetwork', say), as will the contents of /etc/HOSTNAME, but starting a console will show the prompt as 'user@linux:~>'. Any changes made are reset by rebooting the machine, whereupon the hostname 'linux' is resurrected. That is, the output of the hostname command is 'linux', even though the contents of /etc/HOSTNAME is still 'MyHost.MyNetwork'.

It seems that NetworkManager's use of a hostname in the nm-system-settings.conf file is new, as is the format of the 127.0.0.1 line in /etc/hosts, but these two changes have not been coordinated well. To fix this hostname problem, one of two courses of action could be taken, followed by a third:

a. If NetworkManager is to rely on its own config file for the hostname setting, then:
(1) the 'hostname' command should be modified to alter the /etc/NetworkManager/nm-system-settings.conf file, as well as the /etc/HOSTNAME file; and
(2) YaST Network Settings should save its 'hostname' setting to the /etc/NetworkManager/nm-system-settings.conf file, as well as the first hostname field of the 127.0.0.1 entry in /etc/hosts.

*Or*

b. NetworkManager could just refer to /etc/HOSTNAME, which exists precisely for the purpose of defining just that! YaST Network Settings would still need to save its 'hostname' setting to the first hostname field of the 127.0.0.1 entry in /etc/hosts.

c. In addition to 'a' or 'b' above, maybe the 'hostname' command could also be modified to change the first hostname field of the 127.0.0.1 entry in /etc/hosts.

This is for an installation on a hard drive partition from openSUSE-11.1-Beta3-KDE4-LiveCD-i386.iso; network is set up using NetworkManager, not ifup.

Detailed notes are in the attachment.
Comment 2 Katarina Machalkova 2008-11-21 18:24:00 UTC
> When trying to change the hostname, it is not changed in all places that rely
> on definition of the hostname for system purposes. Changing it in YaST Network
> Services succeeds in changing /etc/HOSTNAME and the 127.0.0.2 entry in
> /etc/hosts, but not for the first field of the 127.0.0.1 entry, 

That is indeed a bug, YaST network configuration module should substitute every instance of the old hostname in /etc/hosts by the new one ...

> nor for the
> 'hostname' line in /etc/NetworkManager/nm-system-settings.conf. 

... but this is intentional. NetworkManager uses its own settings system and YaST will not interfere with it.

> b. NetworkManager could just refer to /etc/HOSTNAME, which exists precisely 
> for the purpose of defining just that! 

Afaik, NetworkManager already reads system-wide /etc/HOSTNAME, it must be fixed in some of the recent betas

> YaST Network Settings would still need to
> save its 'hostname' setting to the first hostname field of the 127.0.0.1 entry
> in /etc/hosts.

If you ever happened to see '127.0.0.1 localhost linux.site localhost.localdomain' line in /etc/hosts, it's been added there by NetworkManager. Here I don't know if NM still does it in this form, or if it just uses a real hostname instead of 'linux.site', neverthless, modifying 127.0.0.1 entry was never done by YaST. YaST uses 127.0.0.2 line for remembering hostname, as a workaround for some broken apps :(

Comment 3 Geoff Farrell 2008-11-22 00:22:08 UTC
Thank you for that explanation. I can now see the delineation between NetworkManager and YaST in the setting of the hostname.

> Afaik, NetworkManager already reads system-wide /etc/HOSTNAME, it must be fixed
> in some of the recent betas

Yes, it was fixed in bug #440809 for Beta 5.

> If you ever happened to see '127.0.0.1 localhost linux.site
> localhost.localdomain' line in /etc/hosts, it's been added there by
> NetworkManager. Here I don't know if NM still does it in this form, or if it
> just uses a real hostname instead of 'linux.site', neverthless, modifying
> 127.0.0.1 entry was never done by YaST.

Yes, I can see that happening when I restart network services when NetworkManager is in charge (with Beta 5). However, mixing localhost and hostname in the 127.0.0.1 line doesn't seem logical; but that needs further investigation, which might require a separate bug report in the 'network' category.

But, from what I can glean from your supplied information, YaST-> Network Devices-> Network Services is clear of any buggy behaviour in relation to hostname. So as I see it, this bug can be closed.


Comment 4 Geoff Farrell 2008-11-22 03:10:10 UTC
> YaST-> Network Devices-> Network Services

Sorry, this should have said:

YaST-> Network Devices-> Network Settings

I have confirmed that, in 'ifup' method, Network Settings changes the hostname in all three files used to record the hostname:

1. /etc/hosts
2. /etc/HOSTNAME
3. /proc/sys/kernel/hostname

This firms my opinion that this bug can be closed.
Comment 5 Katarina Machalkova 2008-11-24 15:05:13 UTC
Ok, I verified that if you have your hostname in 127.0.0.1 line and you modify it in YaST, it'll substitute the new value correctly. 
But if you have 'linux.site' on that line (added by NetworkManager) and your /etc/HOSTNAME content is different, YaST can't do much there, as it takes it as a modification done manually by the user, and it is obliged to keep it.

Can't mark this fixed as I did nothing to fix it, marking it as duplicate of the original NetworkManager issue then

*** This bug has been marked as a duplicate of bug 440809 ***