From owner-cvs-all Tue Feb 5 17:26: 5 2002 Delivered-To: cvs-all@freebsd.org Received: from cain.gsoft.com.au (genesi.lnk.telstra.net [139.130.136.161]) by hub.freebsd.org (Postfix) with ESMTP id 5A27637B41A; Tue, 5 Feb 2002 17:25:31 -0800 (PST) Received: from chowder.gsoft.com.au (root@localhost [127.0.0.1]) by cain.gsoft.com.au (8.11.6/8.11.6) with ESMTP id g161PMZ68026; Wed, 6 Feb 2002 11:55:22 +1030 (CST) (envelope-from doconnor@gsoft.com.au) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <20020205134833.T59017@elvis.mu.org> Date: Wed, 06 Feb 2002 11:55:21 +1030 (CST) From: "Daniel O'Connor" To: Alfred Perlstein Subject: Re: cvs commit: src/lib/libpam/modules/pam_unix pam_unix.c Cc: cvs-all@freebsd.org, cvs-committers@freebsd.org, des@freebsd.org, Mark Murray , "Andrey A. Chernov" Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 05-Feb-2002 Alfred Perlstein wrote: >> To see the bug, run following test application with "call_pam" set to 1 >> and 0 > > I understand the issue you're bringing up, would it make sense > to create/utilize a save/restore random() context function? No need to create one.. setstate() returns the old state which can then be passed back to setstate(). eg.. #include #include void foo(void); int main(int argc, char **argv) { printf("%ld\n", random()); foo(); printf("%ld\n", random()); printf("%ld\n", random()); foo(); printf("%ld\n", random()); } void foo(void) { char *rndstate; char state[16]; rndstate = initstate(123456789, state, sizeof(state)); if (rndstate == NULL) { printf("Unable to reseed\n"); exit(1); } srandomdev(); printf("foo - %ld\n", random()); setstate(rndstate); } --- Daniel O'Connor software and network engineer for Genesis Software - http://www.gsoft.com.au "The nice thing about standards is that there are so many of them to choose from." -- Andrew Tanenbaum To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message