Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/distrib/utils/sysinst Pull up changes 1.59->1.61 up to ...
details: https://anonhg.NetBSD.org/src/rev/c63729e03ba2
branches: netbsd-1-5
changeset: 489500:c63729e03ba2
user: hubertf <hubertf%NetBSD.org@localhost>
date: Wed Sep 20 21:48:45 2000 +0000
description:
Pull up changes 1.59->1.61 up to netbsd-1-5 branch, OK'd by thorpej:
revision 1.61
date: 2000/07/24 10:52:28; author: itojun; state: Exp; lines: +140 -98
do not skip IPv6 configuration menu on dhcp configuration.
do not save address/netmask/default router, if we got them from dhcp.
(we shouldn't do that). if we keep any of dhcp config into /etc, we shoul
update rc.conf to run dhcp again.
----------------------------
revision 1.60
date: 2000/07/24 06:05:51; author: itojun; state: Exp; lines: +4 -6
run IPv6 configuration even if we use dhcp. background:
- on a IPv6/v4 dual stack network, it makes more sense to configure both.
- also, many of IPv4/v6 dual stack network requires us to contacd DNS
over IPv4 transport.
discussed with cyber%netbsd.org@localhost.
diffstat:
distrib/utils/sysinst/net.c | 252 +++++++++++++++++++++++++------------------
1 files changed, 146 insertions(+), 106 deletions(-)
diffs (truncated from 368 to 300 lines):
diff -r 1a0eea13cd1d -r c63729e03ba2 distrib/utils/sysinst/net.c
--- a/distrib/utils/sysinst/net.c Wed Sep 20 21:47:16 2000 +0000
+++ b/distrib/utils/sysinst/net.c Wed Sep 20 21:48:45 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: net.c,v 1.58.2.1 2000/07/03 08:34:44 itojun Exp $ */
+/* $NetBSD: net.c,v 1.58.2.2 2000/09/20 21:48:45 hubertf Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -47,9 +47,10 @@
#include <sys/param.h>
#ifdef INET6
#include <sys/sysctl.h>
+#endif
#include <sys/socket.h>
#include <netinet/in.h>
-#endif
+#include <arpa/inet.h>
#include "defs.h"
#include "md.h"
#include "msg_defs.h"
@@ -74,7 +75,7 @@
#define DHCLIENT_EX "/sbin/dhclient"
#include <signal.h>
static int config_dhcp __P((char *));
-static void get_command_out __P((char *, char *, char *));
+static void get_command_out __P((char *, int, char *, char *));
static void get_dhcp_value __P(( char *, char *));
#ifdef INET6
@@ -390,7 +391,7 @@
{ char *tp;
char defname[255];
int octet0;
- int pass, needmedia, v6config, dhcp_config;
+ int pass, v6config, dhcp_config;
FILE *f;
time_t now;
@@ -436,56 +437,69 @@
#endif
/* Preload any defaults we can find */
- dhcp_config = config_dhcp(net_dev);
get_ifinterface_info();
pass = strlen(net_mask) == 0 ? 0 : 1;
- needmedia = strlen(net_media) == 0 ? 0 : 1;
- if(dhcp_config) {
- /* disable ipv6 */
- v6config=0;
- /* run route show and extract data */
- get_command_out(net_defroute,"/sbin/route show 2>/dev/null","default");
- /* pull nameserver info out of /etc/resolv.conf */
- get_command_out(net_namesvr,"cat /etc/resolv.conf 2> /dev/null","nameserver");
-
- /* pull domainname out of leases file */
- get_dhcp_value(net_domain,"domain-name");
- /* pull hostname out of leases file */
- get_dhcp_value(net_host,"hostname");
-
- goto confirm; /* CEBXXX goto's suck */
- }
/* domain and host */
msg_display(MSG_netinfo);
+
+ /* ethernet medium */
+ if (strlen(net_media) == 0)
+ msg_prompt_add(MSG_net_media, net_media, net_media, STRSIZE);
+
+ /* try a dhcp configuration */
+ dhcp_config = config_dhcp(net_dev);
+ if (dhcp_config) {
+ net_dhcpconf |= DHCPCONF_IPADDR;
+
+ /* run route show and extract data */
+ get_command_out(net_defroute, AF_INET,
+ "/sbin/route -n show -inet 2>/dev/null", "default");
+
+ /* pull nameserver info out of /etc/resolv.conf */
+ get_command_out(net_namesvr, AF_INET,
+ "cat /etc/resolv.conf 2> /dev/null", "nameserver");
+ if (strlen(net_namesvr) != 0)
+ net_dhcpconf |= DHCPCONF_NAMESVR;
+
+ /* pull domainname out of leases file */
+ get_dhcp_value(net_domain, "domain-name");
+ if (strlen(net_domain) != 0)
+ net_dhcpconf |= DHCPCONF_DOMAIN;
+
+ /* pull hostname out of leases file */
+ get_dhcp_value(net_host, "hostname");
+ if (strlen(net_host) != 0)
+ net_dhcpconf |= DHCPCONF_HOST;
+ }
+
msg_prompt_add(MSG_net_domain, net_domain, net_domain, STRSIZE);
msg_prompt_add(MSG_net_host, net_host, net_host, STRSIZE);
- /* ethernet medium */
- if (needmedia)
- msg_prompt_add(MSG_net_media, net_media, net_media,
- STRSIZE);
-
- /* Manually configure IPv4 */
- msg_prompt_add(MSG_net_ip, net_ip, net_ip, STRSIZE);
- octet0 = atoi(net_ip);
- if (!pass) {
- if (0 <= octet0 && octet0 <= 127)
- strcpy(net_mask, "0xff000000");
- else if (128 <= octet0 && octet0 <= 191)
- strcpy(net_mask, "0xffff0000");
- else if (192 <= octet0 && octet0 <= 223)
- strcpy(net_mask, "0xffffff00");
+ if (!dhcp_config) {
+ /* Manually configure IPv4 */
+ msg_prompt_add(MSG_net_ip, net_ip, net_ip, STRSIZE);
+ octet0 = atoi(net_ip);
+ if (!pass) {
+ if (0 <= octet0 && octet0 <= 127)
+ strcpy(net_mask, "0xff000000");
+ else if (128 <= octet0 && octet0 <= 191)
+ strcpy(net_mask, "0xffff0000");
+ else if (192 <= octet0 && octet0 <= 223)
+ strcpy(net_mask, "0xffffff00");
+ }
+ msg_prompt_add(MSG_net_mask, net_mask, net_mask, STRSIZE);
+ msg_prompt_add(MSG_net_defroute, net_defroute, net_defroute,
+ STRSIZE);
+ msg_prompt_add(MSG_net_namesrv, net_namesvr, net_namesvr,
+ STRSIZE);
}
- msg_prompt_add(MSG_net_mask, net_mask, net_mask, STRSIZE);
- msg_prompt_add(MSG_net_defroute, net_defroute, net_defroute, STRSIZE);
- msg_prompt_add(MSG_net_namesrv, net_namesvr, net_namesvr, STRSIZE);
#ifdef INET6
/* IPv6 autoconfiguration */
- if (!is_v6kernel() )
+ if (!is_v6kernel())
v6config = 0;
- else if(v6config) { /* dhcp config will disable this */
+ else if (v6config) { /* dhcp config will disable this */
process_menu(MENU_ip6autoconf);
v6config = yesno ? 1 : 0;
}
@@ -498,7 +512,6 @@
}
#endif
-confirm:
/* confirm the setting */
msg_display(MSG_netok, net_domain, net_host,
*net_ip == '\0' ? "<none>" : net_ip,
@@ -842,75 +855,96 @@
char ifconfig_fn [STRSIZE];
FILE *f;
- if (network_up) {
- msg_prompt(MSG_mntnetconfig, ans, ans, 5);
- if (*ans == 'y') {
+ if (!network_up)
+ return;
+ msg_prompt(MSG_mntnetconfig, ans, ans, 5);
+ if (*ans != 'y')
+ return;
- /* Write hostname to /etc/myname */
- f = target_fopen("/etc/myname", "w");
- if (f != 0) {
- (void)fprintf(f, "%s\n", net_host);
- if (scripting)
- (void)fprintf(script, "echo \"%s\" >%s/etc/myname\n", net_host, target_prefix());
- (void)fclose(f);
+ /* Write hostname to /etc/myname */
+ if ((net_dhcpconf & DHCPCONF_HOST) == 0) {
+ f = target_fopen("/etc/myname", "w");
+ if (f != 0) {
+ (void)fprintf(f, "%s\n", net_host);
+ if (scripting) {
+ (void)fprintf(script,
+ "echo \"%s\" >%s/etc/myname\n",
+ net_host, target_prefix());
}
+ (void)fclose(f);
+ }
+ }
+
+ /* If not running in target, copy resolv.conf there. */
+ if ((net_dhcpconf & DHCPCONF_NAMESVR) == 0) {
+ if (strcmp(net_namesvr, "") != 0)
+ dup_file_into_target("/etc/resolv.conf");
+ }
- /* If not running in target, copy resolv.conf there. */
- if (strcmp(net_namesvr, "") != 0)
- dup_file_into_target("/etc/resolv.conf");
- /*
- * Add IPaddr/hostname to /etc/hosts.
- * Be careful not to clobber any existing contents.
- * Relies on ordered seach of /etc/hosts. XXX YP?
- */
- f = target_fopen("/etc/hosts", "a");
- if (f != 0) {
- write_etc_hosts(f);
- (void)fclose(f);
+ if ((net_dhcpconf & DHCPCONF_IPADDR) == 0) {
+ /*
+ * Add IPaddr/hostname to /etc/hosts.
+ * Be careful not to clobber any existing contents.
+ * Relies on ordered seach of /etc/hosts. XXX YP?
+ */
+ f = target_fopen("/etc/hosts", "a");
+ if (f != 0) {
+ write_etc_hosts(f);
+ (void)fclose(f);
+ if (scripting) {
+ (void)fprintf(script,
+ "cat <<EOF >>%s/etc/hosts\n",
+ target_prefix());
+ write_etc_hosts(script);
+ (void)fprintf(script, "EOF\n");
+ }
+ }
+
+ /* Write IPaddr and netmask to /etc/ifconfig.if[0-9] */
+ snprintf(ifconfig_fn, STRSIZE, "/etc/ifconfig.%s",
+ net_dev);
+ f = target_fopen(ifconfig_fn, "w");
+ if (f != 0) {
+ if (*net_media != '\0') {
+ fprintf(f, "%s netmask %s media %s\n",
+ net_ip, net_mask, net_media);
if (scripting) {
- (void)fprintf(script, "cat <<EOF >>%s/etc/hosts\n", target_prefix());
- write_etc_hosts(script);
- (void)fprintf(script, "EOF\n");
+ fprintf(script,
+ "echo \"%s netmask %s media %s\">%s%s\n",
+ net_ip, net_mask, net_media,
+ target_prefix(), ifconfig_fn);
+ }
+ } else {
+ fprintf(f, "%s netmask %s\n",
+ net_ip, net_mask);
+ if (scripting) {
+ fprintf(script,
+ "echo \"%s netmask %s\">%s%s\n",
+ net_ip, net_mask, target_prefix(),
+ ifconfig_fn);
}
}
+ fclose(f);
+ }
- /* Write IPaddr and netmask to /etc/ifconfig.if[0-9] */
- snprintf(ifconfig_fn, STRSIZE, "/etc/ifconfig.%s",
- net_dev);
- f = target_fopen(ifconfig_fn, "w");
- if (f != 0) {
- if (*net_media != '\0') {
- fprintf(f, "%s netmask %s media %s\n",
- net_ip, net_mask, net_media);
- if (scripting)
- fprintf(script, "echo \"%s netmask %s media %s\">%s%s\n",
- net_ip, net_mask, net_media, target_prefix(), ifconfig_fn);
- } else {
- fprintf(f, "%s netmask %s\n",
- net_ip, net_mask);
- if (scripting)
- fprintf(script, "echo \"%s netmask %s\">%s%s\n",
- net_ip, net_mask, target_prefix(), ifconfig_fn);
- }
- fclose(f);
+ f = target_fopen("/etc/mygate", "w");
+ if (f != 0) {
+ fprintf(f, "%s\n", net_defroute);
+ if (scripting) {
+ fprintf(script,
+ "echo \"%s\" >%s/etc/mygate\n",
+ net_defroute, target_prefix());
}
-
- f = target_fopen("/etc/mygate", "w");
- if (f != 0) {
- fprintf(f, "%s\n", net_defroute);
- if (scripting)
- fprintf(script, "echo \"%s\" >%s/etc/mygate\n", net_defroute, target_prefix());
- fclose(f);
- }
- fflush(NULL);
+ fclose(f);
}
}
+
+ fflush(NULL);
}
-
int
Home |
Main Index |
Thread Index |
Old Index