3 ms·
Can I also override $RANDOM to be a static value? PID seems very guessable/brute-forcible.
by e28eta 12y ago
Can I also override $RANDOM to be a static value? PID seems very guessable/brute-forcible.
- JoshTriplett 12y ago$RANDOM isn't actually in POSIX, and /bin/sh might not implement it at all: /tmp$ cat test.sh #!/bin/sh echo $RANDOM $RANDOM $RANDOM /tmp$ ./test.sh /tmp$ In a shell that implements it, though, such as bash, you can't override it via the environment. However, it's quite difficult to write privileged shell code if you don't trust the environment, notably $PATH. Too many shell features depend on variables, and shells don't automatically sanitize those.