116 lines
2.9 KiB
Diff
116 lines
2.9 KiB
Diff
|
diff -ur a/client/clparse.c b/client/clparse.c
|
||
|
--- a/client/clparse.c 2008-09-03 21:39:30.000000000 +0100
|
||
|
+++ b/client/clparse.c 2008-09-03 23:10:48.000000000 +0100
|
||
|
@@ -172,6 +172,10 @@
|
||
|
#endif
|
||
|
}
|
||
|
|
||
|
+ /* Read any extra configuration from stdin */
|
||
|
+ read_client_conf_stdin ((struct interface_info *)0,
|
||
|
+ &top_level_config);
|
||
|
+
|
||
|
/* Set up state and config structures for clients that don't
|
||
|
have per-interface configuration statements. */
|
||
|
config = (struct client_config *)0;
|
||
|
@@ -201,21 +205,13 @@
|
||
|
return status;
|
||
|
}
|
||
|
|
||
|
-int read_client_conf_file (const char *name, struct interface_info *ip,
|
||
|
- struct client_config *client)
|
||
|
+int read_client_conf_actual (struct parse *cfile, 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);
|
||
|
-
|
||
|
do {
|
||
|
token = peek_token (&val, (unsigned *)0, cfile);
|
||
|
if (token == END_OF_FILE)
|
||
|
@@ -226,10 +222,74 @@
|
||
|
status = (cfile -> warnings_occurred
|
||
|
? ISC_R_BADPARSE
|
||
|
: ISC_R_SUCCESS);
|
||
|
+ return status;
|
||
|
+}
|
||
|
+
|
||
|
+int read_client_conf_file (const char *name, struct interface_info *ip,
|
||
|
+ struct client_config *client)
|
||
|
+{
|
||
|
+ int file;
|
||
|
+ struct parse *cfile;
|
||
|
+ 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);
|
||
|
+ status = read_client_conf_actual(cfile, ip, client);
|
||
|
end_parse (&cfile);
|
||
|
return status;
|
||
|
}
|
||
|
|
||
|
+int read_client_conf_stdin (struct interface_info *ip,
|
||
|
+ struct client_config *client)
|
||
|
+{
|
||
|
+ int file;
|
||
|
+ char *buffer = NULL, *p;
|
||
|
+ unsigned buflen, len = 0;
|
||
|
+ struct parse *cfile;
|
||
|
+ size_t bytes;
|
||
|
+ isc_result_t status;
|
||
|
+
|
||
|
+ file = fileno(stdin);
|
||
|
+ if (isatty (file))
|
||
|
+ return ISC_R_NOTFOUND;
|
||
|
+ if (fcntl (file, F_SETFL, O_NONBLOCK) < 0)
|
||
|
+ log_fatal ("could not set stdin to non blocking!");
|
||
|
+
|
||
|
+ buflen = BUFSIZ;
|
||
|
+ buffer = malloc (BUFSIZ + 1);
|
||
|
+ p = buffer;
|
||
|
+ do {
|
||
|
+ bytes = read (file, p, BUFSIZ);
|
||
|
+ if (bytes == 0)
|
||
|
+ break;
|
||
|
+ if (bytes == -1)
|
||
|
+ log_fatal ("failed to read stdin!");
|
||
|
+ if (bytes >= BUFSIZ) {
|
||
|
+ buflen += BUFSIZ;
|
||
|
+ len += BUFSIZ;
|
||
|
+ buffer = realloc (buffer, buflen + 1);
|
||
|
+ if (!buffer)
|
||
|
+ log_fatal ("not enough buffer to read stdin!");
|
||
|
+ p = buffer + len;
|
||
|
+ } else {
|
||
|
+ len += bytes;
|
||
|
+ break;
|
||
|
+ }
|
||
|
+ } while(1);
|
||
|
+ buffer[len] = '\0';
|
||
|
+
|
||
|
+ cfile = (struct parse *)0;
|
||
|
+ status = new_parse (&cfile, -1, buffer, len, "stdin", 0);
|
||
|
+ if (status == ISC_R_SUCCESS) {
|
||
|
+ status = read_client_conf_actual (cfile, ip, client);
|
||
|
+ end_parse (&cfile);
|
||
|
+ }
|
||
|
+ free(buffer);
|
||
|
+ return status;
|
||
|
+}
|
||
|
|
||
|
/* lease-file :== client-lease-statements END_OF_FILE
|
||
|
client-lease-statements :== <nil>
|
||
|
Files a/client/clparse.o and b/client/clparse.o differ
|
||
|
Files a/client/dhclient and b/client/dhclient differ
|