Bug 4672 - 2_b1: /etc/hostname not newline-terminated
Summary: 2_b1: /etc/hostname not newline-terminated
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: x86_64 Linux
Priority: Normal minor
Target Milestone: ---
Assignee: Colin Guthrie
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 2120
  Show dependency treegraph
 
Reported: 2012-02-24 11:30 CET by Bit Twister
Modified: 2012-04-12 01:50 CEST (History)
2 users (show)

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


Attachments

Description Bit Twister 2012-02-24 11:30:24 CET
Description of problem:

/etc/hostname does not contain newline-terminated string.

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


How reproducible:  Always


Steps to Reproduce:
1. clean beta1 install
2. after boot, login
3. click up a terminal
3. cat /etc/hostname

Notice your prompt is on end of the string, not on the next line.
Example:
[bittwister@wb ~]$ cat /etc/hostname
wb.home.test[bittwister@wb ~]$

It should be
[bittwister@wb ~]$ cat /etc/hostname
wb.home.test
[bittwister@wb ~]$
Manuel Hiebel 2012-02-24 21:41:16 CET

Blocks: (none) => 2120
Source RPM: (none) => systemd
Severity: normal => minor

Manuel Hiebel 2012-02-24 21:41:31 CET

Component: Installer => RPM Packages

Comment 1 Remco Rijnders 2012-02-27 10:41:56 CET
Hi Bit Twister,

Do you remember how you've set the hostname? From the prompt, during install time, or using the draktools?

CC: (none) => remco

Comment 2 Colin Guthrie 2012-03-24 23:20:38 CET
For reference the upstream man page:
http://0pointer.de/public/systemd-man/hostname.html

But overall, the code in drakx-net writes out the hostname sans newline, so indeed something is busted here;

I think this patch will do the job, but my perl skills suck, so asking TV for his opinion first before committing.



Index: lib/network/network.pm
===================================================================
--- lib/network/network.pm	(revision 3782)
+++ lib/network/network.pm	(working copy)
@@ -108,7 +108,7 @@
     $net->{network}{NETWORKING} = 'yes';
 
     setVarsInSh($::prefix . $network_file, $net->{network}, qw(HOSTNAME NETWORKING GATEWAY GATEWAYDEV NISDOMAIN FORWARD_IPV4 NETWORKING_IPV6 IPV6_DEFAULTDEV CRDA_DOMAIN));
-    output($::prefix . $hostname_file, $net->{network}{HOSTNAME} || "localhost");
+    output($::prefix . $hostname_file, ( $net->{network}{HOSTNAME} || "localhost" ) . "\n" );
 }
 
 sub write_zeroconf {

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

Comment 3 Colin Guthrie 2012-03-24 23:23:14 CET
(incidentally I checked the scripts run in systemd spec and even on upgrades it would write a newline - so changing the rpm assignment)

Source RPM: systemd => drakx-net

Comment 4 Colin Guthrie 2012-03-25 01:31:20 CET
Fixed in drakx-net svn r3790.
Comment 5 Bit Twister 2012-03-28 20:29:38 CEST
(In reply to comment #4)
> Fixed in drakx-net svn r3790.

Any idea when this will hit the repositiory?

Just did a clean x86_64 beta2 install (calldron.home.test) VB GUEST, urpme --auto-orphans --auto, applied updates, rebooted, urpme --auto-orphans --auto, used drakconnect to delete the connection, then 'Set up a new network interface' with calldron1.home.test as hostname.
cat /etc/hostname had the 1 in the new name but still no new-line character.
Comment 6 Colin Guthrie 2012-03-28 20:40:34 CEST
Certainly before rc. I just need to make sure I've got all my fixes rolled up (and Thierry tends to do releases as an when needed so I'm tend to just let them happen naturally if I can).

Should be over the weekend if not before.
Comment 7 Colin Guthrie 2012-04-12 01:50:34 CEST
OK, so nothing else seems to be going into drakx-net so I just rolled a release. Should be OK in the next version (1.6). If not then I've forgotten something somewhere... :p

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


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