1 |
chainsaw 09/03/30 13:13:28 |
2 |
|
3 |
Added: dhcp-4.0.1-dhclient-stdin-conf.patch |
4 |
Log: |
5 |
Version bump to 4.0.1, stdin config support for dhclient has been rediffed due to upstream changes. Still masked, deleting old ebuild. |
6 |
(Portage version: 2.1.6.11/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 net-misc/dhcp/files/dhcp-4.0.1-dhclient-stdin-conf.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/dhcp/files/dhcp-4.0.1-dhclient-stdin-conf.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/net-misc/dhcp/files/dhcp-4.0.1-dhclient-stdin-conf.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: dhcp-4.0.1-dhclient-stdin-conf.patch |
15 |
=================================================================== |
16 |
diff -uNr dhcp-4.0.1.ORIG/client/clparse.c dhcp-4.0.1/client/clparse.c |
17 |
--- dhcp-4.0.1.ORIG/client/clparse.c 2009-03-30 13:54:47.000000000 +0100 |
18 |
+++ dhcp-4.0.1/client/clparse.c 2009-03-30 13:58:02.000000000 +0100 |
19 |
@@ -174,6 +174,10 @@ |
20 |
#endif |
21 |
} |
22 |
|
23 |
+ /* Read any extra configuration from stdin */ |
24 |
+ read_client_conf_stdin ((struct interface_info *)0, |
25 |
+ &top_level_config); |
26 |
+ |
27 |
/* Set up state and config structures for clients that don't |
28 |
have per-interface configuration statements. */ |
29 |
config = (struct client_config *)0; |
30 |
@@ -203,23 +207,13 @@ |
31 |
return status; |
32 |
} |
33 |
|
34 |
-int read_client_conf_file (const char *name, struct interface_info *ip, |
35 |
+int read_client_conf_actual (struct parse *cfile, struct interface_info *ip, |
36 |
struct client_config *client) |
37 |
{ |
38 |
- int file; |
39 |
- struct parse *cfile; |
40 |
const char *val; |
41 |
int token; |
42 |
isc_result_t status; |
43 |
|
44 |
- if ((file = open (name, O_RDONLY)) < 0) |
45 |
- return uerr2isc (errno); |
46 |
- |
47 |
- cfile = NULL; |
48 |
- status = new_parse(&cfile, file, NULL, 0, path_dhclient_conf, 0); |
49 |
- if (status != ISC_R_SUCCESS || cfile == NULL) |
50 |
- return status; |
51 |
- |
52 |
do { |
53 |
token = peek_token (&val, (unsigned *)0, cfile); |
54 |
if (token == END_OF_FILE) |
55 |
@@ -230,10 +224,74 @@ |
56 |
status = (cfile -> warnings_occurred |
57 |
? ISC_R_BADPARSE |
58 |
: ISC_R_SUCCESS); |
59 |
+ return status; |
60 |
+} |
61 |
+ |
62 |
+int read_client_conf_file (const char *name, struct interface_info *ip, |
63 |
+ struct client_config *client) |
64 |
+{ |
65 |
+ int file; |
66 |
+ struct parse *cfile; |
67 |
+ isc_result_t status; |
68 |
+ |
69 |
+ if ((file = open (name, O_RDONLY)) < 0) |
70 |
+ return uerr2isc (errno); |
71 |
+ |
72 |
+ cfile = (struct parse *)0; |
73 |
+ new_parse (&cfile, file, (char *)0, 0, path_dhclient_conf, 0); |
74 |
+ status = read_client_conf_actual(cfile, ip, client); |
75 |
end_parse (&cfile); |
76 |
return status; |
77 |
} |
78 |
|
79 |
+int read_client_conf_stdin (struct interface_info *ip, |
80 |
+ struct client_config *client) |
81 |
+{ |
82 |
+ int file; |
83 |
+ char *buffer = NULL, *p; |
84 |
+ unsigned buflen, len = 0; |
85 |
+ struct parse *cfile; |
86 |
+ size_t bytes; |
87 |
+ isc_result_t status; |
88 |
+ |
89 |
+ file = fileno(stdin); |
90 |
+ if (isatty (file)) |
91 |
+ return ISC_R_NOTFOUND; |
92 |
+ if (fcntl (file, F_SETFL, O_NONBLOCK) < 0) |
93 |
+ log_fatal ("could not set stdin to non blocking!"); |
94 |
+ |
95 |
+ buflen = BUFSIZ; |
96 |
+ buffer = malloc (BUFSIZ + 1); |
97 |
+ p = buffer; |
98 |
+ do { |
99 |
+ bytes = read (file, p, BUFSIZ); |
100 |
+ if (bytes == 0) |
101 |
+ break; |
102 |
+ if (bytes == -1) |
103 |
+ log_fatal ("failed to read stdin!"); |
104 |
+ if (bytes >= BUFSIZ) { |
105 |
+ buflen += BUFSIZ; |
106 |
+ len += BUFSIZ; |
107 |
+ buffer = realloc (buffer, buflen + 1); |
108 |
+ if (!buffer) |
109 |
+ log_fatal ("not enough buffer to read stdin!"); |
110 |
+ p = buffer + len; |
111 |
+ } else { |
112 |
+ len += bytes; |
113 |
+ break; |
114 |
+ } |
115 |
+ } while(1); |
116 |
+ buffer[len] = '\0'; |
117 |
+ |
118 |
+ cfile = (struct parse *)0; |
119 |
+ status = new_parse (&cfile, -1, buffer, len, "stdin", 0); |
120 |
+ if (status == ISC_R_SUCCESS) { |
121 |
+ status = read_client_conf_actual (cfile, ip, client); |
122 |
+ end_parse (&cfile); |
123 |
+ } |
124 |
+ free(buffer); |
125 |
+ return status; |
126 |
+} |
127 |
|
128 |
/* lease-file :== client-lease-statements END_OF_FILE |
129 |
client-lease-statements :== <nil> |