Browse Source

Clean up comments written to /etc/network/interfaces

r17186
master
Thomas Hood 18 years ago
parent
commit
fe238be9b9
  1. 68
      dhcp.c
  2. 3
      netcfg-common.c
  3. 4
      netcfg.h
  4. 5
      static.c

68
dhcp.c

@ -29,6 +29,42 @@ static int dhcp_exit_status = 1;
static pid_t dhcp_pid = -1;
/*
* Add DHCP-related lines to /etc/network/interfaces
*/
static void netcfg_write_dhcp (char *iface, char *dhostname)
{
FILE *fp;
if ((fp = file_open(INTERFACES_FILE, "a"))) {
fprintf(fp, "\n# The primary network interface\n");
if (!iface_is_hotpluggable(iface))
fprintf(fp, "auto %s\n", iface);
fprintf(fp, "iface %s inet dhcp\n", iface);
if (dhostname)
{
fprintf(fp, "\thostname %s\n", dhostname);
}
if (is_wireless_iface(iface))
{
fprintf(fp, "\t# wireless-* options are implemented by the wireless-tools package\n");
fprintf(fp, "\twireless-mode %s\n",
(mode == MANAGED) ? "managed" : "adhoc");
fprintf(fp, "\twireless-essid %s\n", essid ? essid : "any");
if (wepkey != NULL)
fprintf(fp, "\twireless-key %s\n", wepkey);
}
fclose(fp);
}
#if 0
if ((fp = file_open(RESOLV_FILE, "a"))) {
fclose(fp);
}
#endif
}
/*
* Signal handler for DHCP client child
*/
@ -134,38 +170,6 @@ static int kill_dhcp_client(void)
}
static void netcfg_write_dhcp (char *iface, char *dhostname)
{
FILE *fp;
if ((fp = file_open(INTERFACES_FILE, "a"))) {
fprintf(fp,
"\n# This entry was created during the Debian installation\n");
if (!iface_is_hotpluggable(iface))
fprintf(fp, "auto %s\n", iface);
fprintf(fp, "iface %s inet dhcp\n", iface);
if (dhostname)
{
fprintf(fp, "\thostname %s\n", dhostname);
}
if (is_wireless_iface(iface))
{
fprintf(fp, "\t# wireless-* options are implemented by the wireless-tools package\n");
fprintf(fp, "\twireless-mode %s\n",
(mode == MANAGED) ? "managed" : "adhoc");
fprintf(fp, "\twireless-essid %s\n", essid ? essid : "any");
if (wepkey != NULL)
fprintf(fp, "\twireless-key %s\n", wepkey);
}
fclose(fp);
}
if ((fp = file_open(RESOLV_FILE, "a"))) {
fclose(fp);
}
}
/*
* Poll the started DHCP client for DHCP_SECONDS seconds
* and return 0 if a lease is known to have been acquired,

3
netcfg-common.c

@ -517,8 +517,9 @@ void netcfg_write_loopback (void)
if ((fp = file_open(INTERFACES_FILE, "w"))) {
fprintf(fp, HELPFUL_COMMENT);
fprintf(fp, "\n# The loopback network interface\n");
fprintf(fp, "auto lo\n");
fprintf(fp, "iface lo inet loopback\n\n");
fprintf(fp, "iface lo inet loopback\n");
fclose(fp);
}
}

4
netcfg.h

@ -28,9 +28,7 @@
#define HELPFUL_COMMENT \
"# This file describes the network interfaces available on your system\n" \
"# and how to activate them. For more information, see interfaces(5).\n" \
"\n" \
"# This entry denotes the loopback (127.0.0.1) interface.\n"
"# and how to activate them. For more information, see interfaces(5).\n"
#define IPV6_HOSTS \
"# The following lines are desirable for IPv6 capable hosts\n" \

5
static.c

@ -244,10 +244,7 @@ static int netcfg_write_static(char *domain, struct in_addr nameservers[])
goto error;
if ((fp = file_open(INTERFACES_FILE, "a"))) {
fprintf(fp,
"\n# This entry was created during the Debian installation\n");
fprintf(fp,
"# (network, broadcast and gateway are optional)\n");
fprintf(fp, "\n# The primary network interface\n");
if (!iface_is_hotpluggable(interface))
fprintf(fp, "auto %s\n", interface);
fprintf(fp, "iface %s inet static\n", interface);

Loading…
Cancel
Save