Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/usr.sbin/dhcp/client Pull up differences between 1.27 a...
details: https://anonhg.NetBSD.org/src/rev/1940894795c9
branches: netbsd-1-5
changeset: 488636:1940894795c9
user: mellon <mellon%NetBSD.org@localhost>
date: Sat Jul 22 05:00:19 2000 +0000
description:
Pull up differences between 1.27 and 1.28
diffstat:
usr.sbin/dhcp/client/dhclient.c | 313 ++++++++++++++++++++++++---------------
1 files changed, 188 insertions(+), 125 deletions(-)
diffs (truncated from 417 to 300 lines):
diff -r 92b51de2bc8d -r 1940894795c9 usr.sbin/dhcp/client/dhclient.c
--- a/usr.sbin/dhcp/client/dhclient.c Sat Jul 22 04:59:41 2000 +0000
+++ b/usr.sbin/dhcp/client/dhclient.c Sat Jul 22 05:00:19 2000 +0000
@@ -41,7 +41,7 @@
#ifndef lint
static char ocopyright[] =
-"$Id: dhclient.c,v 1.26.2.1 2000/07/10 19:58:45 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 Internet Software Consortium. All rights reserved.\n";
+"$Id: dhclient.c,v 1.26.2.2 2000/07/22 05:00:19 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -104,6 +104,10 @@
isc_result_t result;
int persist = 0;
int omapi_port;
+ int no_dhclient_conf = 0;
+ int no_dhclient_db = 0;
+ int no_dhclient_pid = 0;
+ char *s;
#ifdef SYSLOG_4_2
openlog ("dhclient", LOG_NDELAY);
@@ -147,14 +151,17 @@
if (++i == argc)
usage ();
path_dhclient_pid = argv [i];
+ no_dhclient_pid = 1;
} else if (!strcmp (argv [i], "-cf")) {
if (++i == argc)
usage ();
path_dhclient_conf = argv [i];
+ no_dhclient_conf = 1;
} else if (!strcmp (argv [i], "-lf")) {
if (++i == argc)
usage ();
path_dhclient_db = argv [i];
+ no_dhclient_db = 1;
} else if (!strcmp (argv [i], "-q")) {
quiet = 1;
quiet_interface_discovery = 1;
@@ -195,6 +202,16 @@
}
}
+ if (!no_dhclient_conf && (s = getenv ("PATH_DHCLIENT_CONF"))) {
+ path_dhclient_conf = s;
+ }
+ if (!no_dhclient_db && (s = getenv ("PATH_DHCLIENT_DB"))) {
+ path_dhclient_db = s;
+ }
+ if (!no_dhclient_pid && (s = getenv ("PATH_DHCLIENT_PID"))) {
+ path_dhclient_pid = s;
+ }
+
/* first kill of any currently running client */
if (release_mode) {
/* XXX inelegant hack to prove concept */
@@ -2117,46 +2134,29 @@
const char *reason;
struct string_list *medium;
{
- int fd;
-#ifndef HAVE_MKSTEMP
+ struct string_list *sl, *next;
- do {
-#endif
- strcpy (scriptName, "/tmp/dcsXXXXXX");
-#ifdef HAVE_MKSTEMP
- fd = mkstemp (scriptName);
-#else
- if (!mktemp (scriptName))
- log_fatal ("can't create temporary script %s: %m",
- scriptName);
- fd = open (scriptName, O_EXCL | O_CREAT | O_WRONLY, 0600);
- } while (fd < 0 && errno == EEXIST);
-#endif
- if (fd < 0)
- log_fatal ("can't create temporary script %s: %m", scriptName);
-
-
- scriptFile = fdopen (fd, "w");
- if (!scriptFile)
- log_fatal ("can't write script file: %m");
- fprintf (scriptFile, "#!/bin/sh\n\n");
if (client) {
+ for (sl = client -> env; sl; sl = next) {
+ next = sl -> next;
+ dfree (sl, MDL);
+ }
+ client -> env = (struct string_list *)0;
+ client -> envc = 0;
+
if (client -> interface) {
- fprintf (scriptFile, "interface=\"%s\"\n",
- client -> interface -> name);
- fprintf (scriptFile, "export interface\n");
+ client_envadd (client, "", "interface", "%s",
+ client -> interface -> name);
}
if (client -> name)
- fprintf (scriptFile, "client=\"%s\"\n",
- client -> name);
- fprintf (scriptFile, "export client\n");
+ client_envadd (client,
+ "", "client", "%s", client -> name);
+ if (medium)
+ client_envadd (client,
+ "", "medium", "%s", medium -> string);
+
+ client_envadd (client, "", "reason", "%s", reason);
}
- if (medium) {
- fprintf (scriptFile, "medium=\"%s\"\n", medium -> string);
- fprintf (scriptFile, "export medium\n");
- }
- fprintf (scriptFile, "reason=\"%s\"\n", reason);
- fprintf (scriptFile, "export reason\n");
}
void script_write_params (client, prefix, lease)
@@ -2168,10 +2168,10 @@
struct data_string data;
struct option_cache *oc;
pair *hash;
+ char *s, *t;
- fprintf (scriptFile, "%sip_address=\"%s\"\n",
- prefix, piaddr (lease -> address));
- fprintf (scriptFile, "export %sip_address\n", prefix);
+ client_envadd (client,
+ prefix, "ip_address", "%s", piaddr (lease -> address));
/* For the benefit of Linux (and operating systems which may
have similar needs), compute the network address based on
@@ -2197,51 +2197,37 @@
subnet = subnet_number (lease -> address, netmask);
if (subnet.len) {
- fprintf (scriptFile,
- "%snetwork_number=\"%s\";\n",
- prefix, piaddr (subnet));
- fprintf (scriptFile,
- "export %snetwork_number\n", prefix);
+ client_envadd (client, prefix, "network_number",
+ "%s", piaddr (subnet));
- oc = lookup_option (&dhcp_universe,
- lease -> options,
- DHO_BROADCAST_ADDRESS);
- if (!oc ||
- !(evaluate_option_cache
- (&data, (struct packet *)0,
- (struct lease *)0,
- (struct option_state *)0,
- lease -> options,
- &global_scope, oc, MDL))) {
- broadcast = broadcast_addr (subnet,
- netmask);
- if (broadcast.len) {
- fprintf (scriptFile,
- "%s%s=\"%s\";\n",
- prefix,
- "broadcast_address",
- piaddr (broadcast));
- fprintf (scriptFile,
- "export %s%s\n",
- prefix,
- "broadcast_address");
- }
+ oc = lookup_option (&dhcp_universe,
+ lease -> options,
+ DHO_BROADCAST_ADDRESS);
+ if (!oc ||
+ !(evaluate_option_cache
+ (&data, (struct packet *)0,
+ (struct lease *)0,
+ (struct option_state *)0,
+ lease -> options,
+ &global_scope, oc, MDL))) {
+ broadcast = broadcast_addr (subnet, netmask);
+ if (broadcast.len) {
+ client_envadd (client,
+ prefix, "broadcast_address",
+ "%s", piaddr (broadcast));
}
+ }
}
}
data_string_forget (&data, MDL);
}
- if (lease -> filename) {
- fprintf (scriptFile, "%sfilename=\"%s\";\n",
- prefix, lease -> filename);
- fprintf (scriptFile, "export %sfilename\n", prefix);
- }
- if (lease -> server_name) {
- fprintf (scriptFile, "%sserver_name=\"%s\";\n",
- prefix, lease -> server_name);
- fprintf (scriptFile, "export %sserver_name\n", prefix);
- }
+ if (lease -> filename)
+ client_envadd (client,
+ prefix, "filename", "%s", lease -> filename);
+ if (lease -> server_name)
+ client_envadd (client, prefix, "server_name",
+ "%s", lease -> server_name);
execute_statements_in_scope ((struct packet *)0,
(struct lease *)0, lease -> options,
@@ -2251,78 +2237,155 @@
hash = lease -> options -> universes [dhcp_universe.index];
for (i = 0; i < OPTION_HASH_SIZE; i++) {
- pair hp;
-
- for (hp = hash [i]; hp; hp = hp -> cdr) {
- oc = (struct option_cache *)hp -> car;
+ pair hp;
- if (evaluate_option_cache (&data,
- (struct packet *)0,
- (struct lease *)0,
- (struct option_state *)0,
- lease -> options,
- &global_scope, oc, MDL)) {
+ for (hp = hash [i]; hp; hp = hp -> cdr) {
+ oc = (struct option_cache *)hp -> car;
- if (data.len) {
- char *s = (dhcp_option_ev_name
- (oc -> option));
-
- fprintf (scriptFile,
- "%s%s=\"%s\"\n", prefix, s,
- (pretty_print_option
- (oc -> option -> code,
- data.data, data.len,
- 0, 0)));
- fprintf (scriptFile,
- "export %s%s\n", prefix, s);
- }
- data_string_forget (&data, MDL);
+ if (evaluate_option_cache (&data,
+ (struct packet *)0,
+ (struct lease *)0,
+ (struct option_state *)0,
+ lease -> options,
+ &global_scope, oc, MDL)) {
+ if (data.len) {
+ char name [256];
+ if (dhcp_option_ev_name (name, sizeof name,
+ oc -> option)) {
+ client_envadd (client, prefix, name, "%s",
+ (pretty_print_option
+ (oc -> option -> code,
+ data.data, data.len,
+ 0, 0)));
+ data_string_forget (&data, MDL);
}
+ }
}
+ }
}
- fprintf (scriptFile, "%sexpiry=\"%d\"\n",
- prefix, (int)lease -> expiry); /* XXX */
- fprintf (scriptFile, "export %sexpiry\n", prefix);
+ client_envadd (client, prefix, "expiry", "%d", (int)(lease -> expiry));
}
int script_go (client)
struct client_state *client;
{
int rval;
+ char *scriptName;
+ char *argv [2];
+ char **envp;
+ char *epp [3];
+ char reason [] = "REASON=NBI";
+ static char client_path [] = CLIENT_PATH;
+ int i;
+ struct string_list *sp, *next;
+ int pid, wpid, wstatus;
- if (client)
- fprintf (scriptFile, "%s\n",
- client -> config -> script_name);
- else
- fprintf (scriptFile, "%s\n",
- top_level_config.script_name);
- fprintf (scriptFile, "exit $?\n");
- fclose (scriptFile);
- chmod (scriptName, 0700);
- rval = system (scriptName);
- if (!save_scripts)
- unlink (scriptName);
- return rval;
+ if (client) {
Home |
Main Index |
Thread Index |
Old Index