Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/dhcp Resolve conflicts in pl20 merge.
details: https://anonhg.NetBSD.org/src/rev/119b2ee667eb
branches: trunk
changeset: 467824:119b2ee667eb
user: mellon <mellon%NetBSD.org@localhost>
date: Mon Mar 29 23:08:21 1999 +0000
description:
Resolve conflicts in pl20 merge.
diffstat:
usr.sbin/dhcp/client/dhclient-script.8 | 79 ++++++++++++++++++---------------
usr.sbin/dhcp/client/dhclient.c | 56 ++++++++++++++++-------
usr.sbin/dhcp/client/scripts/bsdos | 44 +++++++++++++++---
usr.sbin/dhcp/client/scripts/freebsd | 44 +++++++++++++++---
usr.sbin/dhcp/includes/dhcpd.h | 6 ++
usr.sbin/dhcp/server/dhcp.c | 22 ++++++++-
usr.sbin/dhcp/server/dhcpd.c | 46 +++++++++++++------
7 files changed, 210 insertions(+), 87 deletions(-)
diffs (truncated from 665 to 300 lines):
diff -r 1e56e472c982 -r 119b2ee667eb usr.sbin/dhcp/client/dhclient-script.8
--- a/usr.sbin/dhcp/client/dhclient-script.8 Mon Mar 29 23:00:49 1999 +0000
+++ b/usr.sbin/dhcp/client/dhclient-script.8 Mon Mar 29 23:08:21 1999 +0000
@@ -35,7 +35,7 @@
.\" Enterprises. To learn more about the Internet Software Consortium,
.\" see ``http://www.isc.org/isc''. To learn more about Vixie
.\" Enterprises, see ``http://www.vix.com''.
-.TH dhclient 8
+.TH dhclient-script 8
.SH NAME
dhclient-script - DHCP client network configuration script
.SH DESCRIPTION
@@ -46,45 +46,50 @@
interface's final configuration once a lease has been acquired. If no
lease is acquired, the script is used to test predefined leases, if
any, and also called once if no valid lease can be identified.
-.SH CUSTOMIZATION
-This script is not meant to be modified by the end user.
-In general, customizations specific to a particular computer should either
-be done in the
-.B /etc/dhclient.conf
-file, or by setting up an
-.B /etc/dhclient-enter-hooks
-or
-.B /etc/dhclient-exit-hooks
-script. If you find that you can't make such a customization without
-customizing dhclient-script, please submit a bug report.
+.PP
+This script is not meant to be customized by the end user. If local
+customizations are needed, they should be possible using the enter and
+exit hooks provided (see HOOKS for details). These hooks will allow the
+user to override the default behaviour of the client in creating a
+.B /etc/resolv.conf
+file.
.PP
-The
-.B /etc/dhclient-enter-hooks
-script, if it exists, is invoked by
-.B /etc/dhclient-script
-each time it runs, before it does anything.
-It will have the same variable settings as are described later, and
-may modify these settings before dhclient-script sees them, or may
-take additional action.
+No standard client script exists for some operating systems, even though
+the actual client may work, so a pioneering user may well need to create
+a new script or modify an existing one. In general, customizations specific
+to a particular computer should be done in the
+.B ETCDIR/dhclient.conf
+file. If you find that you can't make such a customization without
+customizing
+.B ETCDIR/dhclient.conf
+or using the enter and exit hooks, please submit a bug report.
+.SH HOOKS
+When it starts, the client script first defines a shell function,
+.B make_resolv_conf ,
+which is later used to create the
+.B /etc/resolv.conf
+file. To override the default behaviour, redefine this function in
+the enter hook script.
.PP
-One special action that may be useful is that dhclient-script defines a
-shell function, make_resolv_conf, which overwrites the existing resolv.conf
-file with the configuration information supplied by the server, as modified
-by any append, prepend or supersede statements in the dhclient.conf file.
-It is normally possible to specify the behaviour you want in the
-dhclient.conf file - for example, if you want to always use your own
-local nameserver, you can specify "supersede domain-name-servers 127.0.0.1;"
-in your dhclient.conf file. If this behaviour is not sufficient for some
-reason, however, the make_resolv_conf function can itself be superseded
-with a new definition in the dhclient-enter-hooks script.
+On after defining the make_resolv_conf function, the client script checks
+for the presence of an executable
+.B ETCDIR/dhclient-enter-hooks
+script, and if present, it invokes the script inline, using the Bourne
+shell '.' command. The entire environment documented under OPERATION
+is available to this script, which may modify the environment if needed
+to change the behaviour of the script. If an error occurs during the
+execution of the script, it can set the exit_status variable to a nonzero
+value, and
+.B ETCDIR/dhclient-script
+will exit with that error code immediately after the client script exits.
.PP
-The
-.B /etc/dhclient-exit-hooks
-script, if it exists, is invoked by
-.B /etc/dhclient-script
-each time it exits. The environment will be set up just as with the
-dhclient-enter-hooks script, except that the exit_status variable will
-contain the exit status with which dhclient-script will exit.
+After all processing has completed,
+.B ETCDIR/dhclient-script
+checks for the presence of an executable
+.B ETCDIR/dhclient-exit-hooks
+script, which if present is invoked using the '.' command. The exit status
+is passed in the exit_status shell variable, and will always be zero if the
+script succeeded at the task for which it was invoked.
.SH OPERATION
When dhclient needs to invoke the client configuration script, it
writes a shell script into /tmp which defines a variety of variables.
diff -r 1e56e472c982 -r 119b2ee667eb usr.sbin/dhcp/client/dhclient.c
--- a/usr.sbin/dhcp/client/dhclient.c Mon Mar 29 23:00:49 1999 +0000
+++ b/usr.sbin/dhcp/client/dhclient.c Mon Mar 29 23:08:21 1999 +0000
@@ -56,7 +56,7 @@
#ifndef lint
static char ocopyright[] =
-"$Id: dhclient.c,v 1.16 1999/03/26 17:52:45 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.17 1999/03/29 23:08:21 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -89,17 +89,17 @@
int no_daemon;
int save_scripts;
-static void usage PROTO ((void));
-
void catch_sighup PROTO ((int));
void catch_sigterm PROTO ((int));
static char copyright[] =
"Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium.";
static char arr [] = "All rights reserved.";
-static char message [] = "Internet Software Consortium DHCP Client V2.0b1pl19";
-static char contrib [] = "\nPlease contribute if you find this software useful.";
-static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.html\n";
+static char message [] = "Internet Software Consortium DHCP Client V2.0b1pl20";
+static char contrib [] = "Please contribute if you find this software useful.";
+static char url [] = "For info, please visit http://www.isc.org/dhcp-contrib.html";
+
+static void usage PROTO ((char *));
int main (argc, argv, envp)
int argc;
@@ -111,12 +111,20 @@
struct sigaction sa;
int seed;
int quiet = 0;
+ char *s;
+ s = strchr (argv [0], '/');
+ if (!s)
+ s = argv [0];
+ else
+ s++;
+
+ /* Initially, log errors to stderr as well as to syslogd. */
#ifdef SYSLOG_4_2
- openlog ("dhclient", LOG_NDELAY);
- log_priority = LOG_DAEMON;
+ openlog (s, LOG_NDELAY);
+ log_priority = DHCPD_LOG_FACILITY;
#else
- openlog ("dhclient", LOG_NDELAY, LOG_DAEMON);
+ openlog (s, LOG_NDELAY, DHCPD_LOG_FACILITY);
#endif
#if !(defined (DEBUG) || defined (SYSLOG_4_2) || defined (__CYGWIN32__))
@@ -126,7 +134,7 @@
for (i = 1; i < argc; i++) {
if (!strcmp (argv [i], "-p")) {
if (++i == argc)
- usage ();
+ usage (s);
local_port = htons (atoi (argv [i]));
debug ("binding to user-specified port %d",
ntohs (local_port));
@@ -134,15 +142,19 @@
no_daemon = 1;
} else if (!strcmp (argv [i], "-D")) {
save_scripts = 1;
+ } else if (!strcmp (argv [i], "-pf")) {
+ if (++i == argc)
+ usage (s);
+ path_dhclient_pid = argv [i];
} else if (!strcmp (argv [i], "-lf")) {
if (++i == argc)
- usage ();
+ usage (s);
path_dhclient_db = argv [i];
} else if (!strcmp (argv [i], "-q")) {
quiet = 1;
quiet_interface_discovery = 1;
} else if (argv [i][0] == '-') {
- usage ();
+ usage (s);
} else {
struct interface_info *tmp =
((struct interface_info *)
@@ -163,8 +175,10 @@
note (message);
note (copyright);
note (arr);
+ note ("")
note (contrib);
note (url);
+ note ("")
}
/* Default to the DHCP/BOOTP port. */
@@ -287,9 +301,19 @@
return 0;
}
-static void usage ()
+static void usage (appname)
+ char *appname;
{
- error ("Usage: dhclient [-c] [-p <port>] [-lf lease-file] [interface]");
+ note (message);
+ note (copyright);
+ note (arr);
+ note ("");
+ note (contrib);
+ note (url);
+ note ("");
+
+ warn ("Usage: %s [-c] [-p <port>] [-lf lease-file]", appname);
+ error (" [-pf pidfile] [interface]");
}
void cleanup ()
@@ -484,7 +508,6 @@
{
struct interface_info *ip = packet -> interface;
struct client_lease *lease;
- int i;
/* If we're not receptive to an offer right now, or if the offer
has an unrecognizable transaction id, then just drop it. */
@@ -728,7 +751,6 @@
int arp_timeout_needed, stop_selecting;
char *name = (packet -> options [DHO_DHCP_MESSAGE_TYPE].len
? "DHCPOFFER" : "BOOTREPLY");
- struct iaddrlist *ap;
#ifdef DEBUG_PACKET
dump_packet (packet);
@@ -1386,7 +1408,6 @@
struct interface_info *ip;
struct client_lease *lease;
{
- struct dhcp_packet *raw;
unsigned char discover = DHCPDISCOVER;
int i;
@@ -1696,7 +1717,6 @@
struct tree_cache *options [256];
struct tree_cache message_type_tree;
- struct tree_cache requested_address_tree;
struct tree_cache server_id_tree;
memset (options, 0, sizeof options);
diff -r 1e56e472c982 -r 119b2ee667eb usr.sbin/dhcp/client/scripts/bsdos
--- a/usr.sbin/dhcp/client/scripts/bsdos Mon Mar 29 23:00:49 1999 +0000
+++ b/usr.sbin/dhcp/client/scripts/bsdos Mon Mar 29 23:08:21 1999 +0000
@@ -1,5 +1,33 @@
#!/bin/sh
+make_resolv_conf() {
+ echo search $new_domain_name >/etc/resolv.conf
+ for nameserver in $new_domain_name_servers; do
+ echo nameserver $nameserver >>/etc/resolv.conf
+ done
+}
+
+# Must be used on exit. Invokes the local dhcp client exit hooks, if any.
+exit_with_hooks() {
+ exit_status=$1
+ if [ -x /etc/dhclient-exit-hooks ]; then
+ . /etc/dhclient-exit-hooks
+ fi
+# probably should do something with exit status of the local script
+ exit $exit_status
+}
+
+# Invoke the local dhcp client enter hooks, if they exist.
+if [ -x /etc/dhclient-enter-hooks ]; then
+ exit_status=0
+ . /etc/dhclient-enter-hooks
+ # allow the local script to abort processing of this state
+ # local script must set exit_status variable to nonzero.
+ if [ $exit_status -ne 0 ]; then
+ exit $exit_status
+ fi
+fi
+
if [ x$new_network_number != x ]; then
echo New Network Number: $new_network_number
fi
@@ -25,7 +53,7 @@
ifconfig $interface $medium
ifconfig $interface inet -alias 0.0.0.0 $medium >/dev/null 2>&1
sleep 1
- exit 0
+ exit_with_hooks 0
fi
if [ x$reason = xPREINIT ]; then
Home |
Main Index |
Thread Index |
Old Index