aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Hill <richard.b.hill@intel.com>2012-07-26 09:51:59 -0400
committerJeff Garzik <jgarzik@redhat.com>2012-07-26 09:51:59 -0400
commita9b9bb1df997bd979ad2c6f1f72563d8eec7930b (patch)
tree25f2004d78daed4a92b96b8037f863954ab1be6f
parentca6941f8bae368fc6b66292bfc017a12a8abd9d1 (diff)
downloadrng-tools-a9b9bb1df997bd979ad2c6f1f72563d8eec7930b.tar.gz
Removed timeout option, leaving poll unlimited
Removed timeout variables, parameters, and argument. Poll is now called with -1 as the timeout.
-rw-r--r--rngd.8.in4
-rw-r--r--rngd.c24
-rw-r--r--rngd.h1
-rw-r--r--rngd_linux.c8
-rw-r--r--rngd_linux.h2
5 files changed, 8 insertions, 31 deletions
diff --git a/rngd.8.in b/rngd.8.in
index 2fd357f..2615df9 100644
--- a/rngd.8.in
+++ b/rngd.8.in
@@ -17,7 +17,6 @@ rngd \- Check and feed random data from hardware device to kernel random device
[\fB\-n\fR, \fB\-\-no-tpm=\fI1|0\fR]
[\fB\-q\fR, \fB\-\-quiet\fR]
[\fB\-v\fR, \fB\-\-verbose\fR]
-[\fB\-t\fR, \fB\-\-timeout=\fInnn\fR]
[\fB\-?\fR, \fB\-\-help\fR]
[\fB\-V\fR, \fB\-\-version\fR]
.RI
@@ -81,9 +80,6 @@ Suppress error messages
\fB\-v\fR, \fB\-\-verbose\fR
Report available entropy sources
.TP
-\fB\-t\fI nnn\fR, \fB\-\-timeout=\fInnn\fR
-Interval written to random-device when the entropy pool is full, in seconds, or 0 to disable (default: 60)
-.TP
\fB\-?\fR, \fB\-\-help\fR
Give a short summary of all program options.
.TP
diff --git a/rngd.c b/rngd.c
index f83c562..46ae23a 100644
--- a/rngd.c
+++ b/rngd.c
@@ -99,8 +99,6 @@ static struct argp_option options[] = {
{ "verbose" ,'v', 0, 0, "Report available entropy sources" },
- { "timeout", 't', "nnn", 0,
- "Interval written to random-device when the entropy pool is full, in seconds, or 0 to disable (default: 60)" },
{ "no-tpm", 'n', "1|0", 0,
"do not use tpm as a source of random number input (default: 0)" },
@@ -110,7 +108,6 @@ static struct argp_option options[] = {
static struct arguments default_arguments = {
.random_name = "/dev/random",
.pid_file = "/var/run/rngd.pid",
- .poll_timeout = 60,
.random_step = 64,
.fill_watermark = 2048,
.daemon = true,
@@ -149,15 +146,6 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
case 'r':
rng_default.rng_name = arg;
break;
- case 't': {
- float f;
- if (sscanf(arg, "%f", &f) == 0)
- argp_usage(state);
- else
- arguments->poll_timeout = f;
- break;
- }
-
case 'f':
arguments->daemon = false;
break;
@@ -201,7 +189,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
static struct argp argp = { options, parse_opt, NULL, doc };
-static int update_kernel_random(int random_step, double poll_timeout,
+static int update_kernel_random(int random_step,
unsigned char *buf, fips_ctx_t *fipsctx_in)
{
unsigned char *p;
@@ -217,12 +205,12 @@ static int update_kernel_random(int random_step, double poll_timeout,
for (p = buf; p + random_step <= &buf[FIPS_RNG_BUFFER_SIZE];
p += random_step) {
random_add_entropy(p, random_step);
- random_sleep(poll_timeout);
+ random_sleep();
}
return 0;
}
-static void do_loop(int random_step, double poll_timeout)
+static void do_loop(int random_step)
{
unsigned char buf[FIPS_RNG_BUFFER_SIZE];
int retval = 0;
@@ -250,8 +238,7 @@ static void do_loop(int random_step, double poll_timeout)
work_done = true;
rc = update_kernel_random(random_step,
- poll_timeout, buf,
- iter->fipsctx);
+ buf, iter->fipsctx);
if (rc == 0)
continue; /* succeeded, work done */
@@ -344,8 +331,7 @@ int main(int argc, char **argv)
signal(SIGTERM, term_signal);
}
- do_loop(arguments->random_step,
- arguments->poll_timeout ? : -1.0);
+ do_loop(arguments->random_step);
if (pid_fd >= 0)
unlink(arguments->pid_file);
diff --git a/rngd.h b/rngd.h
index 3ac495f..69343e9 100644
--- a/rngd.h
+++ b/rngd.h
@@ -44,7 +44,6 @@ struct arguments {
int random_step;
int fill_watermark;
- double poll_timeout;
bool quiet;
bool verbose;
diff --git a/rngd_linux.c b/rngd_linux.c
index 173a315..9b76198 100644
--- a/rngd_linux.c
+++ b/rngd_linux.c
@@ -89,7 +89,7 @@ void random_add_entropy(void *buf, size_t size)
}
}
-void random_sleep(double poll_timeout)
+void random_sleep()
{
int ent_count;
struct pollfd pfd = {
@@ -97,11 +97,7 @@ void random_sleep(double poll_timeout)
events: POLLOUT,
};
- if (ioctl(random_fd, RNDGETENTCNT, &ent_count) == 0 &&
- ent_count < arguments->fill_watermark)
- return;
-
- poll(&pfd, 1, 1000.0 * poll_timeout);
+ poll(&pfd, 1, -1);
}
void src_list_add(struct rng *ent_src)
diff --git a/rngd_linux.h b/rngd_linux.h
index d16644b..b543827 100644
--- a/rngd_linux.h
+++ b/rngd_linux.h
@@ -38,7 +38,7 @@ extern void init_kernel_rng(const char* randomdev);
extern void random_add_entropy(void *buf, size_t size);
/* Sleep until the kernel is hungry for entropy */
-extern void random_sleep(double poll_timeout);
+extern void random_sleep();
#endif /* RNGD_LINUX__H */