1d3a6b4b0ffa24eb6403dc953dc9568f058c80ec
[oweals/busybox.git] / busybox / patches / udhcp_config_paths.diff
1 Index: include/usage.h
2 ===================================================================
3 RCS file: /var/cvs/busybox/include/usage.h,v
4 retrieving revision 1.191
5 diff -u -r1.191 usage.h
6 --- a/include/usage.h   25 Feb 2004 10:35:55 -0000      1.191
7 +++ b/include/usage.h   5 Mar 2004 13:20:11 -0000
8 @@ -2606,7 +2606,8 @@
9         "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \
10         "\t-q,\t--quit\tQuit after obtaining lease\n" \
11         "\t-r,\t--request=IP\tIP address to request (default: none)\n" \
12 -       "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
13 +       "\t-s,\t--script=file\tRun file at dhcp events (default: " \
14 +       CONFIG_UDHCPC_SCRIPT_PATH ")\n" \
15         "\t-v,\t--version\tDisplay version"
16
17  #define udhcpd_trivial_usage \
18 Index: networking/udhcp/AUTHORS
19 ===================================================================
20 RCS file: /var/cvs/busybox/networking/udhcp/AUTHORS,v
21 retrieving revision 1.3
22 diff -u -r1.3 AUTHORS
23 --- a/networking/udhcp/AUTHORS  18 Dec 2003 22:25:38 -0000      1.3
24 +++ b/networking/udhcp/AUTHORS  5 Mar 2004 13:20:11 -0000
25 @@ -10,5 +10,5 @@
26  Moreton Bay    (http://www.moretonbay.com/)
27  Vladimir Oleynik <dzo@simtrea.ru> Size optimizations
28
29 -
30 +Tony J. White <tjw@tjw.org> additional busybox build options
31
32 Index: networking/udhcp/Config.in
33 ===================================================================
34 RCS file: /var/cvs/busybox/networking/udhcp/Config.in,v
35 retrieving revision 1.5
36 diff -u -r1.5 Config.in
37 --- a/networking/udhcp/Config.in        22 Oct 2003 09:58:38 -0000      1.5
38 +++ b/networking/udhcp/Config.in        5 Mar 2004 13:20:11 -0000
39 @@ -58,5 +58,62 @@
40
41           See http://udhcp.busybox.net for further details.
42
43 +menu "udhcpd Configuration Options"
44 +       depends on CONFIG_UDHCPD
45 +
46 +config CONFIG_UDHCPD_CONF_PATH
47 +       string "Path to default udhcpd.conf"
48 +       default "/etc/udhcpd.conf"
49 +       depends on CONFIG_UDHCPD
50 +       help
51 +         The full path to udhcpd's default configuration file.
52 +         (default is: /etc/udhcpd.conf)
53 +
54 +config CONFIG_UDHCPD_LEASE_PATH
55 +       string "Path to default udhcpd.leases"
56 +       default "/var/lib/misc/udhcpd.leases"
57 +       depends on CONFIG_UDHCPD
58 +       help
59 +         The full path to udhcpd's default leases file.
60 +         (default is: /var/lib/misc/udhcpd.leases)
61 +
62 +config CONFIG_UDHCPD_PID_PATH
63 +       string "Path to default udhcpd PID file"
64 +       default "/var/run/udhcpd.pid"
65 +       depends on CONFIG_UDHCPD
66 +       help
67 +         The full path to udhcpd's default pid file.
68 +         (default is: /var/run/udhcpd.pid)
69 +
70 +endmenu
71 +
72 +menu "udhcpc Configuration Options"
73 +       depends on CONFIG_UDHCPC
74 +
75 +config CONFIG_UDHCPC_SCRIPT_PATH
76 +       string "Path to default udhcpc event script"
77 +       depends on CONFIG_UDHCPC
78 +       help
79 +         The full path to udhcpc's default event script file.
80 +         (default is: /usr/share/udhcpc/default.script OR
81 +         /share/udhcpc/default.script if CONFIG_INSTALL_NO_USR is set)
82 +       
83 +         When udhcpc is started it executes this script to take care
84 +         of system tasks after it completes DHCP communication.  Such
85 +         tasks include putting network interfaces up or down, setting
86 +         DNS info, adding routing information, etc.
87 +
88 +if CONFIG_INSTALL_NO_USR
89 +config CONFIG_UDHCPC_SCRIPT_PATH
90 +       default "/share/udhcpc/default.script"
91 +endif
92 +
93 +if !CONFIG_INSTALL_NO_USR
94 +config CONFIG_UDHCPC_SCRIPT_PATH
95 +       default "/usr/share/udhcpc/default.script"
96 +endif
97 +
98 +endmenu
99 +
100  endmenu
101
102 Index: networking/udhcp/README
103 ===================================================================
104 RCS file: /var/cvs/busybox/networking/udhcp/README,v
105 retrieving revision 1.3
106 diff -u -r1.3 README
107 --- a/networking/udhcp/README   18 Dec 2003 22:25:38 -0000      1.3
108 +++ b/networking/udhcp/README   5 Mar 2004 13:20:11 -0000
109 @@ -9,27 +9,42 @@
110  compile time options
111  -------------------
112
113 -The Makefile contains three of the compile time options:
114 +The following options can be adjusted when configuring busybox:
115
116 -       UDHCP_DEBUG: If UDHCP_DEBUG is defined, udhcpd will output extra
117 -       debugging output, compile with -g, and not fork to the background when
118 -       run.
119 -       UDHCP_SYSLOG: If UDHCP_SYSLOG is defined, udhcpd will log all its
120 -       messages syslog, otherwise, it will attempt to log them to stdout.
121 -
122 -       COMBINED_BINARY: If COMBINED_BINARY is define, one binary, udhcpd,
123 -       is created. If called as udhcpd, the dhcp server will be started.
124 -       If called as udhcpc, the dhcp client will be started.
125 -
126 -dhcpd.h contains the other three compile time options:
127 -
128 -       LEASE_TIME: The default lease time if not specified in the config
129 -       file.
130 +       CONFIG_FEATURE_UDHCP_DEBUG:
131 +         If this is defined, udhcpd will output extra debugging output,
132 +         compile with -g, and not fork to the background when run.
133
134 -       LEASES_FILE: The default file for storing leases.
135 -
136 -       DHCPD_CONFIG_FILE: The defualt config file to use.
137 +       CONFIG_FEATURE_UDHCP_SYSLOG:
138 +         If this is defined, udhcpd will log all its messages syslog,
139 +         otherwise, it will attempt to log them to stdout.
140 +
141 +       CONFIG_UDHCPD_CONF_PATH:
142 +         The full path to udhcpd's default configuration file.
143 +
144 +       CONFIG_UDHCPD_LEASE_PATH:
145 +         The full path to udhcpd's default leases file.
146 +
147 +       CONFIG_UDHCPD_PID_PATH:
148 +         The full path to udhcpd's default pid file.
149 +
150 +       CONFIG_UDHCPC_SCRIPT_PATH:
151 +         The full path to udhcpc's default event script file.
152 +         (default is: /usr/share/udhcpc/default.script)
153 +
154 +         When udhcpc is started it executes this script to take care
155 +         of system tasks after it completes DHCP communication.  Such
156 +         tasks include putting network interfaces up or down, setting
157 +         DNS info, adding routing information, etc.
158 +
159 +
160 +dhcpd.h contains the another compile time option:
161
162 +       LEASE_TIME:
163 +         The default lease time if not specified in the config file.
164 +         This option can also be changed at runtime with the 'lease'
165 +         configuration option.
166 +
167  options.c contains a set of dhcp options for the client:
168
169         name[10]: The name of the option as it will appear in scripts
170 Index: networking/udhcp/README.udhcpc
171 ===================================================================
172 RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpc,v
173 retrieving revision 1.3
174 diff -u -r1.3 README.udhcpc
175 --- a/networking/udhcp/README.udhcpc    11 Dec 2002 21:12:44 -0000      1.3
176 +++ b/networking/udhcp/README.udhcpc    5 Mar 2004 13:20:11 -0000
177 @@ -23,7 +23,8 @@
178  -q, --quit                      Quit after obtaining lease
179  -r, --request=IP                IP address to request (default: none)
180  -s, --script=file               Run file at dhcp events (default:
181 -                                /usr/share/udhcpc/default.script)
182 +                                /usr/share/udhcpc/default.script or
183 +                               CONFIG_UDHCPC_SCRIPT_PATH at build time)
184  -v, --version                   Display version
185
186
187 Index: networking/udhcp/README.udhcpd
188 ===================================================================
189 RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpd,v
190 retrieving revision 1.1
191 diff -u -r1.1 README.udhcpd
192 --- a/networking/udhcp/README.udhcpd    31 Oct 2002 19:21:27 -0000      1.1
193 +++ b/networking/udhcp/README.udhcpd    5 Mar 2004 13:20:11 -0000
194 @@ -50,10 +50,14 @@
195
196  compile time options
197  -------------------
198 +
199 +During busybox configuration, you can change the default paths for
200 +udhcpd.conf, udhcpd.leases, and udhcpd.pid files.  See README for
201 +more details.
202
203 -dhcpd.h contains the other two compile time options:
204 +dhcpd.h contains the compile time option:
205
206         LEASE_TIME: The default lease time if not specified in the config
207         file.
208 +
209
210 -       DHCPD_CONFIG_FILE: The defualt config file to use.
211 Index: networking/udhcp/dhcpc.h
212 ===================================================================
213 RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.h,v
214 retrieving revision 1.4
215 diff -u -r1.4 dhcpc.h
216 --- a/networking/udhcp/dhcpc.h  30 Jan 2004 23:45:12 -0000      1.4
217 +++ b/networking/udhcp/dhcpc.h  5 Mar 2004 13:20:11 -0000
218 @@ -2,7 +2,11 @@
219  #ifndef _DHCPC_H
220  #define _DHCPC_H
221
222 -#define DEFAULT_SCRIPT  "/usr/share/udhcpc/default.script"
223 +#ifdef CONFIG_UDHCPC_SCRIPT_PATH
224 + #define DEFAULT_SCRIPT  CONFIG_UDHCPC_SCRIPT_PATH
225 +#else
226 + #define DEFAULT_SCRIPT  "/usr/share/udhcpc/default.script"
227 +#endif
228
229  /* allow libbb_udhcp.h to redefine DEFAULT_SCRIPT */
230  #include "libbb_udhcp.h"
231 Index: networking/udhcp/dhcpd.c
232 ===================================================================
233 RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.c,v
234 retrieving revision 1.5
235 diff -u -r1.5 dhcpd.c
236 --- a/networking/udhcp/dhcpd.c  30 Jan 2004 23:45:12 -0000      1.5
237 +++ b/networking/udhcp/dhcpd.c  5 Mar 2004 13:20:11 -0000
238 @@ -70,6 +70,13 @@
239         struct dhcpOfferedAddr *lease;
240         int max_sock;
241         unsigned long num_ips;
242 +       int daemonize = 1;
243 +
244 +       while (strcmp(argv[1],"-f")==0 || strcmp(argv[1],"--foreground")==0) {
245 +               daemonize = 0;
246 +               argv++;
247 +               argc--;
248 +       }
249
250         memset(&server_config, 0, sizeof(struct server_config_t));
251         read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
252 @@ -99,9 +106,8 @@
253                            &server_config.server, server_config.arp) < 0)
254                 return 1;
255
256 -#ifndef UDHCP_DEBUG
257 -       background(server_config.pidfile); /* hold lock during fork. */
258 -#endif
259 +       if(daemonize)
260 +               background(server_config.pidfile); /* hold lock during fork. */
261
262         /* Setup the signal pipe */
263         udhcp_sp_setup();
264 Index: networking/udhcp/dhcpd.h
265 ===================================================================
266 RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.h,v
267 retrieving revision 1.5
268 diff -u -r1.5 dhcpd.h
269 --- a/networking/udhcp/dhcpd.h  30 Jan 2004 23:45:12 -0000      1.5
270 +++ b/networking/udhcp/dhcpd.h  5 Mar 2004 13:20:12 -0000
271 @@ -15,11 +15,25 @@
272
273  /* the period of time the client is allowed to use that address */
274  #define LEASE_TIME              (60*60*24*10) /* 10 days of seconds */
275 -#define LEASES_FILE            "/var/lib/misc/udhcpd.leases"
276 +
277 +#ifdef CONFIG_UDHCPD_LEASE_PATH
278 + #define LEASES_FILE            CONFIG_UDHCPD_LEASE_PATH
279 +#else
280 + #define LEASES_FILE           "/var/lib/misc/udhcpd.leases"
281 +#endif
282
283  /* where to find the DHCP server configuration file */
284 -#define DHCPD_CONF_FILE         "/etc/udhcpd.conf"
285 +#ifdef CONFIG_UDHCPD_CONF_PATH
286 + #define DHCPD_CONF_FILE         CONFIG_UDHCPD_CONF_PATH
287 +#else
288 + #define DHCPD_CONF_FILE         "/etc/udhcpd.conf"
289 +#endif
290
291 +#ifdef CONFIG_UDHCPD_PID_PATH
292 + #define DHCPD_PID_FILE         CONFIG_UDHCPD_PID_PATH
293 +#else
294 + #define DHCPD_PID_FILE         "/var/run/udhcpd.pid"
295 +#endif
296  /*****************************************************************/
297  /* Do not modify below here unless you know what you are doing!! */
298  /*****************************************************************/
299 Index: networking/udhcp/files.c
300 ===================================================================
301 RCS file: /var/cvs/busybox/networking/udhcp/files.c,v
302 retrieving revision 1.13
303 diff -u -r1.13 files.c
304 --- a/networking/udhcp/files.c  30 Jan 2004 23:45:12 -0000      1.13
305 +++ b/networking/udhcp/files.c  5 Mar 2004 13:20:13 -0000
306 @@ -166,7 +166,7 @@
307         {"offer_time",  read_u32, &(server_config.offer_time),  "60"},
308         {"min_lease",   read_u32, &(server_config.min_lease),   "60"},
309         {"lease_file",  read_str, &(server_config.lease_file),  LEASES_FILE},
310 -       {"pidfile",     read_str, &(server_config.pidfile),     "/var/run/udhcpd.pid"},
311 +       {"pidfile",     read_str, &(server_config.pidfile),     DHCPD_PID_FILE},
312         {"notify_file", read_str, &(server_config.notify_file), ""},
313         {"siaddr",      read_ip,  &(server_config.siaddr),      "0.0.0.0"},
314         {"sname",       read_str, &(server_config.sname),       ""},
315 Index: networking/udhcp/libbb_udhcp.h
316 ===================================================================
317 RCS file: /var/cvs/busybox/networking/udhcp/libbb_udhcp.h,v
318 retrieving revision 1.5
319 diff -u -r1.5 libbb_udhcp.h
320 --- a/networking/udhcp/libbb_udhcp.h    18 Dec 2003 22:25:38 -0000      1.5
321 +++ b/networking/udhcp/libbb_udhcp.h    5 Mar 2004 13:20:13 -0000
322 @@ -3,11 +3,6 @@
323  /* bit of a hack, do this no matter what the order of the includes.
324   * (for busybox) */
325
326 -#ifdef CONFIG_INSTALL_NO_USR
327 -#undef DEFUALT_SCRIPT
328 -#define DEFAULT_SCRIPT  "/share/udhcpc/default.script"
329 -#endif
330 -
331  #ifndef _LIBBB_UDHCP_H
332  #define _LIBBB_UDHCP_H
333