Browse Source

make dhclient the default dhcp client

fix a couple buglets

r353
master
David Whedon 23 years ago
parent
commit
d708c90cdd
  1. 4
      Makefile
  2. 6
      netcfg-dhcp.c
  3. 2
      netcfg-static.c
  4. 22
      netcfg.c
  5. 1
      netcfg.h

4
Makefile

@ -7,8 +7,8 @@
ifndef TARGETS
TARGETS=netcfg-dhcp netcfg-static
endif
DHCP_CLIENT=-DPUMP
#-DDHCLIENT
DHCP_CLIENT=-DDHCLIENT
#-DPUMP
#-DDHCPCD
MAJOR=0

6
netcfg-dhcp.c

@ -74,11 +74,13 @@ netcfg_write_dhcp ()
/* nothing to do */
#elif defined DHCLIENT
netcfg_mkdir (DHCLIENT_DIR);
if (dhcp_hostname)
if ((fp = file_open (DHCLIENT_FILE)))
{
fprintf (fp,
"\n# dhclient configuration: created during the Debian installation\n \
"\n# dhclient configuration: created during the Debian installation\n\
interface \"%s\" {\nsend host-name \"%s\";\n}\n",
interface, dhcp_hostname);
fclose (fp);
@ -124,7 +126,7 @@ main (int argc, char *argv[])
{
char *ptr;
char *nameservers=NULL;
int finished = 1;
int finished = 0;
client = debconfclient_new ();
client->command (client, "title", "DHCP Network Configuration", NULL);

2
netcfg-static.c

@ -165,9 +165,9 @@ main (int argc, char *argv[])
client->command (client, "subst", "netcfg/confirm_static", "domain",
(domain ? domain : "<none>"), NULL);
netcfg_nameservers_to_array(nameservers, nameserver_array);
client->command (client, "subst", "netcfg/confirm_static",
"nameservers", (nameservers ? nameservers : "<none>") , NULL);
netcfg_nameservers_to_array(nameservers, nameserver_array);
netcfg_get_static ();

22
netcfg.c

@ -353,40 +353,42 @@ netcfg_get_common (struct debconfclient *client, char **interface,
{
char *ptr;
netcfg_get_interface (client, interface);
if (*hostname)
{
free (*hostname);
hostname = NULL;
*hostname = NULL;
}
*hostname = strdup (debconf_input (client, "medium", "netcfg/get_hostname"));
if (*domain)
{
free (*domain);
*domain = NULL;
}
*domain = NULL;
if ((ptr = debconf_input (client, "medium", "netcfg/get_domain")))
*domain = strdup (ptr);
*nameservers = debconf_input (client, "medium", "netcfg/get_nameservers");
if (*nameservers)
{
free(*nameservers);
}
*nameservers = NULL;
if (ptr = debconf_input (client, "medium", "netcfg/get_nameservers"))
*nameservers = strdup(ptr);
}
void
netcfg_nameservers_to_array(char *nameservers, u_int32_t array[]){
char *save, *ptr, *ns;
if (nameservers)
{
save = ptr = strdup (ptr);
ns = strtok_r (ptr, " ", &ptr);
dot2num (&array[0], ns);
@ -400,7 +402,7 @@ netcfg_nameservers_to_array(char *nameservers, u_int32_t array[]){
free (save);
}
else
nameservers[0] = 0;
array[0] = 0;
}

1
netcfg.h

@ -11,6 +11,7 @@
#define RESOLV_FILE "/etc/resolv.conf"
#define DHCPCD_FILE "/etc/dhcpc/config"
#define DHCLIENT_FILE "/etc/dhclient.conf"
#define DHCLIENT_DIR "/var/dhcp"
extern int netcfg_mkdir (char *path);

Loading…
Cancel
Save