linamh/net-misc/dhcp/files/dhcp-3.0.3-dhclient-stdin-conf.patch
2008-06-08 13:25:18 +00:00

78 lines
1.9 KiB
Diff

--- client/clparse.c.orig 2006-02-22 09:37:12.000000000 +0000
+++ client/clparse.c 2006-02-22 09:38:26.000000000 +0000
@@ -97,6 +97,11 @@
status = read_client_conf_file (path_dhclient_conf,
(struct interface_info *)0,
&top_level_config);
+
+ /* Read any extra configuration from stdin */
+ read_client_conf_stdin ((struct interface_info *)0,
+ &top_level_config);
+
if (status != ISC_R_SUCCESS) {
;
#ifdef LATER
@@ -148,20 +153,17 @@
return status;
}
-int read_client_conf_file (const char *name, struct interface_info *ip,
- struct client_config *client)
+int read_client_conf_actual (int file, const char *name,
+ struct interface_info *ip,
+ struct client_config *client)
{
- int file;
struct parse *cfile;
const char *val;
int token;
isc_result_t status;
- if ((file = open (name, O_RDONLY)) < 0)
- return uerr2isc (errno);
-
cfile = (struct parse *)0;
- new_parse (&cfile, file, (char *)0, 0, path_dhclient_conf, 0);
+ new_parse (&cfile, file, (char *)0, 0, name , 0);
do {
token = peek_token (&val, (unsigned *)0, cfile);
@@ -174,11 +174,36 @@
status = (cfile -> warnings_occurred
? ISC_R_BADPARSE
: ISC_R_SUCCESS);
- close (file);
end_parse (&cfile);
return status;
}
+int read_client_conf_file (const char *name, struct interface_info *ip,
+ struct client_config *client)
+{
+ int file;
+ isc_result_t status;
+
+ if ((file = open (name, O_RDONLY)) < 0)
+ return uerr2isc (errno);
+
+ status = read_client_conf_actual(file, name, ip, client);
+
+ return status;
+}
+
+
+int read_client_conf_stdin (struct interface_info *ip,
+ struct client_config *client)
+{
+ int file = fileno(stdin);
+ isc_result_t status;
+
+ if (isatty(file)) return ISC_R_NOTFOUND;
+ status = read_client_conf_actual(file, "stdin", ip, client);
+
+ return status;
+}
/* lease-file :== client-lease-statements END_OF_FILE
client-lease-statements :== <nil>