mirror of
https://git.busybox.net/udhcp
synced 2025-10-14 01:59:23 +08:00
make udhcpc use /dev/urandom
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
0.9.8 (pending)
|
||||
+ use /dev/urandom to seed xid's (instead of time(0))
|
||||
+ fixed renew behavior (me)
|
||||
+ udhcp now fits nicely into busybox
|
||||
(Glenn McGrath <bug1@optushome.com.au> as well as myself)
|
||||
|
11
README
11
README
@@ -147,6 +147,17 @@ The paramaters for enviromental variables are as follows:
|
||||
|
||||
additional options are easily added in options.c.
|
||||
|
||||
udhcpc will seed its random number generator (used for generating xid's)
|
||||
by reading /dev/urandom. If you have a lot of embedded systems on the same
|
||||
network, with no entropy, you can either seed /dev/urandom by a method of
|
||||
your own, or doing the following on startup:
|
||||
|
||||
ifconfig eth0 > /dev/urandom
|
||||
|
||||
in order to seed /dev/urandom with some data (mac address) unique to your
|
||||
system. If reading /dev/urandom fails, udhcpc will fall back to its old
|
||||
behavior of seeding with time(0).
|
||||
|
||||
udhcpc also responds to SIGUSR1 and SIGUSR2. SIGUSR1 will force a renew state,
|
||||
and SIGUSR2 will force a release of the current lease, and cause udhcpc to
|
||||
go into an inactive state (until it is killed, or receives a SIGUSR1). You do
|
||||
|
6
TODO
6
TODO
@@ -1,17 +1,13 @@
|
||||
TODO
|
||||
----
|
||||
+ using time(0) breaks if the system clock changes, find a portable solution
|
||||
+ make failure of reading functions revert to previous value, not the default
|
||||
+ sanity code for option[OPT_LEN]
|
||||
+ fix aliasing (ie: eth0:0)
|
||||
+ DONE: Make sure get_raw_packet only accepts packets on the specified interface
|
||||
+ better standard linux distro support
|
||||
+ DONE: make config file a command line option for server
|
||||
+ IMPLEMENTED: make forking a command line option
|
||||
+ make sure packet generation works on a wide varitey of arches
|
||||
+ Interoperability testing
|
||||
+ Hooks within the DHCP server
|
||||
+ Additional bootp support in client/server
|
||||
+ Make serverid option in server configurable
|
||||
+ DONE: cause client to generate DHCP_VENDOR option
|
||||
+ Possibly add failure message to DHCP NAK
|
||||
+ Possibly log DHCP NAK failure message in client
|
@@ -35,6 +35,10 @@
|
||||
#include <unistd.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#include "dhcpd.h"
|
||||
@@ -49,7 +53,17 @@ unsigned long random_xid(void)
|
||||
{
|
||||
static int initialized;
|
||||
if (!initialized) {
|
||||
srand(time(0));
|
||||
int fd;
|
||||
unsigned long seed;
|
||||
|
||||
fd = open("/dev/urandom", 0);
|
||||
if (fd < 0 || read(fd, &seed, sizeof(seed)) < 0) {
|
||||
LOG(LOG_WARNING, "Could not load seed from /dev/urandom: %s",
|
||||
strerror(errno));
|
||||
seed = time(0);
|
||||
}
|
||||
if (fd >= 0) close(fd);
|
||||
srand(seed);
|
||||
initialized++;
|
||||
}
|
||||
return rand();
|
||||
|
Reference in New Issue
Block a user