You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sc...@apache.org on 2011/11/07 19:29:47 UTC
svn commit: r1198860 - in /apr/apr/trunk: random/unix/apr_random.c
threadproc/unix/proc.c
Author: sctemme
Date: Mon Nov 7 18:29:46 2011
New Revision: 1198860
URL: http://svn.apache.org/viewvc?rev=1198860&view=rev
Log:
Clarify what happens to the proc structure used by apr_fork().
Set the proc->pid field to the pid of the newly created child.
Note that a mere pid value provides little entropy to mix into
the child random pool.
Modified:
apr/apr/trunk/random/unix/apr_random.c
apr/apr/trunk/threadproc/unix/proc.c
Modified: apr/apr/trunk/random/unix/apr_random.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/random/unix/apr_random.c?rev=1198860&r1=1198859&r2=1198860&view=diff
==============================================================================
--- apr/apr/trunk/random/unix/apr_random.c (original)
+++ apr/apr/trunk/random/unix/apr_random.c Mon Nov 7 18:29:46 2011
@@ -159,6 +159,11 @@ APR_DECLARE(void) apr_random_after_fork(
apr_random_t *r;
for (r = all_random; r; r = r->next)
+ /*
+ * XXX Note: the pid does not provide sufficient entropy to
+ * actually call this secure. See Ben's paper referenced at
+ * the top of this file.
+ */
mixer(r,proc->pid);
}
Modified: apr/apr/trunk/threadproc/unix/proc.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/threadproc/unix/proc.c?rev=1198860&r1=1198859&r2=1198860&view=diff
==============================================================================
--- apr/apr/trunk/threadproc/unix/proc.c (original)
+++ apr/apr/trunk/threadproc/unix/proc.c Mon Nov 7 18:29:46 2011
@@ -219,15 +219,14 @@ APR_DECLARE(apr_status_t) apr_procattr_d
APR_DECLARE(apr_status_t) apr_proc_fork(apr_proc_t *proc, apr_pool_t *pool)
{
int pid;
+
+ memset(proc, 0, sizeof(apr_proc_t));
if ((pid = fork()) < 0) {
return errno;
}
else if (pid == 0) {
- proc->pid = pid;
- proc->in = NULL;
- proc->out = NULL;
- proc->err = NULL;
+ proc->pid = getpid();
apr_random_after_fork(proc);
@@ -235,9 +234,6 @@ APR_DECLARE(apr_status_t) apr_proc_fork(
}
proc->pid = pid;
- proc->in = NULL;
- proc->out = NULL;
- proc->err = NULL;
return APR_INPARENT;
}