Bug 2983 - drakx-net should write (& read) /etc/hostname too for systemd
Summary: drakx-net should write (& read) /etc/hostname too for systemd
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Colin Guthrie
QA Contact:
URL:
Whiteboard:
Keywords: PATCH
: 3665 (view as bug list)
Depends on:
Blocks: 2120
  Show dependency treegraph
 
Reported: 2011-10-08 16:03 CEST by Lucien XU
Modified: 2012-01-04 12:19 CET (History)
8 users (show)

See Also:
Source RPM: libdrakx-net
CVE:
Status comment:


Attachments
update hostname in /etc/hostname (746 bytes, patch)
2011-11-27 22:57 CET, Luc Menut
Details | Diff

Description Lucien XU 2011-10-08 16:03:49 CEST
Description of problem:
The hostname of the machine is not the good one.
If the HOSTNAME entry in /etc/sysconfig/network is not filled, it should be "localhost" and if it is filled, it should be the filled one. But now, it is $HOSTNAME.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Start the machine
2. Launch a terminal or go to tty
3. The hostname displayed in term is $HOSTNAME
Manuel Hiebel 2011-10-08 21:12:01 CEST

Source RPM: (none) => net-tools

Comment 1 Dave Hodgins 2011-10-08 21:56:08 CEST
Works ok here.
$ grep -i hostname /etc/sysconfig/network
HOSTNAME=hodgins.homeip.net

$ echo $HOSTNAME
hodgins.homeip.net

It's set in /etc/rc.d/rc.sysinit, which means you have to reboot after
changing the hostname.

Line 8 sets it to the value returned by the hostname command.
Line 15 source /etc/sysconfig/network, so if it is defined in
that file, that will overwrite the line 8 setting.
Line 23 will set it to localhost if it is not already set.
Line 304 uses the hostname command to set the kernels version
of the hostname to match the value from the above settings.

CC: (none) => davidwhodgins

Comment 2 D Morgan 2011-10-08 22:40:24 CEST
is this bug with systemd ?

CC: (none) => dmorganec

Comment 3 Dave Hodgins 2011-10-08 23:10:54 CEST
Ah.  Good point.  I didn't notice that the bug report was for cauldron.
Comment 4 Lucien XU 2011-10-09 12:24:16 CEST
Are every chauldron distro with systemd ? 
How be sure that I'm running systemd (because I feel like still running initscripts)

Hardware: i586 => x86_64

Comment 5 D Morgan 2011-10-24 01:09:06 CEST
now cauldron should use systemd by default.

Try to add your hostname in /etc/hostname, reboot and see if it is applied.
Comment 6 Lucien XU 2011-10-24 08:42:25 CEST
Nothing happen
Note that the hostname is set first, but is then set to $HOSTNAME. (I can see during the booting process that it is set (KDM display "localhost") but then, it sets $HOSTNAME)
Comment 7 D Morgan 2011-10-24 09:20:39 CEST
what happens with a "new user" ?
Comment 8 Lucien XU 2011-10-24 09:24:19 CEST
A fresh install ?
Because it is system-wide.

Even not login, this happen : 
The KDM starts quickly, and display "localhost" as machine name.
But restarting X (KDM) after TTY is available (booting finished), it wil display $HOSTNAME.
D Morgan 2011-10-27 21:41:08 CEST

Blocks: (none) => 2120

Comment 9 Juergen Harms 2011-11-26 12:31:33 CET
Similar problem here:

At install, I specify as host pcjuergen.unige.ch. After booting the system, the shell prompt says "localhost", and typing the command "hostname" also provides localhost. Nevertheless, my /etc/sysconfig/network contains the correct line
"HOSTNAME=pcjuergen.unige.ch"

This is independant from kdm: same problem if I type "hostname" in a console, immediately after booting (running a 32-bit system on a Dell Optiplex 755 system).

If, after booting, I explicitely define the hostname by typing "hostname pcjuergen.unige.ch" the hostname remains correctly set, and the shell prompts show pcjuergen.unige.ch as they should. But after rebooting, I am back at localhost.

So, it looks as if the mechanism for defining the hostname work correctly, but during boot the hostname is not correctly replicated from the value defined in /etc/sysconfig/network

CC: (none) => juergen.harms

Comment 10 Lucien XU 2011-11-27 08:38:51 CET
I'm with a fresh install of 2 alpha 1. Using systemd on a single / /usr partition (no separated /usr). And using a self defined hostname in /etc/sysconfig/network.

The problem do not exist anymore.
Comment 11 Juergen Harms 2011-11-27 09:32:51 CET
The problem persists for me: fresh install yesterday (26.11) at about 18h00 (all directories in a single root partition). All updates available up to 7h30 this morning installed.

Still faulty behaviour precisely as described in comment 9 - in spite of now having done a fresh install.
Comment 12 Luc Menut 2011-11-27 22:55:58 CET
I confirm the comment 9.
systemd and recent initscripts (rc.sysinit) use /etc/hostname, but the installer or drakconnect write the hostname only in /etc/sysconfig/network, and don't write/update /etc/hostname.
In network.pm, write_hostname should keep in sync hostname in /etc/sysconfig/network and /etc/hostname.
Please, could you review the proposed patch in attachment.

regards,
Luc

CC: (none) => lmenut, mageia
Hardware: x86_64 => All
Source RPM: net-tools => libdrakx-net

Comment 13 Luc Menut 2011-11-27 22:57:41 CET
Created attachment 1143 [details]
update hostname in /etc/hostname
Comment 14 Remco Rijnders 2011-11-28 07:49:38 CET
Luc, thanks for the patch.

blino, I'm assigning this one to you as libdrakx-net maintainer.

Assignee: bugsquad => mageia

Manuel Hiebel 2011-11-28 08:17:49 CET

Keywords: (none) => PATCH

Comment 15 D Morgan 2011-11-28 08:39:38 CET
seems correct.

Blino, can we have your review please ?


(In reply to comment #12)
> I confirm the comment 9.
> systemd and recent initscripts (rc.sysinit) use /etc/hostname, but the
> installer or drakconnect write the hostname only in /etc/sysconfig/network, and
> don't write/update /etc/hostname.

This is not completly true, systemd %post handle this. Maybe there is a bug somewhere. So on a fresh install hostname is set to localhost and in a update this is set to what we had in /etc/sysconfig/network, but where you are right this is if the hostname is graphically modified during install or in drakconnect.


( i just wanted to add more informations ).

PS: ok bug found in the systemd packaging side should be OK on next systemd rpm. but the patch still stay valid.
Thierry Vignaud 2011-11-28 10:06:48 CET

CC: (none) => thierry.vignaud
Summary: Hostname is $HOSTNAME => drakx-net should write (& read) /etc/hostname too for systemd

Comment 16 Colin Guthrie 2012-01-04 11:51:27 CET
*** Bug 3665 has been marked as a duplicate of this bug. ***

CC: (none) => junk_no_spam

Comment 17 Colin Guthrie 2012-01-04 11:52:33 CET
I'll take this one from Blino (tho' his input is, as always, most welcome too).

Status: NEW => ASSIGNED
CC: (none) => mageia
Assignee: mageia => mageia

Comment 18 Colin Guthrie 2012-01-04 12:19:28 CET
OK, should be fixed in drakx-net-1.3

Please feel free to review the slightly expanded version of Luc's patch.

http://svnweb.mageia.org/soft?view=revision&revision=2566

I also wrote "localhost" to the file if no real hostname was available (which is what the %post script in the systemd rpm does.

Status: ASSIGNED => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.