On Sun, Jul 15, 2001 at 07:20:59PM +0200, Eduard Bloch wrote:
> I was helping a new user to configure his woody installation, and was
> surprised by some "funny" messages from misc. config script. First, I
> could find the reason, then I realized that he used an _ underscore in
> the hostname. Normally this must not be used, but the installer allowed
> him to do so and "hostname" does not complain about "broken" strings, so
> the this may be reproduced by newbies, sooner or later. We should
> install something to check the entries, IMHO.
The following patch checks the input for RFC 608 compliance. OK
to apply?
Matt
--- netconfig.c.orig Sun Jul 15 13:32:46 2001
+++ netconfig.c Sun Jul 15 13:38:45 2001
@@ -261,6 +261,8 @@
int get_host()
{
char *def = NULL;
+ static const char *valid_hostname_chars =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
for (;;) {
if(host)
@@ -284,19 +286,20 @@
return 255;
}
- if(strchr(host, ' ')) {
- problemBox(_("The host name must be one word."), _("Problem"));
+ /* Check the hostname for RFC 608 compliance. */
+ if (!isalpha(host[0])) {
+ problemBox(_("The host name must begin with a character from the alphabet."),
+ _("Problem"));
+ } else if (host[strlen(host) - 1] == '-') {
+ problemBox(_("The host name must not end in a minus sign."), _("Problem"));
+ } else if (host[strspn(host, valid_hostname_chars)] != '\0') {
+ problemBox(_("The host name may only contain alphanumeric characters and the
+minus sign."),
+ _("Problem"));
+ } else if (strlen(host) > 48) {
+ problemBox(_("The host name must contain 48 characters or less."),
+ _("Problem"));
} else {
- if (strchr(host, '.')) {
- problemBox(_("The host name must not contain dots."), _("Problem"));
- } else {
- if (isdigit(*host)) {
- problemBox(_("The host name contains leading numerical character(s).\nNote
that the RFC does not allow this."),
- _("Problem"));
- } else {
- break;
- }
- }
+ break;
}
}
return 0;
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]