Skip to content

Commit 40484d2

Browse files
committed
Don't read from /dev/[u]random on GitHub Actions
1 parent d09c90f commit 40484d2

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

.github/workflows/ubuntu20.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ jobs:
1414
- uses: actions/checkout@v2
1515
- run: 'bash --version | head -1'
1616
shell: bash
17-
- run: echo Will read from random
17+
- run: bin/spec
1818
shell: bash
19-
- run: cat /dev/random | base64 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
20-
shell: bash
21-
- run: echo Next read from urandom
22-
shell: bash
23-
- run: cat /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
24-
shell: bash
19+
env:
20+
VERBOSE: true
21+
SHELLPEN_URANDOM: false

shellpen.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,9 +1145,9 @@ shellpen() {
11451145
[ "$existingPenName" = "$penName" ] && { echo "shellpen pens new: pen already exists '$penName'" >&2; return 1; }
11461146
done
11471147

1148-
if [ -n "$SHELLPEN_RANDOM_SOURCE" ] # This is specifically to support GitHub Actions which blocks on urandom
1148+
if [ "$SHELLPEN_URANDOM" = false ] # This is specifically to support GitHub Actions which blocks on /dev/urandom
11491149
then
1150-
local sourceId="$( cat $SHELLPEN_RANDOM_SOURCE | base64 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 )"
1150+
local sourceId="${RANDOM}${RANDOM}${RANDOM}"
11511151
else
11521152
local sourceId="$( cat /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 )"
11531153
fi

src/pens/new.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ do
99
[ "$existingPenName" = "$penName" ] && { echo "!command: pen already exists '$penName'" >&2; return 1; }
1010
done
1111

12-
if [ -n "$SHELLPEN_RANDOM_SOURCE" ] # This is specifically to support GitHub Actions which blocks on urandom
12+
if [ "$SHELLPEN_URANDOM" = false ] # This is specifically to support GitHub Actions which blocks on /dev/urandom
1313
then
14-
local sourceId="$( cat $SHELLPEN_RANDOM_SOURCE | base64 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 )"
14+
local sourceId="${RANDOM}${RANDOM}${RANDOM}"
1515
else
1616
local sourceId="$( cat /dev/urandom | base64 | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 )"
1717
fi

0 commit comments

Comments
 (0)