[Users] No FQDN hostname for COS7/RHEL7 containers?

Sabine Jordan emaleth77 at gmx.net
Wed Aug 5 08:24:55 PDT 2015


Dear OpenVZ users,

I've got a questions concerning RHE7/CENTOS7 containers and the change in the script "/etc/vz/dists/scripts/redhat-set_hostname.sh" which comes with the newer versions of vzctl-core...

function set_hostname()
{
   local cfgfile="$1"
   local var=$2
   local val=$3

   [ -z "${val}" ] && return 0

   if [ -f /etc/hostname ]; then
       # New style: RHEL7/Fedora15+
       # Note hostname(5) says it should NOT be FQDN
   val=${val%%.*}
       echo "$val" > /etc/hostname
   else
       # "Classic" style
       put_param "${cfgfile}" "${var}" "${val}"
   fi

   hostname "${val}"
}

change_hostname /etc/hosts "${HOSTNM}" "${IP_ADDR}"


We've got some CENTOS7 containers for testing (running on Hardware with rhel6 openvz kernel at the moment) The hostname which should be FQDN in our environment is set to short hostname all the time. This happens because the file/etc/hostname exists in Centos 7.

The redhat-set_hostname.sh script changes our entry /etc/hostname  to short hostname...

When I read the man pages of my COS 7.1.1503 Container, I don't see any entry saying that hostname should not be FQDN....

Hostname(5) says that it is recommended but, not that it is a strict requirement... 

DESCRIPTION
      The /etc/hostname file configures the name of the local system that is set during boot using the sethostname(2) system call. It should contain a single newline-terminated hostname string. The
      hostname may be a free-form string up to 64 characters in length; however, it is recommended that it consists only of 7-bit ASCII lower-case characters and no spaces or dots, and limits itself to
      the format allowed for DNS domain name labels, even though this is not a strict requirement.

Hostname(1) says the following...

FILES
      /etc/hostname  Historically  this  file  was supposed to only contain the hostname and not the full canonical FQDN. Nowadays most software is able to cope with a full FQDN here. This file is read at
      boot time by the system initialization scripts to set the hostname.

So why do you prevent users from setting their hostname to fqdn-hostname with the change of the script above?

Greetings, Sabine



More information about the Users mailing list