Hi Ken,

I've posted earlier using "easybeats". This is me "Dex".

I've been reading C source code, plus RHEL documentation to shed some
more light

If you run the hostname command with an invalid character, IE...

hostname invalid\#hostname
hostname: the specified hostname is invalid

It filters out what it believes to be invalid characters and prints a
warning but sets the hostname. Looking at the source code for the
"hostname" command  (which is the entry point for setting the systems
hostname) for Debian, it filters out for alphanumeric, dash (-) and
period (.). At the top there is a comment stating it uses the rules
from RFC 1034 http://tools.ietf.org/html/rfc1034. (See snippet below)

To mean this means that at least for Linux Systems the period (.) is
allowed when setting the hostname of the box . IE entries
configuration files use the "hostname" command to set the name of the
system.

/etc/hostname - (Debian)
/etc/sysconfig/networking - (Red Hat)

Heres the clincher for me, having looked at Red Hats documentation, it
was intended "hostname" either the short form (to the first period) or
the fqdn (both of which is allowed as the hostname).

from 
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/sn-Netconfig-x86.html
"Setup prompts you to supply a host name for this computer, either as
a fully-qualified domain name (FQDN) in the format hostname.domainname
or as a short host name in the format hostname.", notice the period at
the end.

So my conclusions

1. hostname on Linux was intended as either the FQDN or SHORT FORM (To
first period). Periods are allowed in Linux hostname
2. While the hostname fact does not reflect the actual hostname value
as held in the Linux kernel (which can contain periods), it does
present the correct intepretation of RFC 952.

So the "hostname" and "fqdn" facts are strict and correct
interpretations of RFC 952, however as stated in a previous post I
still maintain that facter should represent the hostname (using a
different fact) held as a Linux Kernel C struct value "sysctl -n
kernel.hostname" even if it is only part of the fqdn, The example I
used was SMTP servers enabling/disabling filtering based on strict RFC
interpretations, also the hostname command in Debian doesn't restrict
setting of invalid hostnames but warns the user.

-Dex

-snippet from the hostname command-
/*
 * Check the format of a user-specified hostname. Uses the rules from
RFC 1035,
 * section 2.3.1.
 */
int
check_name(char *name)
{
        int i, len = strlen(name);

        /* Handle leading and trailing hyphen now. */
        if (!len || !isalnum(name[0]) || !isalnum(name[len-1]))
                return 0;

        for (i = 0; i < len; i++) {
                if (!isalnum(name[i]) && name[i] != '-' && name[i] !=
'.')
                        return 0;
                if (name[i] == '-' && (name[i - 1] == '.' || name[i +
1] == '.'))
                        return 0;
                if (name[i] == '.' && name[i - 1] == '.')
                        return 0;
        }

        return 1;
}


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to