Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst don't make /etc/hosts's contents a mes...



details:   https://anonhg.NetBSD.org/src/rev/6181136c5fb2
branches:  trunk
changeset: 473967:6181136c5fb2
user:      cgd <cgd%NetBSD.org@localhost>
date:      Wed Jun 23 22:55:14 1999 +0000

description:
don't make /etc/hosts's contents a message.  there's no point and it
makes some things harder, for instance... Deal correctly with the case
where the user-supplied hostname is already fully qualified with the
domain name they supplied.  Addresses PR#6955.

diffstat:

 distrib/utils/sysinst/msg.mi.en |  11 +----------
 distrib/utils/sysinst/msg.mi.fr |  11 +----------
 distrib/utils/sysinst/net.c     |  36 +++++++++++++++++++++++++++++++-----
 3 files changed, 33 insertions(+), 25 deletions(-)

diffs (117 lines):

diff -r b9880f0ece33 -r 6181136c5fb2 distrib/utils/sysinst/msg.mi.en
--- a/distrib/utils/sysinst/msg.mi.en   Wed Jun 23 22:42:52 1999 +0000
+++ b/distrib/utils/sysinst/msg.mi.en   Wed Jun 23 22:55:14 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.en,v 1.48 1999/06/22 04:29:54 cgd Exp $ */
+/*     $NetBSD: msg.mi.en,v 1.49 1999/06/23 22:55:14 cgd Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -669,15 +669,6 @@
 
 Continue extracting sets?}
 
-message etc_hosts
-{
-#
-#Added by NetBSD sysinst
-#
-%s %s.%s %s
-127.0.0.1 localhost
-}
-
 message partitions_overlap
 {partitions %c and %c overlap.}
 
diff -r b9880f0ece33 -r 6181136c5fb2 distrib/utils/sysinst/msg.mi.fr
--- a/distrib/utils/sysinst/msg.mi.fr   Wed Jun 23 22:42:52 1999 +0000
+++ b/distrib/utils/sysinst/msg.mi.fr   Wed Jun 23 22:55:14 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.fr,v 1.23 1999/06/22 12:45:26 bouyer Exp $      */
+/*     $NetBSD: msg.mi.fr,v 1.24 1999/06/23 22:55:14 cgd Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -691,15 +691,6 @@
 
 Voulez-vous continuer à extraire les composants ?}
 
-message etc_hosts
-{
-#
-#Added by NetBSD sysinst
-#
-%s %s.%s %s
-127.0.0.1 localhost
-}
-
 message partitions_overlap
 {Les partitions %c et %c se recouvrent.}
 
diff -r b9880f0ece33 -r 6181136c5fb2 distrib/utils/sysinst/net.c
--- a/distrib/utils/sysinst/net.c       Wed Jun 23 22:42:52 1999 +0000
+++ b/distrib/utils/sysinst/net.c       Wed Jun 23 22:55:14 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.c,v 1.50 1999/06/22 18:47:07 cgd Exp $     */
+/*     $NetBSD: net.c,v 1.51 1999/06/23 22:55:14 cgd Exp $     */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -64,6 +64,9 @@
 static void get_ifconfig_info __P((void));
 static void get_ifinterface_info __P((void));
 
+static void write_etc_hosts(FILE *f);
+
+
 /*
  * URL encode unsafe characters.  See RFC 1738.
  *
@@ -569,6 +572,31 @@
 }
 
 /*
+ * write the new contents of /etc/hosts to the specified file
+ */
+static void
+write_etc_hosts(FILE *f)
+{
+       int l;
+
+       fprintf(f, "#\n");
+       fprintf(f, "# Added by NetBSD sysinst\n");
+       fprintf(f, "#\n");
+
+       fprintf(f, "127.0.0.1   localhost\n");
+
+       fprintf(f, "%s\t", net_ip);
+       l = strlen(net_host) - strlen(net_domain);
+       if (l <= 0 ||
+           net_host[l - 1] != '.' ||
+           strcasecmp(net_domain, net_host + l) != 0) {
+               /* net_host isn't an FQDN. */
+               fprintf(f, "%s.%s ", net_host, net_domain);
+       }
+       fprintf(f, "%s\n", net_host);
+}
+
+/*
  * Write the network config info the user entered via menus into the
  * config files in the target disk.  Be careful not to lose any
  * information we don't immediately add back, in case the install
@@ -606,13 +634,11 @@
                         */
                        f = target_fopen("/etc/hosts", "a");
                        if (f != 0) {
-                               (void)fprintf(f, msg_string(MSG_etc_hosts),
-                                   net_ip, net_host, net_domain, net_host);
+                               write_etc_hosts(f);
                                (void)fclose(f);
                                if (scripting) {
                                        (void)fprintf(script, "cat <<EOF >>%s/etc/hosts\n", target_prefix());
-                                       (void)fprintf(script, msg_string(MSG_etc_hosts),
-                                           net_ip, net_host, net_domain, net_host);
+                                       write_etc_hosts(script);
                                        (void)fprintf(script, "EOF\n");
                                }
                        }



Home | Main Index | Thread Index | Old Index