summaryrefslogtreecommitdiff
path: root/entropy.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2004-03-01 02:25:32 +0000
committerColin Watson <cjwatson@debian.org>2004-03-01 02:25:32 +0000
commitea8116a11e3de70036dbc665ccb0d486cf89cac9 (patch)
treed73ccdff78d8608e156465af42e6a1b3527fb2d6 /entropy.c
parente39b311381a5609cc05acf298c42fba196dc524b (diff)
parentf5bda272678ec6dccaa5f29379cf60cb855018e8 (diff)
Merge 3.8p1 to the trunk. This builds and runs, but I haven't tested it
extensively yet. ProtocolKeepAlives is now just a compatibility alias for ServerAliveInterval.
Diffstat (limited to 'entropy.c')
-rw-r--r--entropy.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/entropy.c b/entropy.c
index d7c7fdf6e..572e8cece 100644
--- a/entropy.c
+++ b/entropy.c
@@ -36,16 +36,16 @@
36 36
37/* 37/*
38 * Portable OpenSSH PRNG seeding: 38 * Portable OpenSSH PRNG seeding:
39 * If OpenSSL has not "internally seeded" itself (e.g. pulled data from 39 * If OpenSSL has not "internally seeded" itself (e.g. pulled data from
40 * /dev/random), then we execute a "ssh-rand-helper" program which 40 * /dev/random), then we execute a "ssh-rand-helper" program which
41 * collects entropy and writes it to stdout. The child program must 41 * collects entropy and writes it to stdout. The child program must
42 * write at least RANDOM_SEED_SIZE bytes. The child is run with stderr 42 * write at least RANDOM_SEED_SIZE bytes. The child is run with stderr
43 * attached, so error/debugging output should be visible. 43 * attached, so error/debugging output should be visible.
44 * 44 *
45 * XXX: we should tell the child how many bytes we need. 45 * XXX: we should tell the child how many bytes we need.
46 */ 46 */
47 47
48RCSID("$Id: entropy.c,v 1.46 2003/08/25 01:16:21 mouring Exp $"); 48RCSID("$Id: entropy.c,v 1.48 2003/11/21 12:56:47 djm Exp $");
49 49
50#ifndef OPENSSL_PRNG_ONLY 50#ifndef OPENSSL_PRNG_ONLY
51#define RANDOM_SEED_SIZE 48 51#define RANDOM_SEED_SIZE 48
@@ -86,16 +86,16 @@ seed_rng(void)
86 close(p[1]); 86 close(p[1]);
87 close(devnull); 87 close(devnull);
88 88
89 if (original_uid != original_euid && 89 if (original_uid != original_euid &&
90 ( seteuid(getuid()) == -1 || 90 ( seteuid(getuid()) == -1 ||
91 setuid(original_uid) == -1) ) { 91 setuid(original_uid) == -1) ) {
92 fprintf(stderr, "(rand child) setuid(%li): %s\n", 92 fprintf(stderr, "(rand child) setuid(%li): %s\n",
93 (long int)original_uid, strerror(errno)); 93 (long int)original_uid, strerror(errno));
94 _exit(1); 94 _exit(1);
95 } 95 }
96 96
97 execl(SSH_RAND_HELPER, "ssh-rand-helper", NULL); 97 execl(SSH_RAND_HELPER, "ssh-rand-helper", NULL);
98 fprintf(stderr, "(rand child) Couldn't exec '%s': %s\n", 98 fprintf(stderr, "(rand child) Couldn't exec '%s': %s\n",
99 SSH_RAND_HELPER, strerror(errno)); 99 SSH_RAND_HELPER, strerror(errno));
100 _exit(1); 100 _exit(1);
101 } 101 }
@@ -114,12 +114,12 @@ seed_rng(void)
114 close(p[0]); 114 close(p[0]);
115 115
116 if (waitpid(pid, &ret, 0) == -1) 116 if (waitpid(pid, &ret, 0) == -1)
117 fatal("Couldn't wait for ssh-rand-helper completion: %s", 117 fatal("Couldn't wait for ssh-rand-helper completion: %s",
118 strerror(errno)); 118 strerror(errno));
119 signal(SIGCHLD, old_sigchld); 119 signal(SIGCHLD, old_sigchld);
120 120
121 /* We don't mind if the child exits upon a SIGPIPE */ 121 /* We don't mind if the child exits upon a SIGPIPE */
122 if (!WIFEXITED(ret) && 122 if (!WIFEXITED(ret) &&
123 (!WIFSIGNALED(ret) || WTERMSIG(ret) != SIGPIPE)) 123 (!WIFSIGNALED(ret) || WTERMSIG(ret) != SIGPIPE))
124 fatal("ssh-rand-helper terminated abnormally"); 124 fatal("ssh-rand-helper terminated abnormally");
125 if (WEXITSTATUS(ret) != 0) 125 if (WEXITSTATUS(ret) != 0)
@@ -134,7 +134,7 @@ seed_rng(void)
134} 134}
135 135
136void 136void
137init_rng(void) 137init_rng(void)
138{ 138{
139#if defined (DISABLED_BY_DEBIAN) 139#if defined (DISABLED_BY_DEBIAN)
140 /* drow: Is this check still too strict for Debian? */ 140 /* drow: Is this check still too strict for Debian? */