aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-07-04 18:49:03 -0500
committerRob Landley <rob@landley.net>2018-07-04 18:49:03 -0500
commitff2d528a0a6943bd4247f3c122c145a5b19f0387 (patch)
treee79c2baaa076a33deea48e65cf158b62ec6490da /toys/other
parent4d673c9ad4c65c329a85ebb19c2812ae93183099 (diff)
downloadtoybox-ff2d528a0a6943bd4247f3c122c145a5b19f0387.tar.gz
Add xgetrandom() with probe for new system call (else open/read /dev/{,u}random)
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/shred.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/toys/other/shred.c b/toys/other/shred.c
index 30b5e7d9..e10adc09 100644
--- a/toys/other/shred.c
+++ b/toys/other/shred.c
@@ -33,8 +33,6 @@ GLOBALS(
long offset;
long iterations;
long size;
-
- int ufd;
)
void shred_main(void)
@@ -42,7 +40,6 @@ void shred_main(void)
char **try;
if (!(toys.optflags & FLAG_n)) TT.iterations++;
- TT.ufd = xopenro("/dev/urandom");
// We don't use loopfiles() here because "-" isn't stdin, and want to
// respond to files we can't open via chmod.
@@ -96,7 +93,7 @@ void shred_main(void)
if (toys.optflags & FLAG_x)
if (len-pos < throw) throw = len-pos;
- if (iter != TT.iterations) xread(TT.ufd, toybuf, throw);
+ if (iter != TT.iterations) xgetrandom(toybuf, throw, 0);
if (throw != writeall(fd, toybuf, throw)) perror_msg_raw(*try);
pos += throw;
}