Skip to content

Instantly share code, notes, and snippets.

@DevoKun
Created September 30, 2014 15:40
Show Gist options
  • Save DevoKun/f4ce8026b407fa94983f to your computer and use it in GitHub Desktop.
Save DevoKun/f4ce8026b407fa94983f to your computer and use it in GitHub Desktop.
Compile Bash on MacOS X to patch against ShellShock bug
#!/bin/bash
#
# Tested on MacOS X 10.5 for PowerPC (powerpc-apple-darwin9.8.0)
# Using Xcode 3 (powerpc-apple-darwin9-gcc-4.0.1)
# /Developer/usr/bin/xcodebuild -version
# Component versions: DevToolsCore-921.0; DevToolsSupport-893.0
# Compile Bash 4.3
# bash-4.3.tar.gz 26-Feb-2014 09:25
# bash43-025 released on September 24th, 2014 officially fixes the bug:
# https://ftp.gnu.org/gnu/bash/bash-4.3-patches/
curl -O -k https://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
tar zxf bash-4.3.tar.gz
cd bash-4.3
ruby -e '26.times { |i| i+=1; system("curl -O -k https://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-" + ("000000" + i.to_s)[(6+i.to_s.length - 3)..-1]); }'
find . -maxdepth 1 -iname bash43-0\* | awk '{print "patch -p0 < "$0;}' | sh
./configure
make
# Installs to /usr/local/bin/bash
OLDVER=$(/bin/bash --version | tr '\n' ' ' | cut -d " " -f 4 | cut -d "(" -f 1)
mv /bin/bash /bin/bash-${OLDVER}
ln -s /usr/local/bin/bash /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment