[Hostname-devel] Bug#650822: hostname set hostname to (none)

Elvir Kuric elvirkuric at gmail.com
Sat Dec 3 15:38:21 UTC 2011


Package: hostname
Version: 3.04
Severity: normal


In case there is space at end of hostname name in /etc/hostname,the hostname
will be set to (none) after next boot

If space is present at end of line in /etc/hostname,then /etc/init.d/hostname.sh 
will report 

# /etc/init.d/hostname.sh
hostname: the specified hostname is invalid
 
Possible solution: 

In /etc/init.d/hostname.sh is there in function do_start()

do_start () {

        [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"

--- (rest of hostname.sh) --- 
       
If  

	[ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"

is changed to 

 [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname | sed 's/^[ \t]*//;s/[ \t]*$//')"
  

then trailing space in line in /etc/hostname will be removed,and /etc/init.d/hostname.sh will
not report above error 




-- System Information:
Debian Release: 6.0.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages hostname depends on:
ii  libc6                         2.11.2-10  Embedded GNU C Library: Shared lib

hostname recommends no packages.

hostname suggests no packages.

-- no debconf information





More information about the Hostname-devel mailing list