oops, committed to wrong branch accidentally:
Log message: seed $RANDOM from /dev/urandom at startup, too.
This commit is contained in:
12
main.c
12
main.c
@ -1,4 +1,4 @@
|
|||||||
/* $MirBSD: main.c,v 1.2 2004/04/17 00:47:19 tg Exp $ */
|
/* $MirBSD: main.c,v 1.3 2004/04/26 18:24:39 tg Exp $ */
|
||||||
/* $OpenBSD: main.c,v 1.26 2004/01/08 05:43:14 jmc Exp $ */
|
/* $OpenBSD: main.c,v 1.26 2004/01/08 05:43:14 jmc Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -94,6 +94,8 @@ main(int argc, char *argv[])
|
|||||||
char **wp;
|
char **wp;
|
||||||
struct env env;
|
struct env env;
|
||||||
pid_t ppid;
|
pid_t ppid;
|
||||||
|
long trnd;
|
||||||
|
FILE *tfil;
|
||||||
|
|
||||||
#ifdef MEM_DEBUG
|
#ifdef MEM_DEBUG
|
||||||
chmem_set_defaults("ct", 1);
|
chmem_set_defaults("ct", 1);
|
||||||
@ -256,7 +258,13 @@ main(int argc, char *argv[])
|
|||||||
ppid = getppid();
|
ppid = getppid();
|
||||||
setint(global("PPID"), (long) ppid);
|
setint(global("PPID"), (long) ppid);
|
||||||
#ifdef KSH
|
#ifdef KSH
|
||||||
setint(global("RANDOM"), (long) (time((time_t *)0) * kshpid * ppid));
|
trnd = *((long *)kshname);
|
||||||
|
if ((tfil = fopen("/dev/urandom", "rb")) != NULL) {
|
||||||
|
fread(&trnd, 4, 1, tfil);
|
||||||
|
fclose(tfil);
|
||||||
|
}
|
||||||
|
trnd ^= (long) (time((time_t *)0) * kshpid * ppid);
|
||||||
|
setint(global("RANDOM"), trnd);
|
||||||
#endif /* KSH */
|
#endif /* KSH */
|
||||||
/* setstr can't fail here */
|
/* setstr can't fail here */
|
||||||
setstr(global(version_param), ksh_version, KSH_RETURN_ERROR);
|
setstr(global(version_param), ksh_version, KSH_RETURN_ERROR);
|
||||||
|
Reference in New Issue
Block a user