Browse Source

dhcp3-client support is somewhat functional

r15267
master
Joshua Kwan 18 years ago
parent
commit
be2f1a094c
  1. 1
      debian/changelog
  2. 2
      debian/control
  3. 5
      debian/rules
  4. 27
      dhcp.c
  5. 7
      netcfg-common.c

1
debian/changelog

@ -23,6 +23,7 @@ netcfg (0.64) UNRELEASED; urgency=low
over 10 for me. (Closes: #244819)
- Template cleanups: netcfg/static-title, netcfg/dhcp-title,
netcfg/internal-pcmcia
- Add dhcp3-client support.
- Remove a lot of calls to /sbin/this and /sbin/that in response to Joey's
rant on debian-boot.

2
debian/control

@ -9,7 +9,7 @@ Standards-Version: 3.6.1.0
Package: netcfg
XC-Package-Type: udeb
Architecture: i386 sparc alpha m68k arm powerpc mips mipsel hppa ia64
Depends: ${shlibs:Depends}, cdebconf-udeb, dhcp-client-udeb | pump-udeb | busybox-cvs-udeb | busybox-cvs-net-udeb, ethernet-card-detection, libiw27-udeb
Depends: ${shlibs:Depends}, cdebconf-udeb, dhcp3-client-udeb | dhcp-client-udeb | pump-udeb | busybox-cvs-udeb | busybox-cvs-net-udeb, ethernet-card-detection, libiw27-udeb
Provides: configured-network
XB-Installer-Menu-Item: 18
Description: Configure the network

5
debian/rules

@ -37,8 +37,9 @@ install: build
install -m 755 prebaseconfig debian/$(PACKAGE)/usr/lib/prebaseconfig.d/40netcfg ;)
# Install files that are in all DHCP packages
$(foreach PACKAGE, $(DHCP_PACKAGES), \
mkdir -p debian/$(PACKAGE)/etc/dhcp ; \
mkdir -p debian/$(PACKAGE)/var/dhcp ; )
mkdir -p debian/$(PACKAGE)/etc/dhcp debian/$(PACKAGE)/etc/dhcp3 ; \
mkdir -p debian/$(PACKAGE)/var/dhcp ; \
cp dhclient-script debian/$(PACKAGE)/etc/dhcp3/; )
# Build architecture-independent files here.

27
dhcp.c

@ -107,7 +107,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
{
if ((dc = file_open(DHCLIENT_CONF, "w")))
{
fprintf(dc, "send host-name %s\n", hostname);
fprintf(dc, "send host-name \"%s\";\n", dhostname);
fclose(dc);
}
}
@ -122,7 +122,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
{
if ((dc = file_open(DHCLIENT3_CONF, "w")))
{
fprintf(dc, "send host-name %s\n", hostname);
fprintf(dc, "send host-name \"%s\";\n", dhostname);
fclose(dc);
}
}
@ -132,7 +132,7 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
case UDHCPC:
if (dhostname)
snprintf(buf, sizeof(buf), "udhcpc -i %s -n -H %s", interface, hostname);
snprintf(buf, sizeof(buf), "udhcpc -i %s -n -H %s", interface, dhostname);
else
snprintf(buf, sizeof(buf), "udhcpc -i %s -n", interface);
@ -146,6 +146,8 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
{
int ret;
signal(SIGCHLD, &dhcp_client_sigchld);
/* these guys log to syslog already */
if (dhcp_client == DHCLIENT || dhcp_client == DHCLIENT3)
ret = di_exec_shell(buf);
@ -159,7 +161,6 @@ int start_dhcp_client (struct debconfclient *client, char* dhostname)
else
{
dhcp_running = 1;
signal(SIGCHLD, &dhcp_client_sigchld);
return 0;
}
}
@ -256,7 +257,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
break;
case DHCP_HOSTNAME:
if (netcfg_get_hostname(client, "netcfg/dhcp_hostname", &dhostname, 0) == GO_BACK)
if (netcfg_get_hostname(client, "netcfg/dhcp_hostname", &dhostname, 0))
state = ASK_RETRY;
else
{
@ -293,7 +294,7 @@ int netcfg_activate_dhcp (struct debconfclient *client)
/* dhcp hostname, ask for one with the dhcp hostname
* as a seed */
if (gethostname(buf, sizeof(buf)) == 0)
if (gethostname(buf, sizeof(buf)) == 0 && strcmp(buf, "(none)") != 0)
debconf_set(client, "netcfg/get_hostname", buf);
else
seed_hostname_from_dns(client);
@ -327,19 +328,25 @@ int kill_dhcp_client(void)
{
if (dhcp_pid != -1)
{
int s[] = { SIGTERM, SIGKILL, 0 }, *sigs = s;
int sig = SIGTERM;
while (*sigs)
for (;;)
{
kill(dhcp_pid, 0);
/* looks like it died */
if (errno == ESRCH)
{
return 1;
}
kill(dhcp_pid, *sigs);
kill(dhcp_pid, sig);
sleep(2);
if (sig == SIGTERM)
sig = SIGKILL;
else if (sig == SIGKILL)
break;
}
}

7
netcfg-common.c

@ -382,7 +382,7 @@ int netcfg_get_hostname(struct debconfclient *client, char *template, char **hos
return ret;
debconf_get(client, template);
free(*hostname);
*hostname = strdup(client->value);
len = strlen(*hostname);
@ -404,11 +404,12 @@ int netcfg_get_hostname(struct debconfclient *client, char *template, char **hos
} while (!*hostname);
if ((s = strchr(*hostname, '.')))
/* don't strip DHCP hostnames */
if (hdset && (s = strchr(*hostname, '.')))
{
if (s[1] == '\0') /* "somehostname." <- . should be ignored */
*s = '\0';
else if (hdset) /* assume we have a valid domain name here */
else /* assume we have a valid domain name here */
{
debconf_set(client, "netcfg/get_domain", strdup(s + 1));
have_domain = 1;

Loading…
Cancel
Save