mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-21 09:47:01 +02:00
Compare commits
80
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3388b36c22 | ||
|
|
1bf0ff5574 | ||
|
|
6e324f1b54 | ||
|
|
96cadc4105 | ||
|
|
c2c3f527c6 | ||
|
|
70d71f20e8 | ||
|
|
b2f8c26282 | ||
|
|
f0478ffb43 | ||
|
|
17f3517c01 | ||
|
|
8b7b199384 | ||
|
|
93302942c5 | ||
|
|
7b0821367a | ||
|
|
3082392397 | ||
|
|
3d5441fba2 | ||
|
|
5c15ad4ac4 | ||
|
|
9d9f030e30 | ||
|
|
bee42e422f | ||
|
|
550ce0bd1c | ||
|
|
01531fabda | ||
|
|
3f6aa81fb4 | ||
|
|
53399b11d4 | ||
|
|
84287eba8e | ||
|
|
90759eb293 | ||
|
|
50f8dc37b9 | ||
|
|
c219f96c1d | ||
|
|
2415d7d4ee | ||
|
|
8138d582ab | ||
|
|
907ac98c9c | ||
|
|
a6f8181211 | ||
|
|
47a5a9443d | ||
|
|
21e205dea6 | ||
|
|
3785a77232 | ||
|
|
09f63da485 | ||
|
|
a35be8497e | ||
|
|
b7bbcf5bb7 | ||
|
|
c25644e70d | ||
|
|
08a0838518 | ||
|
|
20c3be4446 | ||
|
|
7e8b616708 | ||
|
|
a809a91af2 | ||
|
|
84a2654f24 | ||
|
|
020ebdb41c | ||
|
|
4158d6a0aa | ||
|
|
bd15cadb6c | ||
|
|
74d161cdd8 | ||
|
|
fc94b29d5f | ||
|
|
bbdfa9b7a2 | ||
|
|
7c7f08f422 | ||
|
|
c647520062 | ||
|
|
4a14826629 | ||
|
|
349cb81752 | ||
|
|
e3aad1a249 | ||
|
|
6127bdb3d6 | ||
|
|
6f88b0cd26 | ||
|
|
89ed9e7565 | ||
|
|
dc9065dd76 | ||
|
|
b518a88354 | ||
|
|
020fdd4939 | ||
|
|
1524ed9440 | ||
|
|
597280c3c6 | ||
|
|
d3edd09550 | ||
|
|
cc62982233 | ||
|
|
3f60d435ee | ||
|
|
c112de8d23 | ||
|
|
5f5210b08d | ||
|
|
c2a452d3b1 | ||
|
|
42a47d656c | ||
|
|
f22bee6870 | ||
|
|
ad2cb43392 | ||
|
|
1ae665cf41 | ||
|
|
2519850712 | ||
|
|
82eece415e | ||
|
|
92ff35ae13 | ||
|
|
78b5f7d75e | ||
|
|
32d5f6a4df | ||
|
|
d48988ef83 | ||
|
|
686a753ff5 | ||
|
|
d006f1a2ae | ||
|
|
f69f964d04 | ||
|
|
4692a33dc0 |
No files matched your search
+217
-166
@@ -2,10 +2,48 @@ name: Build palera1n
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'src/**'
|
||||
- 'docs/**'
|
||||
- 'patches/**'
|
||||
- 'include/**'
|
||||
- 'Makefile'
|
||||
- 'CMakeLists.txt'
|
||||
- '.github/workflows/build.yml'
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies (packages)
|
||||
run: |
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install mandoc make
|
||||
|
||||
- name: Build Documentation
|
||||
run: |
|
||||
make -j$(nproc) docs
|
||||
mkdir ready
|
||||
cp docs/*.html docs/mandoc.css ready
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: wangyucode/[email protected]
|
||||
with:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
port: ${{ secrets.NICKCHAN_FTP_PORT }}
|
||||
username: palera1n
|
||||
privateKey: ${{ secrets.NICKCHAN_FTP_KEY }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
|
||||
build-darwin:
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -25,9 +63,10 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
MBEDTLS_VERSION: 3.3.0
|
||||
LIBUSB_VERSION: 1.0.26
|
||||
READLINE_VERSION: 8.2
|
||||
NCURSES_VERSION: 6.4
|
||||
SLANG_VERSION: 2.3.3
|
||||
NEWT_VERSION: 0.52.23
|
||||
POPT_VERSION: 1.19
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -38,27 +77,29 @@ jobs:
|
||||
- name: Install dependencies (packages)
|
||||
run: |
|
||||
sudo /usr/local/bin/pip3 install jsonschema jinja2
|
||||
brew install make autoconf automake pkg-config gnu-sed ncurses
|
||||
brew install make autoconf automake pkg-config gnu-sed gettext
|
||||
sudo rm -rf /usr/local/Frameworks/Python*
|
||||
curl -LO https://github.com/ProcursusTeam/ldid/releases/download/v2.1.5-procursus7/ldid_macosx_x86_64
|
||||
sudo install -m755 ldid_macosx_x86_64 /usr/local/bin/ldid
|
||||
|
||||
- name: Download dependencies (embedded binaries)
|
||||
run: |
|
||||
make -j5 download-deps
|
||||
echo "SDK=$(xcrun -sdk ${{ matrix.os }} --show-sdk-path)" >> $GITHUB_ENV
|
||||
|
||||
- name: Download dependencies (source code)
|
||||
run: |
|
||||
curl -LOOOO \
|
||||
curl -LOOOOOO \
|
||||
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
|
||||
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
|
||||
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
|
||||
https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz
|
||||
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
|
||||
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
|
||||
https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz
|
||||
|
||||
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
|
||||
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
|
||||
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
|
||||
tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz
|
||||
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
|
||||
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
|
||||
tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libplist
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
|
||||
@@ -75,15 +116,14 @@ jobs:
|
||||
echo "CC=$(xcrun --find cc)" >> $GITHUB_ENV
|
||||
echo "CXX=$(xcrun --find c++)" >> $GITHUB_ENV
|
||||
echo "CPP=$(xcrun --find cc) -E" >> $GITHUB_ENV
|
||||
echo "CFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include" >> $GITHUB_ENV
|
||||
echo "CPPFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Wno-error-implicit-function-declaration" >> $GITHUB_ENV
|
||||
echo "CXXFLAGS=-stdlib=libc++ -g -Os -isysroot ${{ env.SDK }} -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isystem $(pwd)/sysroot/usr/local/include" >> $GITHUB_ENV
|
||||
echo "CFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Os" >> $GITHUB_ENV
|
||||
echo "CPPFLAGS=-g -Os -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isysroot ${{ env.SDK }} -isystem $(pwd)/sysroot/usr/local/include -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
|
||||
echo "CXXFLAGS=-stdlib=libc++ -g -Os -isysroot ${{ env.SDK }} -arch ${{ matrix.arch }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -isystem $(pwd)/sysroot/usr/local/include -Os" >> $GITHUB_ENV
|
||||
echo "LDFLAGS=-g -Wl,-dead_strip -arch ${{ matrix.arch }} -isysroot ${{ env.SDK }} -m${{ matrix.os }}-version-min=${{ matrix.minos }} -L$(pwd)/sysroot/usr/local/lib" >> $GITHUB_ENV
|
||||
echo "CFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
|
||||
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
|
||||
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration" >> $GITHUB_ENV
|
||||
echo "CFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
|
||||
echo "CXXFLAGS_FOR_BUILD=-stdlib=libc++ -arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Os" >> $GITHUB_ENV
|
||||
echo "CPPFLAGS_FOR_BUILD=-arch $(uname -m) -isysroot $(xcrun -sdk macosx --show-sdk-path) -Wno-error-implicit-function-declaration -Os" >> $GITHUB_ENV
|
||||
echo "LDFLAGS_FOR_BUILD=-Wl,-dead_strip" >> $GITHUB_ENV
|
||||
echo $(echo $(brew --cellar)/ncurses/*/bin/tic | sed 's|/tic||') >> $GITHUB_PATH
|
||||
mkdir -p $(pwd)/sysroot/usr/local/lib
|
||||
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
|
||||
|
||||
@@ -119,50 +159,13 @@ jobs:
|
||||
gsed -E /'__API_UNAVAILABLE'/d < ${TARGET_SYSROOT}/usr/include/pthread.h > sysroot/usr/local/include/pthread.h
|
||||
gsed -i -E s/'__API_UNAVAILABLE\(.*\)'// sysroot/usr/local/include/IOKit/IOKitLib.h
|
||||
|
||||
- name: Build ncurses
|
||||
run: |
|
||||
cd ncurses-${{ env.NCURSES_VERSION }}
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--with-build-cc="${{ env.CC }}" \
|
||||
--with-build-cflags="${{ env.CFLAGS_FOR_NUILD }}" \
|
||||
--with-build-cpp="${{ env.CC }} -E" \
|
||||
--with-build-cppflags="${{ env.CPPFLAGS_FOR_BUILD }}" \
|
||||
--with-build-ldflags="${{ env.LDFLAGS_FOR_BUILD }}" \
|
||||
--with-pthread \
|
||||
--enable-const \
|
||||
--enable-ext-colors \
|
||||
--enable-ext-mouse \
|
||||
--enable-ext-putwin \
|
||||
--enable-wattr-macros \
|
||||
--disable-overwrite \
|
||||
--without-debug \
|
||||
--without-tests \
|
||||
--enable-sigwinch \
|
||||
--enable-const \
|
||||
--enable-symlinks \
|
||||
--enable-termcap \
|
||||
--enable-pc-files \
|
||||
--without-x11-rgb \
|
||||
--with-tic-path=$(echo $(brew --cellar)/ncurses/*/bin/tic) \
|
||||
--includedir="${{ env.PREFIX }}/include" \
|
||||
--with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \
|
||||
--enable-widec \
|
||||
--with-default-terminfo-dir="/opt/procursus/share/terminfo" \
|
||||
--with-terminfo-dirs="/var/jb/usr/share/terminfo:/opt/procursus/share/terminfo:/opt/local/share/terminfo:/opt/homebrew/share/terminfo:/usr/local/share/terminfo:/opt/sw/share/terminfo:/sw/share/terminfo:/usr/share/terminfo" \
|
||||
LDFLAGS="${{ env.LDFLAGS }}" \
|
||||
PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig" || (cat config.log && exit 1)
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build Mbed TLS
|
||||
run: |
|
||||
cd mbedtls-${{ env.MBEDTLS_VERSION }}
|
||||
cat ../patches/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
||||
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
SDKROOT="${{ env.SDK }}" cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CROSSCOMPILING=true \
|
||||
-DCMAKE_SYSTEM_NAME=Darwin \
|
||||
@@ -175,19 +178,8 @@ jobs:
|
||||
-DENABLE_PROGRAMS=OFF \
|
||||
-DMBEDTLS_FATAL_WARNINGS=OFF \
|
||||
-DCMAKE_INSTALL_SYSCONFDIR="/etc"
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build libusb
|
||||
run: |
|
||||
cd libusb-${{ env.LIBUSB_VERSION }}
|
||||
if [ "${{ matrix.os }}" != "macosx" ]; then
|
||||
curl -Lo libusb.patch https://github.com/ProcursusTeam/Procursus/raw/5f4f302f6cb81ce10c7d92ffefd75c004b5da18f/build_patch/libusb/0001-Get-rid-of-some-macro-checks.patch
|
||||
cat libusb.patch | patch -sN -d . -p1
|
||||
fi
|
||||
./configure ${{ env.CONFIGURE_ARGS }} --disable-udev --enable-log
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
gmake -j$(sysctl -n hw.ncpu) \
|
||||
SDKROOT="${{ env.SDK }}"
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
@@ -199,6 +191,51 @@ jobs:
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build S-Lang
|
||||
run: |
|
||||
cd slang-${{ env.SLANG_VERSION }}
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--without-x \
|
||||
--without-pcre \
|
||||
--without-onig \
|
||||
--without-z \
|
||||
--without-png \
|
||||
--without-iconv
|
||||
gmake -j$(sysctl -n hw.ncpu) static
|
||||
gmake -j$(sysctl -n hw.ncpu) install-static DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build popt
|
||||
run: |
|
||||
cd popt-popt-${{ env.POPT_VERSION }}-release
|
||||
autoreconf -fiv
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--without-libiconv-prefix \
|
||||
--without-libintl-prefix \
|
||||
--disable-nls \
|
||||
--disable-werror
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build newt
|
||||
run: |
|
||||
cd newt-${{ env.NEWT_VERSION }}
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--with-readline=gnu \
|
||||
--without-python \
|
||||
--without-tcl \
|
||||
--disable-nls
|
||||
gmake -j$(sysctl -n hw.ncpu) libnewt.a
|
||||
mkdir -p ${{ env.DESTDIR }}/usr/local/{lib/pkgconfig,include}
|
||||
install -m644 libnewt.pc ${{ env.DESTDIR }}/usr/local/lib/pkgconfig
|
||||
install -m644 libnewt.a ${{ env.DESTDIR }}/usr/local/lib
|
||||
install -m644 newt.h ${{ env.DESTDIR }}/usr/local/include
|
||||
cd ..
|
||||
|
||||
- name: Build libplist
|
||||
run: |
|
||||
cd libplist
|
||||
@@ -223,10 +260,9 @@ jobs:
|
||||
cd libirecovery
|
||||
autoreconf -fiv
|
||||
if [ "${{ matrix.os }}" != "macosx" ]; then
|
||||
./configure ${{ env.CONFIGURE_ARGS }} --with-iokit=no
|
||||
else
|
||||
./configure ${{ env.CONFIGURE_ARGS }}
|
||||
gsed -i '/case kIOUSBTransactionTimeout/d' src/libirecovery.c
|
||||
fi
|
||||
./configure ${{ env.CONFIGURE_ARGS }}
|
||||
echo -e 'all:\ninstall:' > tools/Makefile
|
||||
make -j$(sysctl -n hw.ncpu) LIBS="-lncurses"
|
||||
make -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
@@ -255,12 +291,22 @@ jobs:
|
||||
- name: Build palera1n
|
||||
run: |
|
||||
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
|
||||
if [ "${{ matrix.os }}" = "macosx" ]; then
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
elif [ "${{ matrix.os }}" = "iphoneos" ]; then
|
||||
gmake -j$(sysctl -n hw.ncpu) FAKE_PLATFORM=2 FAKE_SDK=14.0 FAKE_MINOS=14.0
|
||||
fi
|
||||
mv src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||
find dep_root -name '*.dylib' -delete
|
||||
find dep_root -name '*.la' -delete
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DSTATIC=1 -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_CROSSCOMPILING=true \
|
||||
-DCMAKE_SYSTEM_NAME=Darwin \
|
||||
-DCMAKE_C_COMPILER="${{ env.CC }}" \
|
||||
-DCMAKE_C_FLAGS='${{ env.CFLAGS }}' \
|
||||
-DCMAKE_FIND_ROOT_PATH="${{ env.DESTDIR }}" \
|
||||
-DCMAKE_INSTALL_PREFIX="${{ env.PREFIX }}" \
|
||||
-DSTATIC=1
|
||||
make -j$(sysctl -n hw.ncpu)
|
||||
cd ..
|
||||
mkdir -p ready
|
||||
mv build/src/palera1n palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||
dsymutil palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||
strip palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||
ldid -s palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||
@@ -268,6 +314,7 @@ jobs:
|
||||
tar -zcf ready/dep_root-${{ matrix.os }}-${{ matrix.arch }}.tgz dep_root
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: wangyucode/[email protected]
|
||||
with:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
@@ -279,19 +326,8 @@ jobs:
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
|
||||
- name: Upload artifact
|
||||
uses: wangyucode/[email protected]
|
||||
with:
|
||||
host: ${{ secrets.MINEEK_FTP_HOST }}
|
||||
port: 22
|
||||
username: mineekfiles
|
||||
password: ${{ secrets.MINEEK_FTP_PASS }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/uploads/palera1n/artifacts/palera1n-c'
|
||||
|
||||
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} build
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}
|
||||
@@ -299,6 +335,7 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
- name: Upload ${{ matrix.os }} thin ${{ matrix.arch }} debug symbols
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: palera1n-${{ matrix.os }}-${{ matrix.arch }}.dSYM
|
||||
@@ -306,6 +343,7 @@ jobs:
|
||||
retention-days: 1
|
||||
|
||||
darwin-dist:
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
runs-on: macos-latest
|
||||
needs: build-darwin
|
||||
steps:
|
||||
@@ -328,6 +366,7 @@ jobs:
|
||||
zip -r9 ready/palera1n-macos.dSYM.zip palera1n-macos.dSYM
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: wangyucode/[email protected]
|
||||
with:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
@@ -339,18 +378,6 @@ jobs:
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
|
||||
- name: Upload artifact
|
||||
uses: wangyucode/[email protected]
|
||||
with:
|
||||
host: ${{ secrets.MINEEK_FTP_HOST }}
|
||||
port: 22
|
||||
username: mineekfiles
|
||||
password: ${{ secrets.MINEEK_FTP_PASS }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/uploads/palera1n/artifacts/palera1n-c'
|
||||
|
||||
build-Linux:
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -364,7 +391,10 @@ jobs:
|
||||
MBEDTLS_VERSION: 3.3.0
|
||||
LIBUSB_VERSION: 1.0.26
|
||||
READLINE_VERSION: 8.2
|
||||
NCURSES_VERSION: 6.4
|
||||
SLANG_VERSION: 2.3.3
|
||||
NEWT_VERSION: 0.52.23
|
||||
GPM_VERSION: 1.20.7
|
||||
POPT_VERSION: 1.19
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -374,8 +404,8 @@ jobs:
|
||||
|
||||
- name: Install build dependencies (packages)
|
||||
run: |
|
||||
sudo apt remove -y libssl-dev libreadline-dev
|
||||
sudo apt install -y pkg-config autoconf automake
|
||||
sudo apt-get remove -y libssl-dev libreadline-dev
|
||||
sudo apt-get install -y pkg-config autoconf automake autopoint
|
||||
sudo pip3 install jsonschema jinja2
|
||||
|
||||
- name: Download toolchain checksum
|
||||
@@ -425,68 +455,34 @@ jobs:
|
||||
echo "CROSS_COMPILE=${{ matrix.triple }}-" >> $GITHUB_ENV
|
||||
mkdir -p $(pwd)/sysroot/usr/local/lib
|
||||
ln -sf $(pwd)/sysroot/usr/local/lib{,64}
|
||||
|
||||
- name: Download dependencies (embedded binaries)
|
||||
run: |
|
||||
make -j5 download-deps
|
||||
|
||||
- name: Download dependencies (source code)
|
||||
run: |
|
||||
curl -LOOOO \
|
||||
curl -LOOOOOOO \
|
||||
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v${{ env.MBEDTLS_VERSION }}.tar.gz \
|
||||
https://github.com/libusb/libusb/releases/download/v${{ env.LIBUSB_VERSION }}/libusb-${{ env.LIBUSB_VERSION }}.tar.bz2 \
|
||||
https://mirror-hk.koddos.net/gnu/readline/readline-${{ env.READLINE_VERSION }}.tar.gz \
|
||||
https://mirror-hk.koddos.net/gnu/ncurses/ncurses-${{ env.NCURSES_VERSION }}.tar.gz
|
||||
https://www.jedsoft.org/releases/slang/slang-${{ env.SLANG_VERSION }}.tar.bz2 \
|
||||
https://releases.pagure.org/newt/newt-${{ env.NEWT_VERSION }}.tar.gz \
|
||||
https://github.com/telmich/gpm/archive/refs/tags/${{ env.GPM_VERSION }}.tar.gz \
|
||||
https://github.com/rpm-software-management/popt/archive/refs/tags/popt-${{ env.POPT_VERSION }}-release.tar.gz
|
||||
|
||||
tar -xf v${{ env.MBEDTLS_VERSION }}.tar.gz
|
||||
tar -xjf libusb-${{ env.LIBUSB_VERSION }}.tar.bz2
|
||||
tar -xf readline-${{ env.READLINE_VERSION }}.tar.gz
|
||||
tar -xf ncurses-${{ env.NCURSES_VERSION }}.tar.gz
|
||||
tar -xjf slang-${{ env.SLANG_VERSION }}.tar.bz2
|
||||
tar -xf newt-${{ env.NEWT_VERSION }}.tar.gz
|
||||
tar -xf ${{ env.GPM_VERSION }}.tar.gz
|
||||
tar -xf popt-${{ env.POPT_VERSION }}-release.tar.gz
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libplist
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
|
||||
|
||||
- name: Build ncurses
|
||||
run: |
|
||||
cd ncurses-${{ env.NCURSES_VERSION }}
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--with-build-cc="cc" \
|
||||
--with-build-cflags=" " \
|
||||
--with-build-cpp="cc -E" \
|
||||
--with-build-cppflags=" " \
|
||||
--with-build-ldflags=" " \
|
||||
--enable-const \
|
||||
--enable-ext-colors \
|
||||
--enable-ext-mouse \
|
||||
--enable-ext-putwin \
|
||||
--enable-wattr-macros \
|
||||
--with-pthread \
|
||||
--disable-overwrite \
|
||||
--without-debug \
|
||||
--without-tests \
|
||||
--enable-sigwinch \
|
||||
--enable-const \
|
||||
--enable-symlinks \
|
||||
--enable-termcap \
|
||||
--enable-pc-files \
|
||||
--without-x11-rgb \
|
||||
--with-pkg-config-libdir="${{ env.PREFIX }}/lib/pkgconfig" \
|
||||
--includedir="${{ env.PREFIX }}/include" \
|
||||
--enable-widec \
|
||||
--with-default-terminfo-dir="/usr/share/terminfo" \
|
||||
--with-terminfo-dirs="/usr/share/terminfo:/lib/terminfo:/usr/lib/terminfo:/usr/local/share/terminfo:/usr/local/lib/terminfo:/data/data/com.termux/files/usr/share/terminfo" \
|
||||
LDFLAGS="${{ env.LDFLAGS }}" \
|
||||
PKG_CONFIG_LIBDIR="${{ env.PREFIX }}/lib/pkgconfig"
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build Mbed TLS
|
||||
run: |
|
||||
cd mbedtls-${{ env.MBEDTLS_VERSION }}
|
||||
cat ../patches/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
||||
cat ../patches/mbedtls/0001-Allow-empty-x509-cert-issuer.patch | patch -sN -d . -p1
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
@@ -522,6 +518,63 @@ jobs:
|
||||
make -j$(nproc) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build S-Lang
|
||||
run: |
|
||||
cd slang-${{ env.SLANG_VERSION }}
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--without-x \
|
||||
--without-pcre \
|
||||
--without-onig \
|
||||
--without-z \
|
||||
--without-png \
|
||||
--without-iconv
|
||||
gmake -j$(sysctl -n hw.ncpu) static
|
||||
gmake -j$(sysctl -n hw.ncpu) install-static DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build GPM
|
||||
run: |
|
||||
cd gpm-${{ env.GPM_VERSION }}
|
||||
cat ../patches/gpm/*.patch | patch -sN -d . -p1
|
||||
./autogen.sh
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }}
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build popt
|
||||
run: |
|
||||
cd popt-popt-${{ env.POPT_VERSION }}-release
|
||||
autoreconf -fiv
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--without-libiconv-prefix \
|
||||
--without-libintl-prefix \
|
||||
--disable-nls \
|
||||
--disable-werror
|
||||
gmake -j$(sysctl -n hw.ncpu)
|
||||
gmake -j$(sysctl -n hw.ncpu) install DESTDIR=${{ env.DESTDIR }}
|
||||
cd ..
|
||||
|
||||
- name: Build newt
|
||||
run: |
|
||||
cd newt-${{ env.NEWT_VERSION }}
|
||||
./configure \
|
||||
${{ env.CONFIGURE_ARGS }} \
|
||||
--with-readline=gnu \
|
||||
--without-python \
|
||||
--without-tcl \
|
||||
--disable-nls \
|
||||
--with-gpm-support
|
||||
gmake -j$(sysctl -n hw.ncpu) libnewt.a
|
||||
mkdir -p ${{ env.DESTDIR }}/usr/local/{lib/pkgconfig,include}
|
||||
install -m644 libnewt.pc ${{ env.DESTDIR }}/usr/local/lib/pkgconfig
|
||||
install -m644 libnewt.a ${{ env.DESTDIR }}/usr/local/lib
|
||||
install -m644 newt.h ${{ env.DESTDIR }}/usr/local/include
|
||||
cd ..
|
||||
|
||||
- name: Build libplist
|
||||
run: |
|
||||
cd libplist
|
||||
@@ -579,23 +632,33 @@ jobs:
|
||||
cp -a sysroot/${{ env.PREFIX }}/{include,lib} dep_root
|
||||
find dep_root -name '*.so' -delete
|
||||
find dep_root -name '*.la' -delete
|
||||
make -j$(nproc) CC="${{ matrix.triple }}-gcc" palera1n
|
||||
mkdir build
|
||||
cd build
|
||||
CC="${{ matrix.triple }}-gcc" cmake .. -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }} \
|
||||
-DCMAKE_FIND_ROOT_PATH=${{ env.DESTDIR }}${{ env.PREFIX }} \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
|
||||
-DCMAKE_C_FLAGS="-I${{ env.DESTDIR }}${{ env.PREFIX }}/include \
|
||||
-L${{ env.DESTDIR }}${{ env.PREFIX }}/lib -Wl,-rpath,${{ env.PREFIX }}/lib" -DSTATIC=1
|
||||
make -j$(nproc) CC="${{ matrix.triple }}-gcc"
|
||||
|
||||
- name: Seperate debug symbols
|
||||
run: |
|
||||
${{ matrix.triple }}-objcopy --only-keep-debug src/palera1n palera1n.debug
|
||||
${{ matrix.triple }}-strip --strip-debug --strip-unneeded src/palera1n
|
||||
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug src/palera1n
|
||||
${{ matrix.triple }}-objcopy --only-keep-debug build/src/palera1n palera1n.debug
|
||||
${{ matrix.triple }}-strip --strip-debug --strip-unneeded build/src/palera1n
|
||||
${{ matrix.triple }}-objcopy --add-gnu-debuglink=palera1n.debug build/src/palera1n
|
||||
chmod -x palera1n.debug
|
||||
|
||||
- name: Prepare artifact
|
||||
run: |
|
||||
mkdir ready
|
||||
mv palera1n.debug ready/palera1n-${{ env.CHECKRA1N_NAME }}.debug
|
||||
mv src/palera1n ready/palera1n-${{ env.CHECKRA1N_NAME }}
|
||||
mv build/src/palera1n ready/palera1n-${{ env.CHECKRA1N_NAME }}
|
||||
tar -zcf ready/dep_root_${{ matrix.triple }}.tgz dep_root
|
||||
|
||||
- name: Upload artifact
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: wangyucode/[email protected]
|
||||
with:
|
||||
host: ${{ secrets.NICKCHAN_FTP_HOST }}
|
||||
@@ -606,15 +669,3 @@ jobs:
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/palera1n/artifacts/c-rewrite'
|
||||
|
||||
- name: Upload artifact
|
||||
uses: wangyucode/[email protected]
|
||||
with:
|
||||
host: ${{ secrets.MINEEK_FTP_HOST }}
|
||||
port: 22
|
||||
username: mineekfiles
|
||||
password: ${{ secrets.MINEEK_FTP_PASS }}
|
||||
forceUpload: true
|
||||
dryRun: false
|
||||
localDir: 'ready/'
|
||||
remoteDir: '/uploads/palera1n/artifacts/palera1n-c'
|
||||
+8
-2
@@ -1,5 +1,5 @@
|
||||
dep_root/**
|
||||
contrib/**
|
||||
dep_root/**
|
||||
!dep_root/.keep
|
||||
!contrib/.keep
|
||||
contrib/
|
||||
@@ -8,9 +8,15 @@ contrib/
|
||||
checkra1n*
|
||||
payload.c
|
||||
src/palera1n
|
||||
palera1n*
|
||||
!xxd-embedded.h
|
||||
src/binpack.dmg
|
||||
src/ramdisk.dmg
|
||||
src/xxd-*.c
|
||||
.DS_Store
|
||||
!palera1n.1
|
||||
palera1n.1.html
|
||||
Payload
|
||||
docs/*.html
|
||||
build
|
||||
src/*.dmg.c
|
||||
.idea
|
||||
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
project(palera1n)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
set(CMAKE_CXX_STANDARD 99)
|
||||
set(SRC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(DEP ${SRC}/dep_root)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(STATIC 0)
|
||||
set(CMAKE_SUPPRESS_REGENERATION ON)
|
||||
|
||||
set(CMAKE_BUILD_TYPE BUILD_TYPE)
|
||||
|
||||
|
||||
add_custom_target(distclean
|
||||
COMMAND sh -c "find src -name '*.o' -type f -delete"
|
||||
COMMAND sh -c "find src -perm -u+x -type f -delete"
|
||||
)
|
||||
#add_custom_target(distclean
|
||||
# COMMAND sh -c "rm -rf *"
|
||||
# )
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(docs)
|
||||
@@ -2,15 +2,16 @@ SRC = $(shell pwd)
|
||||
DEP = $(SRC)/dep_root
|
||||
STRIP = strip
|
||||
CC ?= cc
|
||||
CFLAGS += -I$(DEP)/include -I$(DEP)/include/ncursestw -I$(SRC)/include -I$(SRC)
|
||||
CFLAGS += -I$(DEP)/include -I$(SRC)/include -I$(SRC)
|
||||
CFLAGS += -Wall -Wextra -DPALERAIN_VERSION=\"2.0.0\" -Wall -Wextra -Wno-unused-parameter
|
||||
CFLAGS += -Wno-unused-variable -I$(SRC)/src
|
||||
CFLAGS += -Wno-unused-variable -I$(SRC)/src -std=c99 -pedantic-errors -D_C99_SOURCE -D_POSIX_C_SOURCE=199506L -D_DARWIN_C_SOURCE
|
||||
LIBS += $(DEP)/lib/libimobiledevice-1.0.a $(DEP)/lib/libirecovery-1.0.a $(DEP)/lib/libusbmuxd-2.0.a
|
||||
LIBS += $(DEP)/lib/libimobiledevice-glue-1.0.a $(DEP)/lib/libplist-2.0.a -pthread
|
||||
ifeq ($(TARGET_OS),)
|
||||
TARGET_OS = $(shell uname -s)
|
||||
endif
|
||||
ifeq ($(TARGET_OS),Darwin)
|
||||
CFLAGS += -Wno-nullability-extension
|
||||
ifeq (,$(findstring version-min=, $(CFLAGS)))
|
||||
CFLAGS += -mmacosx-version-min=10.8
|
||||
endif
|
||||
@@ -21,10 +22,12 @@ CFLAGS += -fdata-sections -ffunction-sections
|
||||
LDFLAGS += -static -no-pie -Wl,--gc-sections
|
||||
endif
|
||||
LIBS += $(DEP)/lib/libmbedtls.a $(DEP)/lib/libmbedcrypto.a $(DEP)/lib/libmbedx509.a $(DEP)/lib/libreadline.a
|
||||
LIBS += $(DEP)/lib/libusb-1.0.a
|
||||
|
||||
ifeq ($(DEV_BUILD),1)
|
||||
LIBS += $(DEP)/lib/libmenutw.a $(DEP)/lib/libncursestw.a
|
||||
LIBS += $(DEP)/lib/libnewt.a $(DEP)/lib/libpopt.a $(DEP)/lib/libslang.a
|
||||
ifeq ($(TARGET_OS),Linux)
|
||||
LIBS += $(DEP)/lib/libgpm.a
|
||||
endif
|
||||
CFLAGS += -O0 -g -DDEV_BUILD -fno-omit-frame-pointer
|
||||
ifeq ($(ASAN),1)
|
||||
BUILD_STYLE=ASAN
|
||||
@@ -51,12 +54,16 @@ palera1n: download-deps
|
||||
|
||||
clean:
|
||||
$(MAKE) -C src clean
|
||||
$(MAKE) -C docs clean
|
||||
|
||||
download-deps:
|
||||
$(MAKE) -C src checkra1n-macos checkra1n-linux-arm64 checkra1n-linux-armel checkra1n-linux-x86 checkra1n-linux-x86_64 checkra1n-kpf-pongo ramdisk.dmg binpack.dmg
|
||||
|
||||
docs:
|
||||
$(MAKE) -C docs
|
||||
|
||||
distclean: clean
|
||||
rm -rf palera1n-* palera1n*.dSYM src/checkra1n-* src/checkra1n-kpf-pongo src/ramdisk.dmg src/binpack.dmg
|
||||
|
||||
.PHONY: all palera1n clean
|
||||
.PHONY: all palera1n clean docs distclean
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
add_custom_target(
|
||||
docs
|
||||
COMMAND sh -c "mandoc -T html -O style=mandoc.css palera1n.1 > palera1n.1.html"
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
PAGES = palera1n.1.html
|
||||
|
||||
all: $(PAGES)
|
||||
|
||||
%.1.html: %.1
|
||||
mandoc -T html -O style=mandoc.css palera1n.1 > palera1n.1.html
|
||||
|
||||
clean:
|
||||
rm -f $(PAGES)
|
||||
+269
@@ -0,0 +1,269 @@
|
||||
/* $OpenBSD: mandoc.css,v 1.35 2021/03/30 19:23:50 schwarze Exp $ */
|
||||
/*
|
||||
* Standard style sheet for mandoc(1) -Thtml and man.cgi(8).
|
||||
*
|
||||
* Written by Ingo Schwarze <[email protected]>.
|
||||
* I place this file into the public domain.
|
||||
* Permission to use, copy, modify, and distribute it for any purpose
|
||||
* with or without fee is hereby granted, without any conditions.
|
||||
*/
|
||||
|
||||
/* Global defaults. */
|
||||
|
||||
html {
|
||||
--bg: #FFFFFF;
|
||||
--fg: #000000; }
|
||||
body { background: var(--bg);
|
||||
color: var(--fg);
|
||||
font-family: monospace,Helvetica,Arial,sans-serif;
|
||||
max-width: 80ch;
|
||||
margin: 1em auto;
|
||||
padding: 0 1ch;
|
||||
}
|
||||
h1 { font-size: 110%; }
|
||||
table { margin-top: 0em;
|
||||
margin-bottom: 0em;
|
||||
border-collapse: collapse; }
|
||||
/* Some browsers set border-color in a browser style for tbody,
|
||||
* but not for table, resulting in inconsistent border styling. */
|
||||
tbody { border-color: inherit; }
|
||||
tr { border-color: inherit; }
|
||||
td { vertical-align: top;
|
||||
padding-left: 0.2em;
|
||||
padding-right: 0.2em;
|
||||
border-color: inherit; }
|
||||
ul, ol, dl { margin-top: 0em;
|
||||
margin-bottom: 0em; }
|
||||
li, dt { margin-top: 1em; }
|
||||
pre { font-family: inherit; }
|
||||
|
||||
.permalink { border-bottom: thin dotted;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-decoration: inherit; }
|
||||
* { clear: both }
|
||||
|
||||
/* Search form and search results. */
|
||||
|
||||
form {
|
||||
position: sticky;
|
||||
top: 0px;
|
||||
background-color: var(--bg);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
fieldset { border: thin solid silver;
|
||||
border-radius: 0.3em;
|
||||
text-align: center; }
|
||||
input[name=expr] {
|
||||
width: 25%; }
|
||||
|
||||
table.results { margin-top: 1em;
|
||||
margin-left: 2em;
|
||||
font-size: smaller; }
|
||||
|
||||
/* Header and footer lines. */
|
||||
|
||||
table.head { width: 100%;
|
||||
border-bottom: 1px dotted #808080;
|
||||
margin-bottom: 1em;
|
||||
font-size: smaller;
|
||||
overflow-wrap: anywhere; }
|
||||
td.head-vol { text-align: center; }
|
||||
td.head-rtitle {
|
||||
text-align: right; }
|
||||
|
||||
table.foot { width: 100%;
|
||||
border-top: 1px dotted #808080;
|
||||
margin-top: 1em;
|
||||
font-size: smaller;
|
||||
overflow-wrap: anywhere; }
|
||||
td.foot-os { text-align: right; }
|
||||
|
||||
table.Nm {
|
||||
overflow-wrap:anywhere;
|
||||
}
|
||||
|
||||
/* Sections and paragraphs. */
|
||||
|
||||
.manual-text {
|
||||
margin-left: 3.8em; }
|
||||
h1.Sh { margin-top: 1.2em;
|
||||
margin-bottom: 0.6em;
|
||||
margin-left: -3.2em; }
|
||||
h2.Ss { margin-top: 1.2em;
|
||||
margin-bottom: 0.6em;
|
||||
margin-left: -1.2em;
|
||||
font-size: 105%; }
|
||||
.Pp { margin: 0.6em 0em; }
|
||||
|
||||
/* Displays and lists. */
|
||||
|
||||
.Bd-indent { margin-left: 3.8em; }
|
||||
|
||||
.Bl-bullet { list-style-type: disc;
|
||||
padding-left: 1em; }
|
||||
.Bl-dash { list-style-type: none;
|
||||
padding-left: 0em; }
|
||||
.Bl-dash > li:before {
|
||||
content: "\2014 "; }
|
||||
.Bl-item { list-style-type: none;
|
||||
padding-left: 0em; }
|
||||
.Bl-compact > li {
|
||||
margin-top: 0em; }
|
||||
|
||||
.Bl-enum { padding-left: 2em; }
|
||||
.Bl-compact > li {
|
||||
margin-top: 0em; }
|
||||
|
||||
.Bl-diag > dt {
|
||||
font-style: normal;
|
||||
font-weight: bold; }
|
||||
.Bl-diag > dd {
|
||||
margin-left: 0em; }
|
||||
.Bl-hang > dd {
|
||||
margin-left: 5.5em; }
|
||||
.Bl-inset > dd {
|
||||
margin-left: 0em; }
|
||||
.Bl-ohang > dd {
|
||||
margin-left: 0em; }
|
||||
.Bl-tag { margin-top: 0.6em;
|
||||
margin-left: 5.5em; }
|
||||
.Bl-tag > dt {
|
||||
float: left;
|
||||
margin-top: 0em;
|
||||
margin-left: -5.5em;
|
||||
padding-right: 0.5em;
|
||||
vertical-align: top; }
|
||||
.Bl-tag > dd {
|
||||
clear: right;
|
||||
column-count: 1; /* Force block formatting context. */
|
||||
width: 100%;
|
||||
margin-top: 0em;
|
||||
margin-left: 0em;
|
||||
margin-bottom: 0.6em;
|
||||
vertical-align: top; }
|
||||
.Bl-compact { margin-top: 0em; }
|
||||
.Bl-compact > dd {
|
||||
margin-bottom: 0em; }
|
||||
.Bl-compact > dt {
|
||||
margin-top: 0em; }
|
||||
|
||||
.Bl-column > tbody > tr > td {
|
||||
margin-top: 1em; }
|
||||
.Bl-compact > tbody > tr > td {
|
||||
margin-top: 0em; }
|
||||
|
||||
.Rs { font-style: normal;
|
||||
font-weight: normal; }
|
||||
.RsB { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.RsI { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.RsJ { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.RsT { text-decoration: underline; }
|
||||
|
||||
.tbl td { vertical-align: middle; }
|
||||
|
||||
.HP { margin-left: 3.8em;
|
||||
text-indent: -3.8em; }
|
||||
|
||||
/* Semantic markup for command line utilities. */
|
||||
|
||||
code.Nm { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit;
|
||||
overflow-wrap: normal; }
|
||||
.Fl { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit; }
|
||||
.Cm { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit; }
|
||||
.Ar { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.Op { display: inline; }
|
||||
.Ic { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit; }
|
||||
.Ev { font-style: normal;
|
||||
font-weight: normal;
|
||||
font-family: monospace; }
|
||||
.Pa { font-style: italic;
|
||||
font-weight: normal; }
|
||||
|
||||
/* Semantic markup for function libraries. */
|
||||
|
||||
code.In { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit; }
|
||||
.Fd { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit; }
|
||||
.Ft { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.Fn { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit; }
|
||||
.Fa { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.Vt { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.Va { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.Dv { font-style: normal;
|
||||
font-weight: normal;
|
||||
font-family: monospace; }
|
||||
.Er { font-style: normal;
|
||||
font-weight: normal;
|
||||
font-family: monospace; }
|
||||
|
||||
/* Various semantic markup. */
|
||||
|
||||
.Cd { font-style: normal;
|
||||
font-weight: bold;
|
||||
font-family: inherit; }
|
||||
.Ad { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.Ms { font-style: normal;
|
||||
font-weight: bold; }
|
||||
|
||||
/* Physical markup. */
|
||||
|
||||
.Bf { display: inline; }
|
||||
.No { font-style: normal;
|
||||
font-weight: normal; }
|
||||
.Em { font-style: italic;
|
||||
font-weight: normal; }
|
||||
.Sy { font-style: normal;
|
||||
font-weight: bold; }
|
||||
.Li { font-style: normal;
|
||||
font-weight: normal;
|
||||
font-family: monospace; }
|
||||
|
||||
/* Overrides to avoid excessive margins on small devices. */
|
||||
|
||||
@media (max-width: 37.5em) {
|
||||
.manual-text {
|
||||
margin-left: 0.5em; }
|
||||
h1.Sh, h2.Ss { margin-left: 0em; }
|
||||
.Bd-indent { margin-left: 2em; }
|
||||
.Bl-hang > dd {
|
||||
margin-left: 2em; }
|
||||
.Bl-tag { margin-left: 2em; }
|
||||
.Bl-tag > dt {
|
||||
margin-left: -2em; }
|
||||
.HP { margin-left: 2em;
|
||||
text-indent: -2em; }
|
||||
}
|
||||
|
||||
/* Overrides for a dark color scheme for accessibility. */
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
html { --bg: #000000;
|
||||
--fg: #FFFFFF; }
|
||||
:link { color: #BAD7FF; }
|
||||
:visited { color: #BAD7FF; }
|
||||
}
|
||||
|
||||
+317
@@ -0,0 +1,317 @@
|
||||
.\"-
|
||||
.\" Copyright (c) 2023 Nick Chan
|
||||
.\" SPDX-License-Identifier: MIT
|
||||
.\"
|
||||
.Dd "06 February 2023"
|
||||
.Dt "Nick Chan utilities manual" 1 "palera1n"
|
||||
.Dt palera1n 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm palera1n
|
||||
.Nd iOS 15+ arm64 iOS/iPadOS jailbreaking tool
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl cCdDEfhlnLOpRsvV
|
||||
.Op Fl e Ar Boot arguments
|
||||
.Op Fl k Ar Pongo image
|
||||
.Op Fl o Ar overlay file
|
||||
.Op Fl r Ar ramdisk file
|
||||
.Op Fl K Ar KPF file
|
||||
.Op Fl i Ar checkra1n file
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
jailbreaks any iOS/iPadOS device with an arm64 (arm64e excluded) on iOS 15+,
|
||||
utilizing the
|
||||
.Em checkm8
|
||||
bootROM exploit.
|
||||
.Pp
|
||||
.Nm
|
||||
is able to jailbreak the device in fakefs-rootful mode, where /
|
||||
is writable, as well as rootless mode, where / cannot be written to.
|
||||
.Pp
|
||||
Due to the nature of the
|
||||
.Em checkm8
|
||||
exploit,
|
||||
.Nm
|
||||
is semi-tethered. That is, you must run the
|
||||
.Nm
|
||||
tool after the device reboot in order to enter the jailbroken state.
|
||||
However, it is not required for the device to boot.
|
||||
.Pp
|
||||
On A11 devices, that is, iPhone 8, iPhone 8 Plus and iPhone X, the passcode cannot
|
||||
be used.
|
||||
.Pp
|
||||
On iOS 15, the passcode must be off while jailbroken.
|
||||
.Pp
|
||||
On iOS 16, the passcode must be off since restore, and
|
||||
.Sy Reset All Contents and Settings
|
||||
from settings app counts as a restore.
|
||||
A backup may be used in this case.
|
||||
.Pp
|
||||
.Sh SUPPORTED DEVICES
|
||||
As described above, arm64 iOS/iPadOS 15+ devices are supported, here is an explicit
|
||||
list of supported devicecs:
|
||||
|
||||
.Bl -tag -compact
|
||||
.It iPhone 6s
|
||||
.It iPhone 6s Plus
|
||||
.It iPhone SE (2016)
|
||||
.It iPhone 7
|
||||
.It iPhone 7 Plus
|
||||
.It iPhone 8
|
||||
.It iPhone 8 Plus
|
||||
.It iPhone X
|
||||
.El
|
||||
|
||||
.Bl -tag -compact
|
||||
.It iPad mini 4
|
||||
.It iPad Air 2
|
||||
.It iPad (5th generation)
|
||||
.It iPad (6th generation)
|
||||
.It iPad (7th generation)
|
||||
.It iPad Pro (9.7")
|
||||
.It iPad Pro (12.9") (1st generation)
|
||||
.It iPad Pro (10.5")
|
||||
.It iPad Pro (12.9") (2nd generation)
|
||||
.El
|
||||
|
||||
.Bl -tag -compact
|
||||
.It iPod Touch (7th generation)
|
||||
.El
|
||||
|
||||
Support for other arm64 Darwin devices, including Apple TV, HomePod and iBridge
|
||||
on Darwin 21 and above could be added, but they are currently unsupported.
|
||||
|
||||
arm64e devices will NEVER be supported.
|
||||
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width -indent
|
||||
.It Fl -version
|
||||
Prints the program version and exit.
|
||||
.It Fl -force-revert
|
||||
Remove the jailbreak while keeping user data. Some jailbreak files may remain
|
||||
after running this command. Additionally, jailbreak apps will remain on the
|
||||
home screen on for a while even when the files are deleted as the icon cache
|
||||
still has their icons. When used with
|
||||
.Fl f , -fakefs ,
|
||||
this will actually boot the device in rootless mode then delete the jailbreak
|
||||
files. As a result, using the loader app to install the jailbreak environment
|
||||
is not supported when this option is used together with
|
||||
.Fl f , -fakefs
|
||||
\[char46]
|
||||
.It Fl c , -setup-fakefs
|
||||
When used with
|
||||
.Fl f , -fakefs ,
|
||||
Create the new APFS volume required for rootful. Will fail if one already exists.
|
||||
.It Fl C , -setup-fakefs-forced
|
||||
When used with
|
||||
.Fl f , -fakefs ,
|
||||
behaves like
|
||||
.Fl c , -setup-fakefs ,
|
||||
but existing fakefs, if exists, will be overwritten instead.
|
||||
.It Fl d , -demote
|
||||
Set the effective production fuse to 0, so as to enable hardware debugging features.
|
||||
.It Fl D , -dfuhelper-only
|
||||
Execute the DFU helper to guide the user into putting the device into DFU mode
|
||||
then exit.
|
||||
.It Fl e , -boot-args Ar boot arguments
|
||||
Specify custom XNU kernel command line. The
|
||||
.Em rootdev=md0
|
||||
argument is used by
|
||||
.Nm
|
||||
and cannot be overriden. Additionally, the
|
||||
.Em wdt=-1
|
||||
argument is used during fakefs setup.
|
||||
.It Fl E , -enter-recovery
|
||||
Exit after entering recovery mode.q
|
||||
.It Fl f , -fakefs
|
||||
Jailbreak in rootful mode.
|
||||
.It Fl h , -help
|
||||
Prints help text.
|
||||
.It Fl i , -checkra1n-file Ar checkra1n file
|
||||
Specify the path to a custom checkra1n file.
|
||||
.It Fl k , -override-pongo Ar pongo file
|
||||
Override PongoOS image. The raw image, named
|
||||
.Em Pongo.bin
|
||||
when built, should be used. PongoOS 2.6.0 or later is required.
|
||||
.It Fl K , -override-kpf Ar KPF file
|
||||
Override the kernel patchfinder PongoOS module. The module is required to support setting
|
||||
root filesystem in paleinfo with
|
||||
.Em rootfs
|
||||
command. If in doubt, use
|
||||
.Sy https://github.com/guacaplushy/PongoOS
|
||||
iOS15 branch or your own fork of it.
|
||||
.It Fl l , -rootless
|
||||
Jailbreak in rootless mode, this is the default when neither
|
||||
.Fl l , -rootless
|
||||
and
|
||||
.Fl f , -fakefs
|
||||
is specified.
|
||||
.Fl L , -jbinit-log-to-file
|
||||
Makes jbinit log to
|
||||
.Em /cores/jbinit.log
|
||||
This file may be viewed from sandboxed applications while jailbroken.
|
||||
.It Fl n , -exit-recovery
|
||||
Exit recovery mode and exit.
|
||||
.It Fl o , -override-overlay Ar overlay file
|
||||
Specify the path to a custom overlay file, which is then mounted onto /cores/binpack
|
||||
during boot, if the default ramdisk is used. The default ramdisk expects the overlay
|
||||
to contain a folder named
|
||||
.Em Applications
|
||||
at the root of it, as well as a dmg named
|
||||
.Em loader.dmg
|
||||
at the root of it. Otherwise, the device will not boot. It is also expected that it
|
||||
contains a shell, a ssh server, and various command line utilities.
|
||||
.It Fl O , -disable-ohio
|
||||
Disable ohio (disable analytics)
|
||||
.It Fl p , -pongo-shell
|
||||
Exit after booting into a clean PongoOS shell
|
||||
.It Fl P , -pongo-full
|
||||
Like
|
||||
.Fl p , -pongo-shell
|
||||
but default images and options have been uploaded and applied respectively.
|
||||
.It Fl r , -override-ramdisk Ar ramdisk file
|
||||
Override the ramdisk. At a very minimum, it should contain a
|
||||
.Em /sbin/launchd
|
||||
as well as a fake dyld
|
||||
.Em /usr/lib/dyld
|
||||
where the logic is expected to be in.
|
||||
.It Fl R , -reboot-device
|
||||
Reboot device in normal mode and exit.
|
||||
.It Fl s , -safe-mode
|
||||
Enter safe mode. An alert will be displayed. Jailbreak daemons nor early boot executable files
|
||||
specified (see
|
||||
.Sy FILES
|
||||
section below) will be executed. The loader app and the built in SSH server can still be used,
|
||||
as well as any jailbreak-specific apps you have installed.
|
||||
.It Fl v , -debug-logging
|
||||
Enable debug logging. The option may be repeated for extra verbosity.
|
||||
.It Fl V , -verbose-boot
|
||||
Boots the device in verbose mode, allowing boot logs to be seen.
|
||||
.El
|
||||
.Sh ENVIRONMENTAL VARIABLES
|
||||
.Bl -tag -width -indent
|
||||
.It TMPDIR
|
||||
This environmental variable should contain the a directory for temporary
|
||||
files. Without the
|
||||
.Fl i , -override-checkra1n
|
||||
option, files must be executable from it as the built-in checkra1n file
|
||||
is extracted and executed here. When not set, /tmp is used.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
To (re-)jailbreak in rootless mode:
|
||||
.Pp
|
||||
.Dl "palera1n"
|
||||
.Pp
|
||||
To setup fakefs for rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n -fc"
|
||||
.Ppq
|
||||
After the device has rebooted, follow the following example.
|
||||
.Pp
|
||||
To re-jailbreak in rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n -f"
|
||||
.Pp
|
||||
To remove the jailbreak in rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n --force-revert -f"
|
||||
.Pp
|
||||
To remove the jailbreak in rootless mode:
|
||||
.Pp
|
||||
.Dl "palera1n --force-revert"
|
||||
.Pp
|
||||
To verbose boot in rootful mode:
|
||||
.Pp
|
||||
.Dl "palera1n -Vf"
|
||||
.Pp
|
||||
To exit recovery mode:
|
||||
.Pp
|
||||
.Dl "palera1n -n"
|
||||
.Pp
|
||||
.Sh CAVEATS
|
||||
.Pp
|
||||
.Em -v
|
||||
is not a real XNU boot argument. It is intercepted by iBoot. However, since XNU
|
||||
boot arguments are set in PongoOS, which is ran after iBoot has ran, it does nothing.
|
||||
To verbose boot, use the
|
||||
.Fl V , -verbose-boot
|
||||
option when jailbreaking.
|
||||
.Pp
|
||||
Fakefs takes up around 5-10 GB of storage, and take up to 10 minutes to setup.
|
||||
.Pp
|
||||
iOS 15.0 requires DER entitlements, and iOS 15.1 requires hash agility in code signatures.
|
||||
As a result, binaries with the old code signature format need to be resigned with a recent
|
||||
version of the Procursus fork of
|
||||
.Xr ldid 1
|
||||
before they can be ran on a device jailbroken with
|
||||
.Nm
|
||||
\[char46]
|
||||
.Sh POST INSTLLATION
|
||||
The palera1n loader app will take up to 30 seconds to appear on the homescreen after the
|
||||
device has booted. If it does not appear, you can try using the shortcut:
|
||||
.Pp
|
||||
.Sy https://www.icloud.com/shortcuts/8cd5f489c8854ee0ab9ee38f2e62f87d
|
||||
.Pp
|
||||
to open it. After opening the loader app, press install to install a bootstrap as well as
|
||||
the
|
||||
.Em Sileo
|
||||
package manager.
|
||||
You can install other package managers from settings of the loader app.
|
||||
.Sh FILES
|
||||
During the jailbreak process, a temporary filesystem is mounted on /cores as a place
|
||||
to stash jailbreak files needed during the boot process. No files are ever written
|
||||
onto the actual disk if you do not use the SSH server to write files or using the
|
||||
loader app to install additional jailbreak files.
|
||||
|
||||
.Bl -tag -width "/var/jb/Library/LaunchDaemons"
|
||||
.It Pa /cores
|
||||
The location of the temporary filesystem where jailbreak files are stash during boot.
|
||||
.It Pa /cores/jbinit.log
|
||||
When
|
||||
.Fl L
|
||||
is used, the log file of jbinit.
|
||||
.It Pa /Library/LaunchDaemons
|
||||
The directory where jailbreak-specific
|
||||
.Xr launchd.plist 5
|
||||
property list files should be placed on rootful.
|
||||
.It Pa /var/jb/Library/LaunchDaemons
|
||||
The directory where jailbreak-specific
|
||||
.Xr launchd.plist 5
|
||||
property list files should be placed on rootless.
|
||||
.It Pa /etc/rc.d
|
||||
The directory where executable filse that needs to be executed during boot, before
|
||||
daemons are launched, are placed rootful. They are executed after all filesystems
|
||||
has been mounted.
|
||||
.It Pa /var/jb/etc/rc.d
|
||||
The directory where executable files that needs to be executed during boot, before
|
||||
daemons are launched, are placed on rootless. They are executed after all filesystems
|
||||
has been mounted.
|
||||
.El
|
||||
.Sh BUGS
|
||||
.Nm
|
||||
may crash if the machine it is running on:
|
||||
.Pp
|
||||
.Dl "- Has no USB ports"
|
||||
.Pp
|
||||
.Dl "- Has non-compliant USB devices plugged in"
|
||||
.Sh NOTES
|
||||
.Nm
|
||||
injects a dylib into launchd to allow the
|
||||
.Sy launchctl runstats
|
||||
command to be used on the device.
|
||||
.Sh SEE ALSO
|
||||
.Xr launchd 8
|
||||
.Xr launchd.plist 5
|
||||
.Xr ldid 1
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
jailbreak was first written by Nebula and Mineek on September 26, 2022, as a shell
|
||||
script. Tweak support with DEVELOPMENT kernels are added on October 2, 2022. RELEASE
|
||||
kernel support is added on November 14, 2022. iOS 16 Support is added on
|
||||
December 13, 2022. Later, the first attempt to rewrite palera1n into C begins on January
|
||||
01 2023. The
|
||||
.Nm
|
||||
utility described here is the second attempt, which first started on January 16, 2023,
|
||||
using checkra1n 1337 and the plush KPF.
|
||||
@@ -0,0 +1,20 @@
|
||||
curl -LOOOOOO \
|
||||
https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/v3.3.0.tar.gz \
|
||||
https://github.com/libusb/libusb/releases/download/1.0.26/libusb-1.0.26.tar.bz2 \
|
||||
https://mirror-hk.koddos.net/gnu/readline/readline-8.2.tar.gz \
|
||||
https://www.jedsoft.org/releases/slang/slang-2.3.3.tar.bz2 \
|
||||
https://releases.pagure.org/newt/newt-0.52.23.tar.gz \
|
||||
https://github.com/rpm-software-management/popt/archive/master-release.tar.gz
|
||||
|
||||
tar xf master.tar.gz
|
||||
tar xf libusb-1.0.26.tar.bz2
|
||||
tar xf readline-8.2.tar.gz
|
||||
tar xf slang-2.3.3.tar.bz2
|
||||
tar xf newt-0.52.23.tar.gz
|
||||
tar xf master-release.tar.gz
|
||||
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libplist
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice-glue
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libirecovery
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libusbmuxd
|
||||
git clone --depth=1 https://github.com/libimobiledevice/libimobiledevice
|
||||
+59
-59
@@ -8,78 +8,78 @@
|
||||
#define ANSI_COLOR_CODES_H
|
||||
|
||||
//Regular text
|
||||
#define BLK "\e[0;30m"
|
||||
#define RED "\e[0;31m"
|
||||
#define GRN "\e[0;32m"
|
||||
#define YEL "\e[0;33m"
|
||||
#define BLU "\e[0;34m"
|
||||
#define MAG "\e[0;35m"
|
||||
#define CYN "\e[0;36m"
|
||||
#define WHT "\e[0;37m"
|
||||
#define BLK "\033[0;30m"
|
||||
#define RED "\033[0;31m"
|
||||
#define GRN "\033[0;32m"
|
||||
#define YEL "\033[0;33m"
|
||||
#define BLU "\033[0;34m"
|
||||
#define MAG "\033[0;35m"
|
||||
#define CYN "\033[0;36m"
|
||||
#define WHT "\033[0;37m"
|
||||
|
||||
//Regular bold text
|
||||
#define BBLK "\e[1;30m"
|
||||
#define BRED "\e[1;31m"
|
||||
#define BGRN "\e[1;32m"
|
||||
#define BYEL "\e[1;33m"
|
||||
#define BBLU "\e[1;34m"
|
||||
#define BMAG "\e[1;35m"
|
||||
#define BCYN "\e[1;36m"
|
||||
#define BWHT "\e[1;37m"
|
||||
#define BBLK "\033[1;30m"
|
||||
#define BRED "\033[1;31m"
|
||||
#define BGRN "\033[1;32m"
|
||||
#define BYEL "\033[1;33m"
|
||||
#define BBLU "\033[1;34m"
|
||||
#define BMAG "\033[1;35m"
|
||||
#define BCYN "\033[1;36m"
|
||||
#define BWHT "\033[1;37m"
|
||||
|
||||
//Regular underline text
|
||||
#define UBLK "\e[4;30m"
|
||||
#define URED "\e[4;31m"
|
||||
#define UGRN "\e[4;32m"
|
||||
#define UYEL "\e[4;33m"
|
||||
#define UBLU "\e[4;34m"
|
||||
#define UMAG "\e[4;35m"
|
||||
#define UCYN "\e[4;36m"
|
||||
#define UWHT "\e[4;37m"
|
||||
#define UBLK "\033[4;30m"
|
||||
#define URED "\033[4;31m"
|
||||
#define UGRN "\033[4;32m"
|
||||
#define UYEL "\033[4;33m"
|
||||
#define UBLU "\033[4;34m"
|
||||
#define UMAG "\033[4;35m"
|
||||
#define UCYN "\033[4;36m"
|
||||
#define UWHT "\033[4;37m"
|
||||
|
||||
//Regular background
|
||||
#define BLKB "\e[40m"
|
||||
#define REDB "\e[41m"
|
||||
#define GRNB "\e[42m"
|
||||
#define YELB "\e[43m"
|
||||
#define BLUB "\e[44m"
|
||||
#define MAGB "\e[45m"
|
||||
#define CYNB "\e[46m"
|
||||
#define WHTB "\e[47m"
|
||||
#define BLKB "\033[40m"
|
||||
#define REDB "\033[41m"
|
||||
#define GRNB "\033[42m"
|
||||
#define YELB "\033[43m"
|
||||
#define BLUB "\033[44m"
|
||||
#define MAGB "\033[45m"
|
||||
#define CYNB "\033[46m"
|
||||
#define WHTB "\033[47m"
|
||||
|
||||
//High intensty background
|
||||
#define BLKHB "\e[0;100m"
|
||||
#define REDHB "\e[0;101m"
|
||||
#define GRNHB "\e[0;102m"
|
||||
#define YELHB "\e[0;103m"
|
||||
#define BLUHB "\e[0;104m"
|
||||
#define MAGHB "\e[0;105m"
|
||||
#define CYNHB "\e[0;106m"
|
||||
#define WHTHB "\e[0;107m"
|
||||
#define BLKHB "\033[0;100m"
|
||||
#define REDHB "\033[0;101m"
|
||||
#define GRNHB "\033[0;102m"
|
||||
#define YELHB "\033[0;103m"
|
||||
#define BLUHB "\033[0;104m"
|
||||
#define MAGHB "\033[0;105m"
|
||||
#define CYNHB "\033[0;106m"
|
||||
#define WHTHB "\033[0;107m"
|
||||
|
||||
//High intensty text
|
||||
#define HBLK "\e[0;90m"
|
||||
#define HRED "\e[0;91m"
|
||||
#define HGRN "\e[0;92m"
|
||||
#define HYEL "\e[0;93m"
|
||||
#define HBLU "\e[0;94m"
|
||||
#define HMAG "\e[0;95m"
|
||||
#define HCYN "\e[0;96m"
|
||||
#define HWHT "\e[0;97m"
|
||||
#define HBLK "\033[0;90m"
|
||||
#define HRED "\033[0;91m"
|
||||
#define HGRN "\033[0;92m"
|
||||
#define HYEL "\033[0;93m"
|
||||
#define HBLU "\033[0;94m"
|
||||
#define HMAG "\033[0;95m"
|
||||
#define HCYN "\033[0;96m"
|
||||
#define HWHT "\033[0;97m"
|
||||
|
||||
//Bold high intensity text
|
||||
#define BHBLK "\e[1;90m"
|
||||
#define BHRED "\e[1;91m"
|
||||
#define BHGRN "\e[1;92m"
|
||||
#define BHYEL "\e[1;93m"
|
||||
#define BHBLU "\e[1;94m"
|
||||
#define BHMAG "\e[1;95m"
|
||||
#define BHCYN "\e[1;96m"
|
||||
#define BHWHT "\e[1;97m"
|
||||
#define BHBLK "\033[1;90m"
|
||||
#define BHRED "\033[1;91m"
|
||||
#define BHGRN "\033[1;92m"
|
||||
#define BHYEL "\033[1;93m"
|
||||
#define BHBLU "\033[1;94m"
|
||||
#define BHMAG "\033[1;95m"
|
||||
#define BHCYN "\033[1;96m"
|
||||
#define BHWHT "\033[1;97m"
|
||||
|
||||
//Reset
|
||||
#define reset "\e[0m"
|
||||
#define CRESET "\e[0m"
|
||||
#define COLOR_RESET "\e[0m"
|
||||
#define reset "\033[0m"
|
||||
#define CRESET "\033[0m"
|
||||
#define COLOR_RESET "\033[0m"
|
||||
|
||||
#endif
|
||||
+22
-1
@@ -59,6 +59,27 @@
|
||||
#define palerain_option_setup_rootful (1 << 2) /* create fakefs */
|
||||
#define palerain_option_setup_rootful_forced (1 << 3) /* create fakefs over an existing one */
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
#define palerain_option_test1 (1 << 29)
|
||||
#define palerain_option_test2 (1 << 30)
|
||||
#endif
|
||||
|
||||
// palerain host options
|
||||
#define host_option_dfuhelper_only (1 << 0) /* dfuhelper only */
|
||||
#define host_option_pongo_exit (1 << 1) /* boot to clean pongo shell */
|
||||
#ifdef DEV_BUILD
|
||||
#define host_option_tui (1 << 2) /* use terminal user interface */
|
||||
#else
|
||||
#define host_option_res1 (1 << 2) /* reserved */
|
||||
#endif
|
||||
#define host_option_demote (1 << 3) /* Demote effective production fuse status */
|
||||
#define host_option_no_ohio (1 << 4) /* Disable Ohio (Analytics) */
|
||||
#define host_option_pongo_full (1 << 5) /* Boot to pongo with default images and options */
|
||||
#define host_option_palerain_version (1 << 6) /* Print version */
|
||||
#define host_option_exit_recovery (1 << 7) /* Exit recovery mode */
|
||||
#define host_option_reboot_device (1 << 8) /* Reboot device in normal mode */
|
||||
#define host_option_enter_recovery (1 << 9) /* Enter recovery mode */
|
||||
|
||||
#define PALEINFO_MAGIC 'PLSH'
|
||||
#define PALEINFO_CIGAM 'HSLP'
|
||||
|
||||
@@ -111,4 +132,4 @@ static inline bool checkrain_option_enabled(checkrain_option_t flags, checkrain_
|
||||
return (flags & opt) != 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,5 +1,9 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
#ifndef PALERAIN_H
|
||||
#define PALERAIN_H
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define _DARWIN_C_SOURCE 1
|
||||
#endif
|
||||
|
||||
#include "xxd-embedded.h"
|
||||
#include "kerninfo.h"
|
||||
@@ -10,16 +14,57 @@
|
||||
#include <usbmuxd.h>
|
||||
#include <libirecovery.h>
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define LOG(loglevel, ...) p1_log(loglevel, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define CLEAR() printf("\33[2K\r");
|
||||
#define palerain_option_case(x) (512 + x)
|
||||
#define palerain_option_version 129
|
||||
#define CMD_LEN_MAX 512
|
||||
#define OVERRIDE_MAGIC 0xd803b376
|
||||
|
||||
#define palerain_option_case_version palerain_option_case(0)
|
||||
#define palerain_option_case_force_revert palerain_option_case(1)
|
||||
|
||||
#ifdef USE_LIBUSB
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
#define USB_RET_SUCCESS LIBUSB_SUCCESS
|
||||
#define USB_RET_NOT_RESPONDING LIBUSB_ERROR_OTHER
|
||||
#define USB_RET_IO LIBUSB_ERROR_IO
|
||||
typedef int usb_ret_t;
|
||||
typedef libusb_device_handle *usb_device_handle_t;
|
||||
|
||||
typedef struct stuff
|
||||
{
|
||||
pthread_t th;
|
||||
libusb_device *dev;
|
||||
usb_device_handle_t handle;
|
||||
} stuff_t;
|
||||
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len);
|
||||
#else
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpedantic"
|
||||
#include <IOKit/IOKitLib.h>
|
||||
#include <IOKit/usb/IOUSBLib.h>
|
||||
#include <IOKit/IOCFPlugIn.h>
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#define USB_RET_SUCCESS KERN_SUCCESS
|
||||
#define USB_RET_NOT_RESPONDING kIOReturnNotResponding
|
||||
#define USB_RET_IO kIOReturnNotResponding
|
||||
|
||||
typedef IOReturn usb_ret_t;
|
||||
typedef IOUSBInterfaceInterface245 **usb_device_handle_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pthread_t th;
|
||||
volatile uint64_t regID;
|
||||
IOUSBDeviceInterface245 **dev;
|
||||
usb_device_handle_t handle;
|
||||
} stuff_t;
|
||||
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, uint32_t len);
|
||||
#endif
|
||||
|
||||
#ifndef PALERAIN_VERSION
|
||||
#define PALERAIN_VERSION "2.0.0"
|
||||
@@ -53,6 +98,12 @@ struct mach_header_64
|
||||
};
|
||||
#endif
|
||||
|
||||
// Keep in sync with Pongo
|
||||
#define PONGO_USB_VENDOR 0x05ac
|
||||
#define PONGO_USB_PRODUCT 0x4141
|
||||
#define CMD_LEN_MAX 512
|
||||
#define UPLOADSZ_MAX (1024 * 1024 * 128)
|
||||
|
||||
typedef enum {
|
||||
LOG_FATAL = 0,
|
||||
LOG_ERROR = 1,
|
||||
@@ -92,19 +143,17 @@ typedef struct {
|
||||
} override_file_t;
|
||||
|
||||
typedef unsigned char niarelap_file_t[];
|
||||
typedef int usb_ret_t;
|
||||
typedef libusb_device_handle *usb_device_handle_t;
|
||||
|
||||
extern unsigned int verbose;
|
||||
extern int demote;
|
||||
|
||||
extern char* pongo_path;
|
||||
|
||||
extern bool dfuhelper_only, pongo_exit;
|
||||
#ifdef DEV_BUILD
|
||||
extern bool use_tui;
|
||||
extern bool tui_started;
|
||||
#endif
|
||||
|
||||
extern checkrain_option_t host_flags;
|
||||
extern checkrain_option_p host_flags_p;
|
||||
|
||||
extern pthread_t dfuhelper_thread, pongo_thread;
|
||||
extern int pongo_thr_running, dfuhelper_thr_running;
|
||||
|
||||
@@ -117,17 +166,15 @@ extern pthread_mutex_t log_mutex;
|
||||
|
||||
extern pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
|
||||
|
||||
extern int enable_rootful, demote;
|
||||
extern int pongo_thr_running, dfuhelper_thr_running;
|
||||
extern bool ohio, pongo_full, device_has_booted;
|
||||
extern bool device_has_booted;
|
||||
extern char xargs_cmd[0x270];
|
||||
extern char checkrain_flags_cmd[0x20];
|
||||
extern char palerain_flags_cmd[0x20];
|
||||
extern char kpf_flags_cmd[0x20];
|
||||
extern char dtpatch_cmd[0x20];
|
||||
extern char rootfs_cmd[512];
|
||||
|
||||
extern bool palerain_version;
|
||||
extern char* ext_checkra1n;
|
||||
|
||||
void thr_cleanup(void* ptr);
|
||||
void* dfuhelper(void* ptr);
|
||||
@@ -146,14 +193,13 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid);
|
||||
int autoboot_cmd(const uint64_t ecid);
|
||||
int exitrecv_cmd(const uint64_t ecid);
|
||||
|
||||
void exec_checkra1n();
|
||||
int exec_checkra1n();
|
||||
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename);
|
||||
void* pongo_helper(void* ptr);
|
||||
|
||||
|
||||
extern void* pongo_usb_callback(void* arg);
|
||||
usb_ret_t USBControlTransfer(usb_device_handle_t handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t wLength, void *data, uint32_t *wLenDone);
|
||||
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len);
|
||||
const char *usb_strerror(usb_ret_t err);
|
||||
int wait_for_pongo();
|
||||
int issue_pongo_command();
|
||||
@@ -168,4 +214,16 @@ void* pongo_helper(void* _);
|
||||
bool set_found_pongo(bool val);
|
||||
uint64_t get_ecid_wait_for_dfu();
|
||||
uint64_t set_ecid_wait_for_dfu(uint64_t ecid);
|
||||
#endif
|
||||
|
||||
void write_stdout(char *buf, uint32_t len);
|
||||
void io_start(stuff_t *stuff);
|
||||
void io_stop(stuff_t *stuff);
|
||||
|
||||
void print_credits();
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
#include <newt.h>
|
||||
newtComponent get_tui_log();
|
||||
newtComponent set_tui_log(newtComponent co);
|
||||
#endif
|
||||
#endif
|
||||
+13
-9
@@ -1,8 +1,5 @@
|
||||
#ifndef TUI_H
|
||||
#define TUI_H
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -13,14 +10,16 @@
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <unistd.h>
|
||||
#include <newt.h>
|
||||
|
||||
#define MAIN_OPTIONS "Options"
|
||||
#define MAIN_START "Start"
|
||||
#define MAIN_EXIT "Exit"
|
||||
#define BACK_BUTTON "Back"
|
||||
#define WIDTH 76
|
||||
#define HEIGHT 19
|
||||
|
||||
#define MSG_COLOR 1
|
||||
#define ICON_COLOR 2
|
||||
#define PI_LOG_COLOR NEWT_COLORSET_CUSTOM(0)
|
||||
#define PI_STEP_CURRENT NEWT_COLORSET_CUSTOM(1)
|
||||
#define PI_STEP_OTHER NEWT_COLORSET_CUSTOM(2)
|
||||
|
||||
#define CHECKBOX_STATE(flags, opt) checkrain_option_enabled(flags, opt) ? '*' : ' '
|
||||
|
||||
typedef enum tui_screens {
|
||||
ERROR_SCREEN = -1,
|
||||
@@ -32,6 +31,11 @@ typedef enum tui_screens {
|
||||
ENTER_RECOVERY_SCREEN = 5
|
||||
} tui_screen_t;
|
||||
|
||||
typedef struct bitfield_checkbox_info {
|
||||
checkrain_option_p flags_p;
|
||||
checkrain_option_t opt;
|
||||
} tui_bit_info_t;
|
||||
|
||||
tui_screen_t tui_screen_main();
|
||||
tui_screen_t tui_screen_options();
|
||||
tui_screen_t tui_screen_enter_recovery();
|
||||
|
||||
@@ -13,4 +13,4 @@ extern unsigned int ramdisk_dmg_len;
|
||||
extern unsigned char binpack_dmg[];
|
||||
extern unsigned int binpack_dmg_len;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,23 @@
|
||||
Description: Add no-op option -V for compatibility
|
||||
|
||||
Index: b/src/daemon/cmdline.c
|
||||
===================================================================
|
||||
--- a/src/daemon/cmdline.c 2008-05-29 02:26:08.000000000 +0300
|
||||
+++ b/src/daemon/cmdline.c 2008-06-11 05:46:23.000000000 +0300
|
||||
@@ -32,7 +32,7 @@
|
||||
void cmdline(int argc, char **argv)
|
||||
{
|
||||
extern struct options option;
|
||||
- char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:Tuv23";
|
||||
+ char options[]="a:A::b:B:d:Dg:hi:kl:m:Mo:pr:R::s:S:t:TuvV23";
|
||||
int opt;
|
||||
|
||||
/* initialize for the dual mouse */
|
||||
@@ -81,6 +81,7 @@ void cmdline(int argc, char **argv)
|
||||
case 'u': option.autodetect = 1; break;
|
||||
case 'T': opt_test++; break;
|
||||
case 'v': printf(GPM_MESS_VERSION "\n"); exit(0);
|
||||
+ case 'V': /* Compat code */ break;
|
||||
case '2': (which_mouse->opt_three) = -1; break;
|
||||
case '3': (which_mouse->opt_three) = 1; break;
|
||||
default: exit(usage("commandline"));
|
||||
@@ -0,0 +1,39 @@
|
||||
Description: source code of gpm_has_mouse_control helper
|
||||
|
||||
Index: b/contrib/control/gpm_has_mouse_control.c
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ b/contrib/control/gpm_has_mouse_control.c 2007-12-10 08:25:45.000000000 +0200
|
||||
@@ -0,0 +1,20 @@
|
||||
+#include <sys/fcntl.h>
|
||||
+#include <sys/kd.h>
|
||||
+#include <stdio.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <sys/ioctl.h>
|
||||
+
|
||||
+int main (int argc, char **argv)
|
||||
+{
|
||||
+ int fd;
|
||||
+ int mode;
|
||||
+ fd = open ("/dev/tty0", O_RDONLY);
|
||||
+ if (fd == -1)
|
||||
+ fd = open ("/dev/vc/0", O_RDONLY);
|
||||
+ if (fd == -1)
|
||||
+ perror ("open");
|
||||
+ if (ioctl (fd, KDGETMODE, &mode) != 0)
|
||||
+ perror ("ioctl");
|
||||
+ exit(mode);
|
||||
+}
|
||||
+
|
||||
Index: b/contrib/control/Makefile
|
||||
===================================================================
|
||||
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
||||
+++ b/contrib/control/Makefile 2007-12-10 08:25:45.000000000 +0200
|
||||
@@ -0,0 +1,7 @@
|
||||
+CC := gcc
|
||||
+
|
||||
+all: gpm_has_mouse_control.c
|
||||
+ $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o gpm_has_mouse_control -Wall gpm_has_mouse_control.c
|
||||
+
|
||||
+clean:
|
||||
+ -rm -f gpm_has_mouse_control
|
||||
@@ -0,0 +1,107 @@
|
||||
Description: Use MAX_NR_CONSOLES instead of MAX_VC
|
||||
|
||||
--- a/src/daemon/gpm.c
|
||||
+++ b/src/daemon/gpm.c
|
||||
@@ -93,7 +93,7 @@
|
||||
int fifofd=-1;
|
||||
|
||||
int eventFlag=0;
|
||||
-Gpm_Cinfo *cinfo[MAX_VC+1];
|
||||
+Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1];
|
||||
|
||||
time_t last_selection_time;
|
||||
time_t opt_age_limit = 0;
|
||||
--- a/src/daemon/old_main.c
|
||||
+++ b/src/daemon/old_main.c
|
||||
@@ -141,7 +141,7 @@
|
||||
signal(SIGWINCH,gpm_killed); /* reinstall handler */
|
||||
|
||||
/* and notify clients */
|
||||
- for(i=0; i<MAX_VC+1; i++) {
|
||||
+ for(i=0; i<=MAX_NR_CONSOLES; i++) {
|
||||
Gpm_Cinfo *ci;
|
||||
for (ci = cinfo[i]; ci; ci = ci->next) kill(ci->data.pid,SIGWINCH);
|
||||
}
|
||||
@@ -214,7 +214,7 @@
|
||||
/*........................ got request */
|
||||
|
||||
/* itz 10-22-96 check _all_ clients, not just those on top! */
|
||||
- for (i=0; pending && (i<=MAX_VC); i++) {
|
||||
+ for (i=0; pending && (i<=MAX_NR_CONSOLES); i++) {
|
||||
Gpm_Cinfo* ci;
|
||||
for (ci = cinfo[i]; pending && ci; ci = ci->next) {
|
||||
if (FD_ISSET(ci->fd,&selSet)) {
|
||||
--- a/src/daemon/processconn.c
|
||||
+++ b/src/daemon/processconn.c
|
||||
@@ -67,8 +67,8 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
- if((vc = request->vc) > MAX_VC) {
|
||||
- gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_VC);
|
||||
+ if((vc = request->vc) > MAX_NR_CONSOLES) {
|
||||
+ gpm_report(GPM_PR_DEBUG, GPM_MESS_REQUEST_ON, vc, MAX_NR_CONSOLES);
|
||||
free(info);
|
||||
close(newfd);
|
||||
return -1;
|
||||
--- a/src/daemon/processrequest.c
|
||||
+++ b/src/daemon/processrequest.c
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
gpm_report(GPM_PR_INFO, GPM_MESS_CON_REQUEST, ci->fd, vc);
|
||||
|
||||
- if (vc>MAX_VC) return -1;
|
||||
+ if (vc>MAX_NR_CONSOLES) return -1;
|
||||
|
||||
/* itz 10-22-96 this shouldn't happen now */
|
||||
if (vc==-1) gpm_report(GPM_PR_OOPS, GPM_MESS_UNKNOWN_FD);
|
||||
--- a/src/headers/daemon.h
|
||||
+++ b/src/headers/daemon.h
|
||||
@@ -26,6 +26,7 @@
|
||||
*/
|
||||
#include "gpm.h" /* Gpm_Event */
|
||||
#include <sys/select.h> /* fd_set */
|
||||
+#include <linux/vt.h> /* for cinfo -- to be moved to os/linux in 2.x! */
|
||||
|
||||
/*************************************************************************
|
||||
* Types / structures
|
||||
@@ -104,13 +105,6 @@
|
||||
* Macros
|
||||
*/
|
||||
|
||||
-/* How many virtual consoles are managed? */
|
||||
-#ifndef MAX_NR_CONSOLES
|
||||
-# define MAX_NR_CONSOLES 64 /* this is always sure */
|
||||
-#endif
|
||||
-
|
||||
-#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */
|
||||
-
|
||||
/* for adding a mouse; add_mouse */
|
||||
#define GPM_ADD_DEVICE 0
|
||||
#define GPM_ADD_TYPE 1
|
||||
@@ -174,7 +168,7 @@
|
||||
extern int eventFlag;
|
||||
extern struct winsize win;
|
||||
|
||||
-extern Gpm_Cinfo *cinfo[MAX_VC+1];
|
||||
+extern Gpm_Cinfo *cinfo[MAX_NR_CONSOLES+1];
|
||||
|
||||
extern struct mouse_features mouse_table[3],
|
||||
*which_mouse; /*the current one*/
|
||||
--- a/src/headers/gpmCfg.h
|
||||
+++ b/src/headers/gpmCfg.h
|
||||
@@ -32,14 +32,6 @@
|
||||
#include <linux/tty.h>
|
||||
#endif
|
||||
|
||||
-/* FIXME: still needed ?? */
|
||||
-/* How many virtual consoles are managed? */
|
||||
-#ifndef MAX_NR_CONSOLES
|
||||
-# define MAX_NR_CONSOLES 64 /* this is always sure */
|
||||
-#endif
|
||||
-
|
||||
-#define MAX_VC MAX_NR_CONSOLES /* doesn't work before 1.3.77 */
|
||||
-
|
||||
/* How many buttons may the mouse have? */
|
||||
/* #define MAX_BUTTONS 3 ===> not used, it is hardwired :-( */
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
Description: Add AC_CANONICAL_HOST
|
||||
|
||||
--- a/configure.ac.footer
|
||||
+++ b/configure.ac.footer
|
||||
@@ -35,6 +35,8 @@
|
||||
# Find programs
|
||||
#
|
||||
|
||||
+AC_CANONICAL_HOST
|
||||
+
|
||||
AC_PROG_CC
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_INSTALL
|
||||
@@ -0,0 +1,16 @@
|
||||
Description: Fix FTBFS with -Wformat-security
|
||||
Author: Axel Beckert <[email protected]>
|
||||
Bug-Debian: https://bugs.debian.org/888792
|
||||
Bug-Debian: https://bugs.debian.org/888797
|
||||
|
||||
--- a/src/lib/report-lib.c
|
||||
+++ b/src/lib/report-lib.c
|
||||
@@ -47,7 +47,7 @@
|
||||
log_level = LOG_CRIT; break;
|
||||
}
|
||||
#ifdef HAVE_VSYSLOG
|
||||
- syslog(log_level, string);
|
||||
+ syslog(log_level, "%s", string);
|
||||
vsyslog(log_level, text, ap);
|
||||
#else
|
||||
fprintf(stderr,"%s[%s(%d)]:\n",string,file,line);
|
||||
@@ -0,0 +1,133 @@
|
||||
Description: Fix spelling errors found by lintian
|
||||
Author: Axel Beckert <[email protected]>
|
||||
|
||||
--- a/doc/FAQ
|
||||
+++ b/doc/FAQ
|
||||
@@ -132,7 +132,7 @@
|
||||
to keep hold of processor time for at least 1 second).
|
||||
- no pnp vendor will be able to support three buttons any more (no
|
||||
more mouse protocols, all mice must behave the same).
|
||||
- - similary, only 1200 baud devices (any serial device) are supported,
|
||||
+ - similarly, only 1200 baud devices (any serial device) are supported,
|
||||
because the initialization string of pnp devices only tells
|
||||
the vendor and release, with no information about required
|
||||
port configuration.
|
||||
--- a/doc/doc.gpm.in
|
||||
+++ b/doc/doc.gpm.in
|
||||
@@ -394,7 +394,7 @@
|
||||
automatically forces the @emph{repeater} (@samp{\-R}) option on.
|
||||
|
||||
@item \-o @var{list-of-extra-options}
|
||||
- The option works similary to the ``\-o'' option of mount; it is
|
||||
+ The option works similarly to the ``\-o'' option of mount; it is
|
||||
used to specify a list of ``extra options'' that are specific
|
||||
to each mouse type. The list is comma-separated. The options
|
||||
@samp{dtr}, @samp{rts} or @samp{both} are used by the serial
|
||||
--- a/src/daemon/old_main.c
|
||||
+++ b/src/daemon/old_main.c
|
||||
@@ -190,7 +190,7 @@
|
||||
/*....................................... got mouse, process event */
|
||||
/*
|
||||
* Well, actually, run a loop to maintain inlining of functions without
|
||||
- * lenghtening the file. This is not too clean a code, but it works....
|
||||
+ * lengthening the file. This is not too clean a code, but it works....
|
||||
*/
|
||||
|
||||
for (i=1; i <= 1+opt_double; i++) {
|
||||
--- a/src/mice.c
|
||||
+++ b/src/mice.c
|
||||
@@ -122,7 +122,7 @@
|
||||
break;
|
||||
}
|
||||
if (p->type == ARGV_END) { /* not found */
|
||||
- fprintf(stderr, "%s: Uknown option \"%s\" for pointer \"%s\"\n",
|
||||
+ fprintf(stderr, "%s: Unknown option \"%s\" for pointer \"%s\"\n",
|
||||
option.progname, argv[i], argv[0]);
|
||||
errors++;
|
||||
continue;
|
||||
--- a/src/prog/mouse-test.c
|
||||
+++ b/src/prog/mouse-test.c
|
||||
@@ -524,7 +524,7 @@
|
||||
Gpm_Event event;
|
||||
|
||||
if (packetsize!=cur->this->packetlen) {
|
||||
- REMOVETYPE(cur,"different packet lenght");
|
||||
+ REMOVETYPE(cur,"different packet length");
|
||||
continue;
|
||||
}
|
||||
|
||||
--- a/src/synaptics.c
|
||||
+++ b/src/synaptics.c
|
||||
@@ -2471,7 +2471,7 @@
|
||||
#define PS2_SCALE_11 0xE6 /* Set scale to 1:1 */
|
||||
|
||||
|
||||
-/* Normal ps2 responce */
|
||||
+/* Normal ps2 response */
|
||||
#define PS2_ERROR 0xFC /* Error, after a reset,resend or disconnect*/
|
||||
#define PS2_ACK 0xFA /* Command acknowledge */
|
||||
#define PS2_READY 0xAA /* Send after a calibration or ERROR */
|
||||
@@ -2538,7 +2538,7 @@
|
||||
}
|
||||
|
||||
# ifdef DEBUG_PUTBYTE_ACK
|
||||
- gpm_report(GPM_PR_DEBUG,"Responce %X to byte %X",ack,b);
|
||||
+ gpm_report(GPM_PR_DEBUG,"Response %X to byte %X",ack,b);
|
||||
# endif
|
||||
|
||||
return ack;
|
||||
@@ -2565,11 +2565,11 @@
|
||||
|
||||
/* Do some sanity checking */
|
||||
if((response[0] & 0xFC) != 0x84) {
|
||||
- gpm_report (GPM_PR_ERR,"Byte 0 of stick device responce is not valid");
|
||||
+ gpm_report (GPM_PR_ERR,"Byte 0 of stick device response is not valid");
|
||||
return -1;
|
||||
}
|
||||
if((response[3] & 0xCC) != 0xC4) {
|
||||
- gpm_report (GPM_PR_ERR,"Byte 3 of stick device responce is not valid");
|
||||
+ gpm_report (GPM_PR_ERR,"Byte 3 of stick device response is not valid");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2844,7 +2844,7 @@
|
||||
byte status,id_code = PS2_MOUSE_IDCODE;
|
||||
byte reset_cmd = PS2_RESET;
|
||||
|
||||
- gpm_report(GPM_PR_DEBUG,"Reseting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad"));
|
||||
+ gpm_report(GPM_PR_DEBUG,"Resetting Synaptic PS/2 %s\n",(stick?"Stick":"Touchpad"));
|
||||
|
||||
/* Send reset command without eating the ack. */
|
||||
if(!stick) {
|
||||
@@ -2871,11 +2871,11 @@
|
||||
usleep(750000);
|
||||
|
||||
if ( (status = syn_ps2_getbyte(fd,stick)) != PS2_READY ){
|
||||
- gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: No READY, got %02X.\n"
|
||||
+ gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: No READY, got %02X.\n"
|
||||
"Check pc_keyb.c for reconnect smartness.\n",status);
|
||||
}
|
||||
if ( (id_code = syn_ps2_getbyte(fd,stick)) != PS2_MOUSE_IDCODE){
|
||||
- gpm_report(GPM_PR_ERR,"Reseting PS/2 Device failed: Wrong ID, got %02X.\n",id_code);
|
||||
+ gpm_report(GPM_PR_ERR,"Resetting PS/2 Device failed: Wrong ID, got %02X.\n",id_code);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3155,7 +3155,7 @@
|
||||
|
||||
void syn_serial_reset(int fd)
|
||||
{
|
||||
- gpm_report (GPM_PR_INFO,"Reseting Synaptic Serial Touchpad.");
|
||||
+ gpm_report (GPM_PR_INFO,"Resetting Synaptic Serial Touchpad.");
|
||||
|
||||
syn_serial_set_mode (fd, (RELATIVE_MODE |
|
||||
HIGH_REPORT_RATE |
|
||||
@@ -3247,7 +3247,7 @@
|
||||
|
||||
void syn_ps2_reset (int fd)
|
||||
{
|
||||
- gpm_report (GPM_PR_INFO,"Reseting Synaptic PS/2 Touchpad.");
|
||||
+ gpm_report (GPM_PR_INFO,"Resetting Synaptic PS/2 Touchpad.");
|
||||
|
||||
/* Stop incoming motion data (of whatever kind absolute/relative). */
|
||||
tp_ps2_disable_data(fd);
|
||||
@@ -0,0 +1,63 @@
|
||||
Origin: http://download.nutyx.org/x86_64/rolling/cli/gpm/gpm-1.20.7-consolidated-1.patch
|
||||
Bug: https://github.com/telmich/gpm/issues/21
|
||||
Bug-Debian: https://bugs.debian.org/886903
|
||||
Bug-LFS: https://wiki.linuxfromscratch.org/blfs/ticket/9616#ticket
|
||||
Author: tnut from nutyx.org, https://github.com/tnut
|
||||
Description: Fix FTBFS with glibc 2.26
|
||||
|
||||
--- a/src/daemon/open_console.c
|
||||
+++ b/src/daemon/open_console.c
|
||||
@@ -24,6 +24,10 @@
|
||||
#include <sys/ioctl.h> /* ioctl */
|
||||
#include <sys/types.h> /* major() */
|
||||
|
||||
+#ifdef HAVE_SYS_SYSMACROS_H
|
||||
+#include <sys/sysmacros.h> /* major() w/newer glibc */
|
||||
+#endif
|
||||
+
|
||||
/* Linux specific (to be outsourced in gpm2 */
|
||||
#include <linux/serial.h> /* for serial console check */
|
||||
#include <asm/ioctls.h> /* for serial console check */
|
||||
--- a/src/prog/gpm-root.y
|
||||
+++ b/src/prog/gpm-root.y
|
||||
@@ -443,6 +443,7 @@
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------*/
|
||||
+#if 0
|
||||
static int f_debug_one(FILE *f, Draw *draw)
|
||||
{
|
||||
DrawItem *ip;
|
||||
@@ -465,6 +466,7 @@
|
||||
#undef LINE
|
||||
return 0;
|
||||
}
|
||||
+#endif
|
||||
|
||||
int f_debug(int mode, DrawItem *self, int uid)
|
||||
{
|
||||
@@ -960,10 +962,8 @@
|
||||
/*------------*/
|
||||
static inline void scr_restore(int fd, FILE *f, unsigned char *buffer, int vc)
|
||||
{
|
||||
- int x,y, dumpfd;
|
||||
+ int dumpfd;
|
||||
char dumpname[20];
|
||||
-
|
||||
- x=buffer[2]; y=buffer[3];
|
||||
|
||||
/* WILL NOT WORK WITH DEVFS! FIXME! */
|
||||
sprintf(dumpname,"/dev/vcsa%i",vc);
|
||||
@@ -1196,11 +1196,7 @@
|
||||
LOG_DAEMON : LOG_USER);
|
||||
/* reap your zombies */
|
||||
childaction.sa_handler=reap_children;
|
||||
-#if defined(__GLIBC__)
|
||||
- __sigemptyset(&childaction.sa_mask);
|
||||
-#else /* __GLIBC__ */
|
||||
- childaction.sa_mask=0;
|
||||
-#endif /* __GLIBC__ */
|
||||
+ sigemptyset(&childaction.sa_mask);
|
||||
childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */
|
||||
sigaction(SIGCHLD,&childaction,NULL);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
Description: FTBFS with gcc-10 due to -fno-commons
|
||||
Author: Sergei Trofimovich <[email protected]>
|
||||
Reviewed-By: Helmut Grohne <[email protected]>
|
||||
Origin: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8f7e2ac82fc5a1847c132057fb7de1a996d66c76
|
||||
Forwarded: https://github.com/telmich/gpm/pull/37
|
||||
Bug: https://github.com/telmich/gpm/pull/37
|
||||
Bug-Gentoo: https://bugs.gentoo.org/705878
|
||||
Bug-Debian: https://bugs.debian.org/953266
|
||||
|
||||
--- a/src/headers/daemon.h
|
||||
+++ b/src/headers/daemon.h
|
||||
@@ -176,7 +176,7 @@
|
||||
extern Gpm_Type mice[];
|
||||
extern Gpm_Type *repeated_type;
|
||||
|
||||
-time_t last_selection_time;
|
||||
+extern time_t last_selection_time;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
Description: Add musl support
|
||||
* Use SA_NODEFER instead of its non-standard alias SA_NOMASK.
|
||||
* Add missing sys/select.h and fcntl.h includes.
|
||||
* Use standard sigemptyset unconditionally.
|
||||
* Define SA_INTERRUPT if it's not defined (historical no-op).
|
||||
* With these changes gpm builds against musl libc.
|
||||
Author: Szabolcs Nagy <[email protected]>
|
||||
Bug-Debian: https://bugs.debian.org/813751
|
||||
|
||||
--- a/src/lib/liblow.c
|
||||
+++ b/src/lib/liblow.c
|
||||
@@ -179,7 +179,7 @@
|
||||
/* Reincarnation. Prepare for another death early. */
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_handler = gpm_suspend_hook;
|
||||
- sa.sa_flags = SA_NOMASK;
|
||||
+ sa.sa_flags = SA_NODEFER;
|
||||
sigaction (SIGTSTP, &sa, 0);
|
||||
|
||||
/* Pop the gpm stack by closing the useless connection */
|
||||
@@ -386,7 +386,7 @@
|
||||
|
||||
/* if signal was originally ignored, job control is not supported */
|
||||
if (gpm_saved_suspend_hook.sa_handler != SIG_IGN) {
|
||||
- sa.sa_flags = SA_NOMASK;
|
||||
+ sa.sa_flags = SA_NODEFER;
|
||||
sa.sa_handler = gpm_suspend_hook;
|
||||
sigaction(SIGTSTP, &sa, 0);
|
||||
}
|
||||
--- a/src/prog/display-buttons.c
|
||||
+++ b/src/prog/display-buttons.c
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <stdio.h> /* printf() */
|
||||
#include <time.h> /* time() */
|
||||
#include <errno.h> /* errno */
|
||||
+#include <sys/select.h> /* fd_set, FD_ZERO */
|
||||
#include <gpm.h> /* gpm information */
|
||||
|
||||
/* display resulting data */
|
||||
--- a/src/prog/display-coords.c
|
||||
+++ b/src/prog/display-coords.c
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <stdio.h> /* printf() */
|
||||
#include <time.h> /* time() */
|
||||
#include <errno.h> /* errno */
|
||||
+#include <sys/select.h> /* fd_set, FD_ZERO */
|
||||
#include <gpm.h> /* gpm information */
|
||||
|
||||
/* display resulting data */
|
||||
--- a/src/prog/gpm-root.y
|
||||
+++ b/src/prog/gpm-root.y
|
||||
@@ -1197,6 +1197,9 @@
|
||||
/* reap your zombies */
|
||||
childaction.sa_handler=reap_children;
|
||||
sigemptyset(&childaction.sa_mask);
|
||||
+#ifndef SA_INTERRUPT
|
||||
+#define SA_INTERRUPT 0
|
||||
+#endif
|
||||
childaction.sa_flags=SA_INTERRUPT; /* need to break the select() call */
|
||||
sigaction(SIGCHLD,&childaction,NULL);
|
||||
|
||||
--- a/contrib/control/gpm_has_mouse_control.c
|
||||
+++ b/contrib/control/gpm_has_mouse_control.c
|
||||
@@ -1,4 +1,4 @@
|
||||
-#include <sys/fcntl.h>
|
||||
+#include <fcntl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
File renamed without changes.
@@ -0,0 +1,344 @@
|
||||
#execute_process(COMMAND sh -c "cd ../dep_root && sh ../download_deps.sh")
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||
|
||||
|
||||
#set(SRC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
#set(DEP ${SRC}/../dep_root)
|
||||
|
||||
cmake_parse_arguments(palera1n "" "" "-arch" ${ARGN})
|
||||
|
||||
set(CHECKRA1N_VERSION 0.1337.1)
|
||||
if( ${LDID})
|
||||
set(LDID ldid)
|
||||
endif()
|
||||
if( ${LIPO})
|
||||
set(LIPO lipo)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(CHECKRA1N_FILE_NAME checkra1n-macos)
|
||||
else()
|
||||
set(CHECKRA1N_FILE_NAME checkra1n-linux-${CMAKE_SYSTEM_PROCESSOR})
|
||||
endif()
|
||||
|
||||
add_executable(palera1n
|
||||
binpack.dmg.c
|
||||
checkra1n-kpf-pongo.c
|
||||
checkra1n.c
|
||||
devhelper.c
|
||||
dfuhelper.c
|
||||
exec_checkra1n.c
|
||||
lock_vars.c
|
||||
lockdown_helper.c
|
||||
log.c
|
||||
main.c
|
||||
optparse.c
|
||||
override_file.c
|
||||
pongo_helper.c
|
||||
credits.c
|
||||
ramdisk.dmg.c
|
||||
../include/kerninfo.h
|
||||
../include/palerain.h
|
||||
../include/ANSI-color-codes.h
|
||||
../include/tui.h
|
||||
../include/xxd-embedded.h
|
||||
)
|
||||
|
||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -pedantic-errors -g)
|
||||
|
||||
# adds dev mode files
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
|
||||
list(APPEND MY_TARGET_SOURCES tui_main.c
|
||||
tui_screen_enter_dfu.c
|
||||
tui_screen_enter_recovery.c
|
||||
tui_screen_jailbreak.c
|
||||
tui_screen_main.c
|
||||
tui_screen_options.c)
|
||||
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
|
||||
|
||||
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "ASAN")
|
||||
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
|
||||
list(APPEND MY_TARGET_SOURCES tui_main.c
|
||||
tui_screen_enter_dfu.c
|
||||
tui_screen_enter_recovery.c
|
||||
tui_screen_jailbreak.c
|
||||
tui_screen_main.c
|
||||
tui_screen_options.c)
|
||||
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
|
||||
add_compile_options(-fsanitize=address,undefined -fsanitize-address-use-after-return=runtime)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "TSAN")
|
||||
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
|
||||
list(APPEND MY_TARGET_SOURCES tui_main.c
|
||||
tui_screen_enter_dfu.c
|
||||
tui_screen_enter_recovery.c
|
||||
tui_screen_jailbreak.c
|
||||
tui_screen_main.c
|
||||
tui_screen_options.c)
|
||||
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
|
||||
add_compile_options(-fsanitize=thread,undefined)
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "Release")
|
||||
endif()
|
||||
|
||||
#message("Testing for Clang/LLVM")
|
||||
#string(TOLOWER CMAKE_C_COMPILER_ID COMPILER)
|
||||
|
||||
#if(CMAKE_C_COMPILER_ID MATCHES "AppleClang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# message("Using clang/llvm! Enabling -flto=full! Please make sure clang is up to date, or else compile will fail")
|
||||
# add_compile_options(-flto=full)
|
||||
#else()
|
||||
# message("Not using clang/llvm! Using normal lto/no lto!")
|
||||
# add_compile_options(-flto)
|
||||
#endif()
|
||||
|
||||
|
||||
|
||||
#add_custom_command(TARGET palera1n
|
||||
# COMMAND sh -c "curl -LO https://assets.checkra.in/downloads/preview/${CHECKRA1N_VERSION}/${CHECKRA1N_FILE_NAME} && chmod 755 ${CHECKRA1N_FILE_NAME}"
|
||||
# )
|
||||
#
|
||||
#if(APPLE)
|
||||
# add_custom_command(TARGET palera1n
|
||||
# COMMAND sh -c "ldid -Scheckra1n.plist checkra1n"
|
||||
# )
|
||||
# add_custom_command(TARGET palera1n
|
||||
# COMMAND lipo -thin ${CMAKE_SYSTEM_PROCESSOR} -output checkra1n checkra1n-macos
|
||||
# )
|
||||
# if(CFLAGS MATCHES "version-min=")
|
||||
# add_custom_command(TARGET palera1n
|
||||
# COMMAND sh -c "vtool -remove-build-version 1 -replace -output checkra1n checkra1n && vtool -set-build-version $(FAKE_PLATFORM) $(FAKE_MINOS) $(FAKE_SDK) -replace -output checkra1n checkra1n && install_name_tool -change /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit /System/Library/Frameworks/IOKit.framework/IOKit checkra1n && install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation checkra1n && ${LDID} -Susb.xml checkra1n"
|
||||
# )
|
||||
# endif()
|
||||
#else()
|
||||
# execute_process(
|
||||
# COMMAND cp ${CHECKRA1N_FILE_NAME} ../src/checkra1n
|
||||
# )
|
||||
#endif()
|
||||
|
||||
#ifneq (,$(findstring arm64, $(CFLAGS)))
|
||||
#$(LIPO) -thin arm64 -output checkra1n checkra1n-macos
|
||||
#else ifneq (,$(findstring x86_64, $(CFLAGS)))
|
||||
#$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
|
||||
#else ifeq ($(shell arch),i386)
|
||||
#$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
|
||||
#else
|
||||
#$(LIPO) -thin $(shell arch) -output checkra1n checkra1n-
|
||||
|
||||
if(APPLE)
|
||||
if(${LIBUSB})
|
||||
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
|
||||
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
|
||||
list(APPEND MY_TARGET_SOURCES
|
||||
usb_libusb.c)
|
||||
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
|
||||
target_link_libraries(palera1n
|
||||
${DEP}/lib/libusb-1.0.a
|
||||
)
|
||||
else()
|
||||
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
|
||||
list(APPEND MY_TARGET_SOURCES
|
||||
usb_iokit.c)
|
||||
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
if(IOS AND CMAKE_C_FLAGS MATCHES "arm64")
|
||||
add_custom_command(
|
||||
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
|
||||
COMMAND lipo -thin arm64 -output checkra1n checkra1n-macos
|
||||
COMMAND sh -c "vtool -remove-build-version 1 -replace -output checkra1n checkra1n && vtool -set-build-version $(FAKE_PLATFORM) $(FAKE_MINOS) $(FAKE_SDK) -replace -output checkra1n checkra1n && install_name_tool -change /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit /System/Library/Frameworks/IOKit.framework/IOKit checkra1n && install_name_tool -change /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation checkra1n && ${LDID} -Susb.xml checkra1n"
|
||||
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
|
||||
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
|
||||
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
|
||||
COMMAND pwd
|
||||
COMMAND xxd -iC checkra1n checkra1n.c
|
||||
COMMAND xxd -iC binpack.dmg binpack.dmg.c
|
||||
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
|
||||
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
|
||||
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
|
||||
)
|
||||
elseif(CMAKE_C_FLAGS MATCHES "arm64")
|
||||
add_custom_command(
|
||||
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
|
||||
COMMAND lipo -thin arm64 -output checkra1n checkra1n-macos
|
||||
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
|
||||
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
|
||||
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
|
||||
COMMAND pwd
|
||||
COMMAND xxd -iC checkra1n checkra1n.c
|
||||
COMMAND xxd -iC binpack.dmg binpack.dmg.c
|
||||
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
|
||||
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
|
||||
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
COMMAND sh -c "curl -Lo checkra1n-macos https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
|
||||
COMMAND lipo -thin x86_64 -output checkra1n checkra1n-macos
|
||||
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
|
||||
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
|
||||
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
|
||||
COMMAND pwd
|
||||
COMMAND xxd -iC checkra1n checkra1n.c
|
||||
COMMAND xxd -iC binpack.dmg binpack.dmg.c
|
||||
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
|
||||
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
|
||||
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
add_custom_command(
|
||||
COMMAND sh -c "curl -Lo checkra1n https://assets.checkra.in/downloads/preview/0.1337.1/${CHECKRA1N_FILE_NAME} "
|
||||
COMMAND sh -c "curl -Lo binpack.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/binpack.dmg"
|
||||
COMMAND sh -c "curl -Lo ramdisk.dmg https://cdn.nickchan.lol/palera1n/c-rewrite/deps/ramdisk.dmg"
|
||||
COMMAND sh -c "curl -Lo checkra1n-kpf-pongo https://github.com/guacaplushy/checkp4le/raw/main/binaries/checkra1n-kpf-pongo"
|
||||
COMMAND pwd
|
||||
COMMAND xxd -iC checkra1n checkra1n.c
|
||||
COMMAND xxd -iC binpack.dmg binpack.dmg.c
|
||||
COMMAND xxd -iC ramdisk.dmg ramdisk.dmg.c
|
||||
COMMAND xxd -iC checkra1n-kpf-pongo checkra1n-kpf-pongo.c
|
||||
OUTPUT checkra1n.c checkra1n-kpf-pongo.c ramdisk.dmg.c binpack.dmg.c binpack.dmg ramdisk.dmg checkra1n-kpf-pongo
|
||||
)
|
||||
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
|
||||
get_property(MY_TARGET_SOURCES TARGET palera1n PROPERTY SOURCES)
|
||||
list(APPEND MY_TARGET_SOURCES
|
||||
usb_libusb.c)
|
||||
set_property(TARGET palera1n PROPERTY SOURCES ${MY_TARGET_SOURCES})
|
||||
target_link_libraries(palera1n
|
||||
${DEP}/lib/libusb-1.0.a
|
||||
)
|
||||
target_compile_definitions(palera1n PRIVATE -DUSE_LIBUSB)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
../include
|
||||
${SRC}
|
||||
)
|
||||
|
||||
|
||||
target_compile_definitions(palera1n PRIVATE -DPALERAIN_VERSION=\"2.0.0\")
|
||||
|
||||
target_include_directories(palera1n PRIVATE
|
||||
${SRC}/include
|
||||
${SRC}
|
||||
${DEP}/include
|
||||
)
|
||||
|
||||
#if(${STATIC})
|
||||
target_link_libraries(palera1n
|
||||
${DEP}/lib/libimobiledevice-1.0.a
|
||||
${DEP}/lib/libirecovery-1.0.a
|
||||
${DEP}/lib/libusbmuxd-2.0.a
|
||||
${DEP}/lib/libimobiledevice-glue-1.0.a
|
||||
${DEP}/lib/libplist-2.0.a
|
||||
${DEP}/lib/libmbedtls.a
|
||||
${DEP}/lib/libmbedcrypto.a
|
||||
${DEP}/lib/libmbedx509.a
|
||||
${DEP}/lib/libreadline.a
|
||||
)
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
if(NOT APPLE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static")
|
||||
endif()
|
||||
#else()
|
||||
# find_library(LIBIMOBILEDEVICE libimobiledevice)
|
||||
# if (NOT CORE_FOUNDATION)
|
||||
# message(FATAL_ERROR "libimobiledevice not found")
|
||||
# endif()
|
||||
# target_link_libraries(palera1n ${LIBIMOBILEDEVICE})
|
||||
#
|
||||
# find_library(LIR libirecovery)
|
||||
# if (NOT SYSCONF)
|
||||
# message(FATAL_ERROR "libirecovery not found")
|
||||
# endif()
|
||||
# target_link_libraries(palera1n ${LIR})
|
||||
#
|
||||
# find_library(USBMUXD usbmuxd)
|
||||
# if (NOT SEC)
|
||||
# message(FATAL_ERROR "usbmuxd not found")
|
||||
# endif()
|
||||
# target_link_libraries(palera1n ${USBMUXD})
|
||||
#
|
||||
# find_library(GLUE libimobiledevice-glue)
|
||||
# if (NOT IOKIT)
|
||||
# message(FATAL_ERROR "libimobiledevice-glue not found")
|
||||
# endif()
|
||||
# target_link_libraries(palera1n ${GLUE})
|
||||
#
|
||||
## target_link_libraries(palera1n
|
||||
## imobiledevice-1.0
|
||||
## irecovery-1.0
|
||||
## usbmuxd-2.0
|
||||
## imobiledevice-glue-1.0
|
||||
## plist-2.0
|
||||
## mbedtls
|
||||
## mbedcrypto
|
||||
## mbedx509
|
||||
## readline
|
||||
## usb-1.0
|
||||
## )
|
||||
#endif()
|
||||
#if(APPLE)
|
||||
# add_compile_options(palera1n
|
||||
# -framework CoreFoundation
|
||||
# -framework SystemConfiguration
|
||||
# -framework IOKit
|
||||
# -framework Security
|
||||
# )
|
||||
#endif()
|
||||
|
||||
if(APPLE)
|
||||
find_library(CORE_FOUNDATION CoreFoundation)
|
||||
if (NOT CORE_FOUNDATION)
|
||||
message(FATAL_ERROR "CoreFoundation not found")
|
||||
endif()
|
||||
target_link_libraries(palera1n ${CORE_FOUNDATION})
|
||||
|
||||
find_library(SYSCONF SystemConfiguration)
|
||||
if (NOT SYSCONF)
|
||||
message(FATAL_ERROR "SystemConfiguration not found")
|
||||
endif()
|
||||
target_link_libraries(palera1n ${SYSCONF})
|
||||
|
||||
find_library(SEC Security)
|
||||
if (NOT SEC)
|
||||
message(FATAL_ERROR "Security not found")
|
||||
endif()
|
||||
target_link_libraries(palera1n ${SEC})
|
||||
|
||||
find_library(IOKIT IOKit)
|
||||
if (NOT IOKIT)
|
||||
message(FATAL_ERROR "IOKit not found")
|
||||
endif()
|
||||
target_link_libraries(palera1n ${IOKIT})
|
||||
endif()
|
||||
add_compile_options(palera1n
|
||||
-static -no-pie -Wl,--gc-sections
|
||||
)
|
||||
|
||||
|
||||
if(!BUILD_DATE)
|
||||
execute_process(COMMAND date OUTPUT_VARIABLE BUILD_DATE)
|
||||
endif()
|
||||
if(!BUILD_TAG)
|
||||
execute_process(COMMAND git describe --dirty --tags --abbrev=7 OUTPUT_VARIABLE BUILD_TAG)
|
||||
endif()
|
||||
if(!BUILD_WHOAMI)
|
||||
execute_process(COMMAND whoami OUTPUT_VARIABLE BUILD_WHOAMI)
|
||||
endif ()
|
||||
|
||||
set(INCLUDE_DIR /usr/local/include)
|
||||
include_directories (${INCLUDE_DIR})
|
||||
|
||||
|
||||
add_compile_definitions(
|
||||
BUILD_DATE="${BUILD_DATE}"
|
||||
BUILD_TAG="${BUILD_TAG}"
|
||||
BUILD_WHOAMI="${BUILD_WHOAMI}"
|
||||
BUILD_STYLE="${CMAKE_BUILD_TYPE}"
|
||||
)
|
||||
+43
-5
@@ -1,9 +1,31 @@
|
||||
all: palera1n
|
||||
|
||||
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o exec_checkra1n.o
|
||||
OBJECTS += pongo_usb.o optparse.o override_file.o pongo_helper.o log.o
|
||||
OBJECTS += xxd-checkra1n.o xxd-checkra1n-kpf-pongo.o xxd-ramdisk.dmg.o
|
||||
OBJECTS += xxd-binpack.dmg.o lock_vars.o
|
||||
OBJECTS = main.o dfuhelper.o devhelper.o lockdown_helper.o
|
||||
OBJECTS += optparse.o override_file.o log.o lock_vars.o credits.o
|
||||
OBJECTS += fake_embedded.o exec_checkra1n.o pongo_helper.o
|
||||
|
||||
|
||||
ifneq ($(NO_RAMDISK),1)
|
||||
OBJECTS += xxd-ramdisk.dmg.o
|
||||
else
|
||||
CFLAGS += -DNO_RAMDISK
|
||||
endif
|
||||
ifneq ($(NO_KPF),1)
|
||||
OBJECTS += xxd-checkra1n-kpf-pongo.o
|
||||
else
|
||||
CFLAGS += -DNO_KPF
|
||||
endif
|
||||
ifneq ($(NO_BINPACK),1)
|
||||
OBJECTS += xxd-binpack.dmg.o
|
||||
else
|
||||
CFLAGS += -DNO_BINPACK
|
||||
endif
|
||||
ifneq ($(NO_CHECKRAIN),1)
|
||||
OBJECTS += xxd-checkra1n.o
|
||||
else
|
||||
CFLAGS += -DNO_CHECKRAIN
|
||||
endif
|
||||
|
||||
ifeq ($(DEV_BUILD),1)
|
||||
OBJECTS += tui_screen_enter_recovery.o tui_screen_enter_dfu.o tui_main.o
|
||||
OBJECTS += tui_screen_jailbreak.o tui_screen_main.o tui_screen_options.o
|
||||
@@ -13,6 +35,20 @@ CHECKRA1N_VERSION ?= 0.1337.1
|
||||
LIPO = lipo
|
||||
LDID = ldid
|
||||
|
||||
ifeq ($(TARGET_OS),Darwin)
|
||||
ifneq ($(USE_LIBUSB),1)
|
||||
OBJECTS += usb_iokit.o
|
||||
endif
|
||||
else
|
||||
USE_LIBUSB = 1
|
||||
endif
|
||||
|
||||
ifeq ($(USE_LIBUSB),1)
|
||||
OBJECTS += usb_libusb.o
|
||||
CFLAGS += -DUSE_LIBUSB=1
|
||||
LIBS += $(DEP)/lib/libusb-1.0.a
|
||||
endif
|
||||
|
||||
checkra1n-%:
|
||||
curl -LO https://assets.checkra.in/downloads/preview/$(CHECKRA1N_VERSION)/$@
|
||||
chmod 755 $@
|
||||
@@ -23,6 +59,8 @@ ifneq (,$(findstring arm64, $(CFLAGS)))
|
||||
$(LIPO) -thin arm64 -output checkra1n checkra1n-macos
|
||||
else ifneq (,$(findstring x86_64, $(CFLAGS)))
|
||||
$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
|
||||
else ifeq ($(shell arch),i386)
|
||||
$(LIPO) -thin x86_64 -output checkra1n checkra1n-macos
|
||||
else
|
||||
$(LIPO) -thin $(shell arch) -output checkra1n checkra1n-macos
|
||||
endif
|
||||
@@ -42,7 +80,7 @@ endif
|
||||
xxd-%.c: %
|
||||
xxd -iC $< > $@
|
||||
|
||||
%.o: %.c
|
||||
%.o: %.c $(wildcard ../include/*.h)
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
|
||||
palera1n: $(OBJECTS)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define EE fprintf
|
||||
#define Q }
|
||||
#define P print_credits() {
|
||||
#define BAKERAIN_DEVELOPER "dora2ios"
|
||||
#define O void
|
||||
#define Y )
|
||||
#define Z (
|
||||
#define R stdout
|
||||
#define S ,
|
||||
#define T ;
|
||||
#define A "# == palera1n-c == \n#\n"
|
||||
#define B "# Made by: Nick Chan, Tom, Mineek, Nebula, llsc12\n#\n"
|
||||
#define C "# Thanks to: " BAKERAIN_DEVELOPER ", pythonplayer, tihmstar, nikias\n"
|
||||
#define D "# (libimobiledevice), checkra1n team (Siguza, axi0mx, littlelailo\n"
|
||||
#define E "# et al.), Procursus Team (Hayden Seay, Cameron Katri, Keto et.al)\n\n"
|
||||
|
||||
O P EE Z R S A B C D E Y T Q
|
||||
+5
-5
@@ -34,7 +34,7 @@
|
||||
#include <libtvcontrol.h>
|
||||
#endif
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
|
||||
irecv_device_event_context_t irecvctx = NULL;
|
||||
|
||||
@@ -322,7 +322,7 @@ int passstat_cmd(unsigned char* status, const char* udid) {
|
||||
{
|
||||
if (passstat_status)
|
||||
free(passstat_status);
|
||||
|
||||
passstat_status = NULL;
|
||||
plist_free(node);
|
||||
LOG(LOG_ERROR, "Error getting passcode state (invalid status)");
|
||||
return -1;
|
||||
@@ -363,9 +363,9 @@ int recvinfo_cmd(recvinfo_t* info, const uint64_t ecid) {
|
||||
}
|
||||
info->mode = mode;
|
||||
info->cpid = device->chip_id;
|
||||
strncpy(info->product_type, device->product_type, 0x20);
|
||||
strncpy(info->display_name, device->display_name, 0x20);
|
||||
strncpy(info->iboot_ver, (ibootver) ? ibootver : "", 0x20);
|
||||
snprintf(info->product_type, 0x20, "%s", device->product_type);
|
||||
snprintf(info->display_name, 0x20, "%s", device->display_name);
|
||||
snprintf(info->iboot_ver, 0x20, "%s", (ibootver) ? ibootver : "");
|
||||
free(ibootver);
|
||||
irecv_close(client);
|
||||
return 0;
|
||||
|
||||
+45
-20
@@ -25,7 +25,7 @@
|
||||
#include <usbmuxd.h>
|
||||
|
||||
#include <ANSI-color-codes.h>
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
|
||||
#define FORMAT_KEY_VALUE 1
|
||||
#define FORMAT_XML 2
|
||||
@@ -36,7 +36,7 @@ int dfuhelper_thr_running = false;
|
||||
|
||||
void step(int time, int time2, char *text, bool (*cond)(uint64_t), uint64_t cond_arg) {
|
||||
for (int i = time2; i < time; i++) {
|
||||
printf(CYN "\r\e[K%s (%d)" CRESET, text, time - i + time2);
|
||||
printf(CYN "\r\033[K%s (%d)" CRESET, text, time - i + time2);
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
if (cond != NULL && cond(cond_arg)) pthread_exit(NULL);
|
||||
@@ -77,6 +77,11 @@ int connected_normal_mode(const usbmuxd_device_info_t *usbmuxd_device) {
|
||||
LOG(LOG_INFO, "Telling device with udid %s to enter recovery mode immediately", usbmuxd_device->udid);
|
||||
enter_recovery_cmd(usbmuxd_device->udid);
|
||||
devinfo_free(&dev);
|
||||
if (checkrain_option_enabled(host_flags, host_option_enter_recovery)) {
|
||||
device_has_booted = true;
|
||||
set_spin(0);
|
||||
unsubscribe_cmd();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -91,9 +96,6 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
|
||||
cpid = info->cpid;
|
||||
ecid = info->ecid;
|
||||
bdid = info->bdid;
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
pthread_setname_np("in.palera.recovery-mode-handler");
|
||||
#endif
|
||||
if (!cpid_is_arm64(info->cpid)) {
|
||||
LOG(LOG_WARNING, "Ignoring non-arm64 device...");
|
||||
return NULL;
|
||||
@@ -104,12 +106,13 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
|
||||
LOG(LOG_ERROR, "Cannot set auto-boot back to true");
|
||||
return NULL;
|
||||
}
|
||||
LOG(LOG_INFO, "Press any key when ready for DFU mode");
|
||||
LOG(LOG_INFO, "Press Enter when ready for DFU mode");
|
||||
getchar();
|
||||
step(3, 0, "Get ready", NULL, 0);
|
||||
if (NOHOME)
|
||||
step(4, 2, "Hold Volume Down + Side button", NULL, 0);
|
||||
step(4, 2, "Hold volume down + side button", NULL, 0);
|
||||
else
|
||||
step(4, 2, "Hold Home + Power Button", NULL, 0);
|
||||
step(4, 2, "Hold home + power button", NULL, 0);
|
||||
set_ecid_wait_for_dfu(info->ecid);
|
||||
ret = exitrecv_cmd(info->ecid);
|
||||
info = NULL;
|
||||
@@ -118,16 +121,16 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
|
||||
set_ecid_wait_for_dfu(0);
|
||||
return NULL;
|
||||
}
|
||||
printf("\r\e[K");
|
||||
printf("\r\033[K");
|
||||
bool nohome = NOHOME;
|
||||
if (nohome)
|
||||
step(2, 0, "Hold Volume Down + Side button", NULL, 0);
|
||||
step(2, 0, "Hold volume down + side button", NULL, 0);
|
||||
else
|
||||
step(2, 0, "Hold Home + Power Button", NULL, 0);
|
||||
step(2, 0, "Hold home + power Button", NULL, 0);
|
||||
if (nohome)
|
||||
step(10, 0, "Hold Volume Down button", conditional, ecid);
|
||||
step(10, 0, "Hold volume down button", conditional, ecid);
|
||||
else
|
||||
step(10, 0, "Hold Home button", conditional, ecid);
|
||||
step(10, 0, "Hold home button", conditional, ecid);
|
||||
if (get_ecid_wait_for_dfu() != ecid) {
|
||||
} else {
|
||||
LOG(LOG_WARNING, "Whoops, device did not enter DFU mode");
|
||||
@@ -141,16 +144,13 @@ void* connected_recovery_mode(struct irecv_device_info* info) {
|
||||
}
|
||||
|
||||
void* connected_dfu_mode(struct irecv_device_info* info) {
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
pthread_setname_np("in.palera.dfu-mode-handler");
|
||||
#endif
|
||||
if (get_ecid_wait_for_dfu() == info->ecid) {
|
||||
set_ecid_wait_for_dfu(0);
|
||||
puts("");
|
||||
LOG(LOG_INFO, "Device entered DFU mode successfully");
|
||||
}
|
||||
unsubscribe_cmd();
|
||||
set_spin(0);
|
||||
unsubscribe_cmd();
|
||||
pthread_exit(NULL);
|
||||
return NULL;
|
||||
}
|
||||
@@ -160,6 +160,16 @@ void device_event_cb(const usbmuxd_event_t *event, void* userdata) {
|
||||
switch (event->event) {
|
||||
case UE_DEVICE_ADD:
|
||||
LOG(LOG_VERBOSE, "Normal mode device connected");
|
||||
if (checkrain_option_enabled(host_flags, host_option_exit_recovery)) {
|
||||
break;
|
||||
} else if (checkrain_option_enabled(host_flags, host_option_reboot_device)) {
|
||||
reboot_cmd(event->device.udid);
|
||||
LOG(LOG_INFO, "Restarted device");
|
||||
set_spin(0);
|
||||
unsubscribe_cmd();
|
||||
pthread_exit(NULL);
|
||||
break;
|
||||
}
|
||||
connected_normal_mode(&event->device);
|
||||
break;
|
||||
case UE_DEVICE_REMOVE:
|
||||
@@ -175,9 +185,27 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
|
||||
case IRECV_DEVICE_ADD:
|
||||
if (event->mode == IRECV_K_RECOVERY_MODE_1 || event->mode == IRECV_K_RECOVERY_MODE_2 || event->mode == IRECV_K_RECOVERY_MODE_3 || event->mode == IRECV_K_RECOVERY_MODE_4) {
|
||||
LOG(LOG_VERBOSE, "Recovery mode device %ld connected", event->device_info->ecid);
|
||||
if (checkrain_option_enabled(host_flags, host_option_exit_recovery)) {
|
||||
exitrecv_cmd(event->device_info->ecid);
|
||||
LOG(LOG_INFO, "Exited recovery mode");
|
||||
device_has_booted = true;
|
||||
set_spin(0);
|
||||
unsubscribe_cmd();
|
||||
if (dfuhelper_thr_running) pthread_cancel(dfuhelper_thread);
|
||||
pthread_exit(NULL);
|
||||
break;
|
||||
}
|
||||
if (checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
|
||||
checkrain_option_enabled(host_flags, host_option_reboot_device)) return;
|
||||
pthread_create(&recovery_thread, NULL, (void* (*)(void*))connected_recovery_mode, event->device_info);
|
||||
} else if (event->mode == IRECV_K_DFU_MODE) {
|
||||
LOG(LOG_VERBOSE, "DFU mode device %ld connected", event->device_info->ecid);
|
||||
if (
|
||||
checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
|
||||
checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
|
||||
checkrain_option_enabled(host_flags, host_option_reboot_device)) {
|
||||
break;
|
||||
}
|
||||
pthread_create(&dfu_thread, NULL, (void* (*)(void*))connected_dfu_mode, event->device_info);
|
||||
}
|
||||
break;
|
||||
@@ -189,9 +217,6 @@ void irecv_device_event_cb(const irecv_device_event_t *event, void* userdata) {
|
||||
|
||||
void *dfuhelper(void* ptr) {
|
||||
dfuhelper_thr_running = true;
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
pthread_setname_np("in.palera.dfu-helper");
|
||||
#endif
|
||||
subscribe_cmd(device_event_cb, irecv_device_event_cb);
|
||||
set_spin(1);
|
||||
while (get_spin()) {
|
||||
|
||||
+25
-10
@@ -17,34 +17,45 @@
|
||||
|
||||
extern char **environ;
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <xxd-embedded.h>
|
||||
char* pongo_path = NULL;
|
||||
char* ext_checkra1n = NULL;
|
||||
|
||||
void exec_checkra1n() {
|
||||
#define tmpdir getenv("TMPDIR") == NULL ? "/tmp" : getenv("TMPDIR")
|
||||
|
||||
int exec_checkra1n() {
|
||||
LOG(LOG_INFO, "About to execute checkra1n");
|
||||
int fd, ret;
|
||||
char checkra1n_path[] = "/tmp/checkra1n.XXXXXX";
|
||||
char* checkra1n_path = NULL;
|
||||
if (ext_checkra1n != NULL) {
|
||||
checkra1n_path = ext_checkra1n;
|
||||
goto checkra1n_exec;
|
||||
}
|
||||
checkra1n_path = malloc(strlen(tmpdir) + 20);
|
||||
snprintf(checkra1n_path, strlen(tmpdir) + 20, "%s/checkra1n.XXXXXX", tmpdir);
|
||||
fd = mkstemp(checkra1n_path);
|
||||
if (fd == -1) {
|
||||
LOG(LOG_FATAL, "Cannot open temporary file: %d (%s)", errno, strerror(errno));
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
ssize_t didWrite = write(fd, checkra1n, checkra1n_len);
|
||||
if (didWrite != (ssize_t)checkra1n_len) {
|
||||
LOG(LOG_FATAL, "Size written does not match expected: %lld != %d: %d (%s)", didWrite, checkra1n_len, errno, strerror(errno));
|
||||
close(fd);
|
||||
unlink(checkra1n_path);
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
close(fd);
|
||||
ret = chmod(checkra1n_path, 0700);
|
||||
if (ret) {
|
||||
LOG(LOG_FATAL, "Cannot chmod %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||
unlink(checkra1n_path);
|
||||
return -1;
|
||||
}
|
||||
checkra1n_exec: {};
|
||||
char args[0x10] = "-pE";
|
||||
if (demote) strncat(args, "d", 0xf);
|
||||
if (checkrain_option_enabled(host_flags, host_option_demote)) strncat(args, "d", 0xf);
|
||||
if (verbose >= 2) strncat(args, "v", 0xf);
|
||||
if (pongo_path != NULL) strncat(args, "k", 0xf); // keep this at last
|
||||
pid_t pid;
|
||||
@@ -59,12 +70,16 @@ void exec_checkra1n() {
|
||||
pongo_path = NULL;
|
||||
if (ret) {
|
||||
LOG(LOG_FATAL, "Cannot posix spawn %s: %d (%s)", checkra1n_path, errno, strerror(errno));
|
||||
unlink(checkra1n_path);
|
||||
return;
|
||||
if (ext_checkra1n != NULL) unlink(checkra1n_path);
|
||||
return -1;
|
||||
}
|
||||
LOG(LOG_VERBOSE2, "%s spawned successfully", checkra1n_path);
|
||||
sleep(2);
|
||||
unlink(checkra1n_path);
|
||||
if (ext_checkra1n == NULL) {
|
||||
unlink(checkra1n_path);
|
||||
free(checkra1n_path);
|
||||
checkra1n_path = NULL;
|
||||
}
|
||||
waitpid(pid, NULL, 0);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef NO_KPF
|
||||
unsigned char* checkra1n_kpf_pongo = NULL;
|
||||
unsigned int checkra1n_kpf_pongo_len = 0;
|
||||
#endif
|
||||
|
||||
#ifdef NO_RAMDISK
|
||||
unsigned char* ramdisk_dmg = NULL;
|
||||
unsigned int ramdisk_dmg_len = 0;
|
||||
#endif
|
||||
|
||||
#ifdef NO_CHECKRAIN
|
||||
unsigned char* checkra1n = NULL;
|
||||
unsigned int checkra1n_len = 0;
|
||||
#endif
|
||||
|
||||
#ifdef NO_BINPACK
|
||||
unsigned char* binpack_dmg = NULL;
|
||||
unsigned int binpack_dmg_len = 0;
|
||||
#endif
|
||||
+23
-2
@@ -25,11 +25,16 @@
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
|
||||
#include <ANSI-color-codes.h>
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <xxd-embedded.h>
|
||||
#include <kerninfo.h>
|
||||
|
||||
pthread_mutex_t spin_mutex, found_pongo_mutex, ecid_dfu_wait_mutex;
|
||||
#ifdef DEV_BUILD
|
||||
#include <newt.h>
|
||||
pthread_mutex_t tui_log_mutex;
|
||||
newtComponent tui_log_output = NULL;
|
||||
#endif
|
||||
|
||||
bool spin, found_pongo = 0;
|
||||
uint64_t ecid_wait_for_dfu = 0;
|
||||
@@ -80,10 +85,26 @@ uint64_t get_ecid_wait_for_dfu() {
|
||||
}
|
||||
|
||||
uint64_t set_ecid_wait_for_dfu(uint64_t ecid) {
|
||||
LOG(LOG_VERBOSE5, "locking ecid wait for dfu value for set ecid_wait_for_dfu = %llu", ecid);
|
||||
LOG(LOG_VERBOSE5, "locking ecid wait for dfu mutex for set ecid_wait_for_dfu = %llu", ecid);
|
||||
pthread_mutex_lock(&ecid_dfu_wait_mutex);
|
||||
ecid_wait_for_dfu = ecid;
|
||||
LOG(LOG_VERBOSE5, "UN-locking ecid wait for dfu mutex afrer setting ecid_wait_for_dfu");
|
||||
pthread_mutex_unlock(&ecid_dfu_wait_mutex);
|
||||
return ecid;
|
||||
}
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
newtComponent get_tui_log() {
|
||||
pthread_mutex_lock(&tui_log_mutex);
|
||||
newtComponent ret = tui_log_output;
|
||||
pthread_mutex_unlock(&tui_log_mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
newtComponent set_tui_log(newtComponent co) {
|
||||
pthread_mutex_lock(&tui_log_mutex);
|
||||
tui_log_output = co;
|
||||
pthread_mutex_unlock(&tui_log_mutex);
|
||||
return co;
|
||||
}
|
||||
#endif
|
||||
@@ -205,7 +205,7 @@ int lockdown_get_string_value(int fd, const char* domain, const char* key, char*
|
||||
}
|
||||
size_t str_len = p - str_start;
|
||||
*value = (char*)malloc(str_len + 1);
|
||||
strncpy(*value, str_start, str_len);
|
||||
snprintf(*value, str_len, "%s", str_start);
|
||||
(*value)[str_len] = '\0';
|
||||
free(resp);
|
||||
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <ANSI-color-codes.h>
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
|
||||
int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxname, char *__restrict format, ...)
|
||||
{
|
||||
if (verbose >= 5) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
|
||||
if (verbose >= 5
|
||||
#ifdef DEV_BUILD
|
||||
&& !checkrain_option_enabled(host_flags, host_option_tui)
|
||||
#endif
|
||||
) fprintf(stderr, "p1_log: loglevel %d from %s:%d:%s()\n", loglevel, fname, lineno, fxname);
|
||||
int ret = 0;
|
||||
char type[0x10];
|
||||
char colour[0x10];
|
||||
@@ -18,7 +22,11 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
if (verbose < (loglevel - 3) && loglevel > LOG_INFO) {
|
||||
if (verbose >= 5) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
|
||||
if (verbose >= 5
|
||||
#ifdef DEV_BUILD
|
||||
&& !tui_started
|
||||
#endif
|
||||
) fprintf(stderr, "p1_log: hid log with high log level (%d < %d)\n", verbose, loglevel - 3);
|
||||
return 0;
|
||||
}
|
||||
switch (loglevel) {
|
||||
@@ -49,28 +57,40 @@ int p1_log(log_level_t loglevel, const char *fname, int lineno, const char *fxna
|
||||
snprintf(colour_bold, 0x10, "%s", BWHT);
|
||||
break;
|
||||
}
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
char timestring[0x80];
|
||||
time_t curtime;
|
||||
time(&curtime);
|
||||
struct tm* timeinfo = localtime(&curtime);
|
||||
snprintf(timestring, 0x80, "%s[%s%02d/%02d/%d %02d:%02d:%02d%s]", CRESET, HBLK, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, CRESET);
|
||||
if (verbose >= 2) {
|
||||
printf("%s| - %s%s <%s> " CRESET "%s" HBLU "%s" CRESET ":" BLU "%d" CRESET ":" BMAG "%s()" CRESET ": \n%s| ----> ", colour_bold, timestring, colour_bold, type, WHT, fname, lineno, fxname, colour_bold);
|
||||
} else {
|
||||
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
|
||||
}
|
||||
printf("%s", colour);
|
||||
ret = vprintf(format, args);
|
||||
va_end(args);
|
||||
#ifdef DEV_BUILD
|
||||
if (checkrain_option_enabled(host_flags, host_option_tui) && tui_started) {
|
||||
newtComponent co = get_tui_log();
|
||||
if (co == NULL) {
|
||||
return 0; /* 0 bytes printed */
|
||||
}
|
||||
char printbuf[0x200];
|
||||
ret = vsnprintf(printbuf, 0x200, format, args);
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
newtTextboxSetText(co, printbuf);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
pthread_mutex_lock(&log_mutex);
|
||||
char timestring[0x80];
|
||||
time_t curtime;
|
||||
time(&curtime);
|
||||
struct tm* timeinfo = localtime(&curtime);
|
||||
snprintf(timestring, 0x80, "%s[%s%02d/%02d/%d %02d:%02d:%02d%s]", CRESET, HBLK, timeinfo->tm_mon + 1, timeinfo->tm_mday, timeinfo->tm_year - 100, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec, CRESET);
|
||||
if (verbose >= 2) {
|
||||
printf("%s| - %s%s <%s> " CRESET "%s" HBLU "%s" CRESET ":" BLU "%d" CRESET ":" BMAG "%s()" CRESET ": \n%s| ----> ", colour_bold, timestring, colour_bold, type, WHT, fname, lineno, fxname, colour_bold);
|
||||
} else {
|
||||
printf(" - %s %s<%s>%s: ", timestring, colour_bold, type, CRESET);
|
||||
}
|
||||
printf("%s", colour);
|
||||
ret = vprintf(format, args);
|
||||
va_end(args);
|
||||
|
||||
if (verbose < 2)
|
||||
printf(CRESET "\n");
|
||||
else {
|
||||
printf("\n%s-%s\n", colour, CRESET);
|
||||
if (verbose < 2)
|
||||
printf(CRESET "\n");
|
||||
else
|
||||
printf("\n%s-%s\n", colour, CRESET);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
pthread_mutex_unlock(&log_mutex);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+23
-18
@@ -25,7 +25,7 @@
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
|
||||
#include <ANSI-color-codes.h>
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <xxd-embedded.h>
|
||||
#include <kerninfo.h>
|
||||
|
||||
@@ -33,12 +33,9 @@
|
||||
#define OVERRIDE_MAGIC 0xd803b376
|
||||
|
||||
unsigned int verbose = 0;
|
||||
int enable_rootful = 0, demote = 0;
|
||||
bool ohio = true;
|
||||
char xargs_cmd[0x270] = "xargs", checkrain_flags_cmd[0x20] = "deadbeef", palerain_flags_cmd[0x20] = "deadbeef";
|
||||
char xargs_cmd[0x270] = "xargs ", checkrain_flags_cmd[0x20] = "deadbeef", palerain_flags_cmd[0x20] = "deadbeef";
|
||||
char kpf_flags_cmd[0x20] = "deadbeef", dtpatch_cmd[0x20] = "deadbeef", rootfs_cmd[512] = "deadbeef";
|
||||
extern char** environ;
|
||||
typedef unsigned char niarelap_file_t[];
|
||||
|
||||
niarelap_file_t* kpf_to_upload_1 = &checkra1n_kpf_pongo;
|
||||
niarelap_file_t* ramdisk_to_upload_1 = &ramdisk_dmg;
|
||||
@@ -61,49 +58,51 @@ void thr_cleanup(void* ptr) {
|
||||
|
||||
int build_checks() {
|
||||
#if defined(__APPLE__)
|
||||
#ifndef NO_CHECKRAIN
|
||||
struct mach_header_64* c1_header = (struct mach_header_64*)&checkra1n[0];
|
||||
if (c1_header->magic != MH_MAGIC_64 && c1_header->magic != MH_CIGAM_64) {
|
||||
LOG(LOG_FATAL, "Broken build: checkra1n is not a thin Mach-O");
|
||||
return -1;
|
||||
}
|
||||
if (c1_header->cputype != _mh_execute_header.cputype) {
|
||||
LOG(LOG_FATAL, "Broken build: checkra1n CPU type is not the same as %s CPU type", getprogname());
|
||||
LOG(LOG_FATAL, "Broken build: checkra1n CPU type does not match palera1n CPU type");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifndef NO_KPF
|
||||
struct mach_header_64 *kpf_hdr = (struct mach_header_64 *)checkra1n_kpf_pongo;
|
||||
if (kpf_hdr->magic != MH_MAGIC_64 && kpf_hdr->magic != MH_CIGAM_64) {
|
||||
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not thin 64-bit Mach-O");
|
||||
return -1;
|
||||
} else if (kpf_hdr->filetype != MH_KEXT_BUNDLE) {
|
||||
} else
|
||||
if (kpf_hdr->filetype != MH_KEXT_BUNDLE) {
|
||||
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: Not a kext bundle");
|
||||
return -1;
|
||||
} else if (kpf_hdr->cputype != CPU_TYPE_ARM64) {
|
||||
LOG(LOG_FATAL, "Broken build: Invalid kernel patchfinder: CPU type is not arm64");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool dfuhelper_only = false, pongo_exit = false, palerain_version = false;
|
||||
#ifdef DEV_BUILD
|
||||
bool use_tui = false;
|
||||
bool tui_started = false;
|
||||
#endif
|
||||
|
||||
int palera1n(int argc, char *argv[]) {
|
||||
int ret = 0;
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
pthread_setname_np("in.palera.main-thread");
|
||||
#endif
|
||||
pthread_mutex_init(&log_mutex, NULL);
|
||||
pthread_mutex_init(&spin_mutex, NULL);
|
||||
pthread_mutex_init(&found_pongo_mutex, NULL);
|
||||
pthread_mutex_init(&ecid_dfu_wait_mutex, NULL);
|
||||
if ((ret = build_checks())) return ret;
|
||||
print_credits();
|
||||
if ((ret = optparse(argc, argv))) goto cleanup;
|
||||
if (palerain_version) goto normal_exit;
|
||||
if (checkrain_option_enabled(host_flags, host_option_palerain_version)) goto normal_exit;
|
||||
#ifdef DEV_BUILD
|
||||
if (use_tui) {
|
||||
if (checkrain_option_enabled(host_flags, host_option_tui)) {
|
||||
ret = tui();
|
||||
if (ret) goto cleanup;
|
||||
else goto normal_exit;
|
||||
@@ -114,10 +113,15 @@ int palera1n(int argc, char *argv[]) {
|
||||
pthread_create(&dfuhelper_thread, NULL, dfuhelper, NULL);
|
||||
pthread_join(dfuhelper_thread, NULL);
|
||||
set_spin(0);
|
||||
if (dfuhelper_only || device_has_booted)
|
||||
if (checkrain_option_enabled(host_flags, host_option_dfuhelper_only) ||
|
||||
checkrain_option_enabled(host_flags, host_option_reboot_device) ||
|
||||
checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
|
||||
checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
|
||||
device_has_booted)
|
||||
goto normal_exit;
|
||||
exec_checkra1n();
|
||||
if (pongo_exit || demote)
|
||||
if (exec_checkra1n()) goto cleanup;
|
||||
|
||||
if (checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_demote))
|
||||
goto normal_exit;
|
||||
set_spin(1);
|
||||
sleep(2);
|
||||
@@ -128,7 +132,7 @@ int palera1n(int argc, char *argv[]) {
|
||||
sleep(1);
|
||||
}
|
||||
normal_exit:
|
||||
if (access("/usr/bin/curl", F_OK) == 0 && ohio) {
|
||||
if (access("/usr/bin/curl", F_OK) == 0 && !checkrain_option_enabled(host_flags, host_option_no_ohio)) {
|
||||
LOG(LOG_VERBOSE4, "Ohio");
|
||||
char* ohio_argv[] = {
|
||||
"/usr/bin/curl",
|
||||
@@ -162,6 +166,7 @@ cleanup:
|
||||
munmap(override_overlay.ptr, (size_t)override_overlay.len);
|
||||
close(override_overlay.fd);
|
||||
}
|
||||
if (ext_checkra1n != NULL) free(ext_checkra1n);
|
||||
pthread_mutex_destroy(&log_mutex);
|
||||
pthread_mutex_destroy(&spin_mutex);
|
||||
pthread_mutex_destroy(&found_pongo_mutex);
|
||||
|
||||
+106
-39
@@ -10,8 +10,10 @@
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <errno.h>
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
|
||||
checkrain_option_t host_flags = 0;
|
||||
checkrain_option_p host_flags_p = &host_flags;
|
||||
|
||||
static struct option longopts[] = {
|
||||
{"setup-fakefs", no_argument, NULL, 'c'},
|
||||
@@ -27,15 +29,21 @@ static struct option longopts[] = {
|
||||
{"rootless", no_argument, NULL, 'l'},
|
||||
{"jbinit-log-to-file", no_argument, NULL, 'L'},
|
||||
{"demote", no_argument, NULL, 'd'},
|
||||
{"force-revert", no_argument, NULL, checkrain_option_force_revert},
|
||||
{"force-revert", no_argument, NULL, palerain_option_case_force_revert},
|
||||
{"safe-mode", no_argument, NULL, 's'},
|
||||
{"version", no_argument, NULL, palerain_option_version},
|
||||
{"version", no_argument, NULL, palerain_option_case_version},
|
||||
{"override-pongo", required_argument, NULL, 'k'},
|
||||
{"override-overlay", required_argument, NULL, 'o'},
|
||||
{"override-ramdisk", required_argument, NULL, 'r'},
|
||||
{"override-kpf", required_argument, NULL, 'K'},
|
||||
{"disable-ohio", no_argument, NULL, 'O'},
|
||||
{"override-checkra1n", required_argument, NULL, 'i'},
|
||||
{"reboot-device", no_argument, NULL, 'R'},
|
||||
{"exit-recovery", no_argument, NULL, 'n'},
|
||||
{"enter-recovery", no_argument, NULL, 'E'},
|
||||
#ifdef DEV_BUILD
|
||||
{"test1", no_argument, NULL, '1'},
|
||||
{"test2", no_argument, NULL, '2'},
|
||||
{"tui", no_argument, NULL, 't'},
|
||||
#endif
|
||||
{NULL, 0, NULL, 0}
|
||||
@@ -45,38 +53,49 @@ static int usage(int e, char* prog_name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
#ifdef DEV_BUILD
|
||||
"Usage: %s [-cCDhpvVldsOLtf]"
|
||||
"Usage: %s [-12cCdDEfhlLnOpRstvV]"
|
||||
#else
|
||||
"Usage: %s [-cCDhpvVldsOLf]"
|
||||
"Usage: %s [-cCdDEfhlLnOpRsvV]"
|
||||
#endif
|
||||
" [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file]\n"
|
||||
" [-e boot arguments] [-k Pongo image] [-o overlay file] [-r ramdisk file] [-K KPF file] [-i checkra1n file]\n"
|
||||
"Copyright (C) 2023, palera1n team, All Rights Reserved.\n\n"
|
||||
"iOS/iPadOS 15+ arm64 jailbreaking tool\n\n"
|
||||
"\t--version\t\t\t\tPrint version\n"
|
||||
"\t--force-revert\t\t\t\tRemove jailbreak\n"
|
||||
#ifdef DEV_BUILD
|
||||
"\t-1, --test1\t\t\t\tSet palerain_option_test1\n"
|
||||
"\t-2, --test2\t\t\t\tSet palerain_option_test2\n"
|
||||
#endif
|
||||
"\t-c, --setup-fakefs\t\t\tSetup fakefs\n"
|
||||
"\t-C, --setup-fakefs-forced\t\tSetup fakefs and overwrite any existing ones\n"
|
||||
"\t-d, --demote\t\t\t\tDemote\n"
|
||||
"\t-D, --dfuhelper-only\t\t\tExit after entering DFU\n"
|
||||
"\t-e, --boot-args <boot arguments>\tXNU boot arguments\n"
|
||||
"\t-E, --enter-recovery\t\t\tEnter recovery mode\n"
|
||||
"\t-f, --fakefs \t\t\t\tBoots fakefs\n"
|
||||
"\t-h, --help\t\t\t\tShow this help\n"
|
||||
"\t-i, --override-checkra1n <file>\t\tOverride checkra1n\n"
|
||||
"\t-k, --override-pongo <file>\t\tOverride Pongo image\n"
|
||||
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
|
||||
"\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n"
|
||||
"\t-L, --jbinit-log-to-file\t\tMake jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)\n"
|
||||
"\t-n, --exit-recovery\t\t\tExit recovery mode\n"
|
||||
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
|
||||
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
|
||||
"\t-p, --pongo-shell\t\t\tBoots to PongoOS shell\n"
|
||||
"\t-P, --pongo-full\t\t\tBoots to a PongoOS shell with default images already uploaded\n"
|
||||
"\t-r, --override-ramdisk <file>\t\tOverride ramdisk\n"
|
||||
"\t-R, --reboot-device\t\t\tReboot connected device in normal mode\n"
|
||||
"\t-s, --safe-mode\t\t\t\tEnter safe mode\n"
|
||||
"\t-v, --debug-logging\t\t\tEnable debug logging\n"
|
||||
"\t\tThis option can be repeated for extra verbosity.\n"
|
||||
"\t-V, --verbose-boot\t\t\tVerbose boot\n"
|
||||
"\t-L, --jbinit-log-to-file\t\tMake jbinit log to /cores/jbinit.log (can be read from sandbox while jailbroken)\n"
|
||||
"\t-e, --boot-args <boot arguments>\tXNU boot arguments\n"
|
||||
"\t-f, --fakefs \t\t\t\tBoots fakefs\n"
|
||||
"\t-l, --rootless\t\t\t\tBoots rootless. This is the default\n"
|
||||
"\t-s, --safe-mode\t\t\t\tEnter safe mode\n"
|
||||
"\t-d, --demote\t\t\t\tDemote\n"
|
||||
"\t-k, --override-pongo <file>\t\tOverride Pongo image\n"
|
||||
"\t-o, --override-overlay <file>\t\tOverride overlay\n"
|
||||
"\t-r, --override-ramdisk <file>\t\tOverride ramdisk\n"
|
||||
"\t-K, --override-kpf <file>\t\tOverride kernel patchfinder\n"
|
||||
"\t-O, --disable-ohio\t\t\tDisable Ohio\n"
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
"\t-t, --tui\t\t\t\tTerminal user interface\n"
|
||||
#endif
|
||||
"\nEnvironmental variables:\n"
|
||||
"\tTMPDIR\t\ttemporary diretory (path the built-in checkra1n will be extracted to)\n"
|
||||
,
|
||||
prog_name);
|
||||
exit(e);
|
||||
@@ -87,9 +106,9 @@ int optparse(int argc, char* argv[]) {
|
||||
int index;
|
||||
while ((opt = getopt_long(argc, argv,
|
||||
#ifdef DEV_BUILD
|
||||
"cCDhpvVldsOLtfPe:o:r:K:k:",
|
||||
"12cCDEhpvVldsOLftRnPe:o:r:K:k:i:",
|
||||
#else
|
||||
"cCDhpvVldsOLfPe:o:r:K:k:",
|
||||
"cCDEhpvVldsOLfRnPe:o:r:K:k:i:",
|
||||
#endif
|
||||
longopts, NULL)) != -1)
|
||||
{
|
||||
@@ -104,13 +123,13 @@ int optparse(int argc, char* argv[]) {
|
||||
kpf_flags |= checkrain_option_verbose_boot;
|
||||
break;
|
||||
case 'p':
|
||||
pongo_exit = true;
|
||||
host_flags |= host_option_pongo_exit;
|
||||
break;
|
||||
case 'P':
|
||||
pongo_full = 1;
|
||||
host_flags |= host_option_pongo_full;
|
||||
break;
|
||||
case 'D':
|
||||
dfuhelper_only = true;
|
||||
host_flags |= host_option_dfuhelper_only;
|
||||
break;
|
||||
case 'h':
|
||||
usage(0, argv[0]);
|
||||
@@ -134,16 +153,19 @@ int optparse(int argc, char* argv[]) {
|
||||
case 'f':
|
||||
snprintf(rootfs_cmd, sizeof(rootfs_cmd), "rootfs %s", optarg);
|
||||
snprintf(dtpatch_cmd, 0x20, "dtpatch %s", optarg);
|
||||
enable_rootful = 1;
|
||||
palerain_flags |= palerain_option_rootful;
|
||||
break;
|
||||
case 'l':
|
||||
enable_rootful = 0;
|
||||
palerain_flags &= ~palerain_option_rootful;
|
||||
break;
|
||||
case 'L':
|
||||
palerain_flags |= palerain_option_jbinit_log_to_file;
|
||||
break;
|
||||
case 'd':
|
||||
demote = 1;
|
||||
host_flags |= host_option_demote;
|
||||
break;
|
||||
case 'E':
|
||||
host_flags |= host_option_enter_recovery;
|
||||
break;
|
||||
case 's':
|
||||
checkrain_flags |= checkrain_option_safemode;
|
||||
@@ -179,34 +201,54 @@ int optparse(int argc, char* argv[]) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 'i': {};
|
||||
struct stat st;
|
||||
if (stat(optarg, &st) != 0) {
|
||||
LOG(LOG_FATAL, "cannot stat external checkra1n file: %d (%s)", errno, strerror(errno));
|
||||
return -1;
|
||||
} else if (!(st.st_mode & S_IXUSR) && !(st.st_mode & S_IXGRP) && !(st.st_mode & S_IXOTH)) {
|
||||
LOG(LOG_FATAL, "%s is not executable", optarg);
|
||||
return -1;
|
||||
};
|
||||
ext_checkra1n = calloc(1, strlen(optarg) + 1);
|
||||
snprintf(ext_checkra1n, strlen(optarg) + 1, "%s", optarg);
|
||||
break;
|
||||
case 'R':
|
||||
host_flags |= host_option_reboot_device;
|
||||
break;
|
||||
case 'n':
|
||||
host_flags |= host_option_exit_recovery;
|
||||
break;
|
||||
case 'O':
|
||||
ohio = false;
|
||||
host_flags |= host_option_no_ohio;
|
||||
break;
|
||||
#ifdef DEV_BUILD
|
||||
case 't':
|
||||
use_tui = true;
|
||||
host_flags |= host_option_tui;
|
||||
break;
|
||||
case '1':
|
||||
palerain_flags |= palerain_option_test1;
|
||||
break;
|
||||
case '2':
|
||||
palerain_flags |= palerain_option_test2;
|
||||
break;
|
||||
#endif
|
||||
case checkrain_option_force_revert:
|
||||
case palerain_option_case_force_revert:
|
||||
checkrain_flags |= checkrain_option_force_revert;
|
||||
break;
|
||||
case palerain_option_version:
|
||||
palerain_version = true;
|
||||
case palerain_option_case_version:
|
||||
host_flags |= host_option_palerain_version;
|
||||
break;
|
||||
default:
|
||||
usage(1, argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (palerain_version) {
|
||||
if (checkrain_option_enabled(host_flags, host_option_palerain_version)) {
|
||||
printf("palera1n version " PALERAIN_VERSION ": " BUILD_DATE "; " BUILD_WHOAMI ":" BUILD_TAG "/" BUILD_STYLE "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (enable_rootful) {
|
||||
palerain_flags |= palerain_option_rootful;
|
||||
}
|
||||
|
||||
if (checkrain_option_enabled(checkrain_flags, checkrain_option_force_revert) && checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
|
||||
LOG(LOG_WARNING, "force revert and setup rootful requested at the same time, behaviour here is undefined");
|
||||
}
|
||||
@@ -217,6 +259,7 @@ int optparse(int argc, char* argv[]) {
|
||||
LOG(LOG_VERBOSE3, "checkrain_flags: %s", checkrain_flags_cmd);
|
||||
LOG(LOG_VERBOSE3, "palerain_flags: %s", palerain_flags_cmd);
|
||||
LOG(LOG_VERBOSE3, "kpf_flags: %s", kpf_flags_cmd);
|
||||
LOG(LOG_VERBOSE3, "host_flags: 0x%x", host_flags);
|
||||
if (override_kpf.magic == OVERRIDE_MAGIC) {
|
||||
LOG(LOG_VERBOSE4, "kpf override length %u -> %u", override_kpf.orig_len, checkra1n_kpf_pongo_len);
|
||||
LOG(LOG_VERBOSE4, "kpf override ptr %p -> %p", override_kpf.orig_ptr, **kpf_to_upload);
|
||||
@@ -236,6 +279,30 @@ int optparse(int argc, char* argv[]) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!(
|
||||
checkrain_option_enabled(host_flags, host_option_dfuhelper_only) ||
|
||||
checkrain_option_enabled(host_flags, host_option_enter_recovery) ||
|
||||
checkrain_option_enabled(host_flags, host_option_exit_recovery) ||
|
||||
checkrain_option_enabled(host_flags, host_option_reboot_device)))
|
||||
{
|
||||
#ifdef NO_CHECKRAIN
|
||||
if (checkra1n_len == 0 && ext_checkra1n == NULL)
|
||||
{
|
||||
LOG(LOG_FATAL, "checkra1n omitted in build but no override specified");
|
||||
return -1;
|
||||
}
|
||||
if (!(checkrain_option_enabled(host_flags, host_option_pongo_exit) || checkrain_option_enabled(host_flags, host_option_pongo_exit)))
|
||||
{
|
||||
#ifdef NO_KPF
|
||||
if (checkra1n_kpf_pongo_len == 0)
|
||||
{
|
||||
LOG(LOG_FATAL, "kernel patchfinder omitted in build but no override specified");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
for (index = optind; index < argc; index++)
|
||||
{
|
||||
@@ -252,17 +319,17 @@ int optparse(int argc, char* argv[]) {
|
||||
usage(1, argv[0]);
|
||||
}
|
||||
}
|
||||
if (verbose >= 2) putenv("LIBUSB_DEBUG=1");
|
||||
if (verbose >= 2) setenv("LIBUSB_DEBUG", "1", 1);
|
||||
if (verbose >= 3)
|
||||
{
|
||||
irecv_set_debug_level(1);
|
||||
putenv("LIBUSB_DEBUG=2");
|
||||
setenv("LIBUSB_DEBUG", "2", 1);
|
||||
}
|
||||
if (verbose >= 4) {
|
||||
idevice_set_debug_level(1);
|
||||
putenv("LIBUSB_DEBUG=3");
|
||||
setenv("LIBUSB_DEBUG", "3", 1);
|
||||
}
|
||||
if (verbose >= 5)
|
||||
putenv("LIBUSB_DEBUG=4");
|
||||
setenv("LIBUSB_DEBUG", "4", 1);
|
||||
return 0;
|
||||
}
|
||||
+4
-3
@@ -1,3 +1,5 @@
|
||||
#include <palerain.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -12,7 +14,6 @@
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <common.h>
|
||||
|
||||
int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *orig_len, char *filename) {
|
||||
int ret = 0;
|
||||
@@ -30,7 +31,7 @@ int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *
|
||||
return errno;
|
||||
}
|
||||
LOG(LOG_VERBOSE5, "override_file: fstat fd %d succeeded!", fd);
|
||||
void *addr = mmap(NULL, st.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);
|
||||
void *addr = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
LOG(LOG_ERROR, "Failed to map file %s: %d (%s)", filename, errno, strerror(errno));
|
||||
return errno;
|
||||
@@ -46,4 +47,4 @@ int override_file(override_file_t *finfo, niarelap_file_t** orig, unsigned int *
|
||||
*orig_len = (unsigned int)st.st_size;
|
||||
LOG(LOG_VERBOSE5, "override_file() finished!");
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
+141
-16
@@ -10,17 +10,16 @@
|
||||
#include <sys/mman.h> // mmap, munmap
|
||||
#include <sys/stat.h> // fstst
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
|
||||
bool pongo_full, device_has_booted = 0;
|
||||
bool device_has_booted = 0;
|
||||
int pongo_thr_running = 0;
|
||||
|
||||
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
|
||||
|
||||
void* pongo_helper(void* ptr) {
|
||||
pongo_thr_running = 1;
|
||||
pthread_cleanup_push(thr_cleanup, &pongo_thr_running);
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
pthread_setname_np("in.palera.pongo-helper");
|
||||
#endif
|
||||
wait_for_pongo();
|
||||
while (get_spin()) {
|
||||
sleep(1);
|
||||
@@ -33,10 +32,6 @@ void *pongo_usb_callback(void *arg) {
|
||||
if (get_found_pongo())
|
||||
return NULL;
|
||||
set_found_pongo(1);
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
pthread_setname_np("in.palera.pongo-handler");
|
||||
#endif
|
||||
strncat(xargs_cmd, " rootdev=md0", 0x270 - strlen(xargs_cmd) - 1);
|
||||
if (checkrain_option_enabled(palerain_flags, palerain_option_setup_rootful)) {
|
||||
strncat(xargs_cmd, " wdt=-1", 0x270 - strlen(xargs_cmd) - 1);
|
||||
}
|
||||
@@ -50,16 +45,27 @@ void *pongo_usb_callback(void *arg) {
|
||||
issue_pongo_command(handle, kpf_flags_cmd);
|
||||
issue_pongo_command(handle, checkrain_flags_cmd);
|
||||
issue_pongo_command(handle, palerain_flags_cmd);
|
||||
if (enable_rootful)
|
||||
if (checkrain_option_enabled(palerain_flags, palerain_option_rootful))
|
||||
{
|
||||
issue_pongo_command(handle, "rootfs");
|
||||
}
|
||||
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len);
|
||||
issue_pongo_command(handle, "ramdisk");
|
||||
upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);
|
||||
issue_pongo_command(handle, "overlay");
|
||||
#ifdef NO_RAMDISK
|
||||
if (ramdisk_dmg_len != 0)
|
||||
#endif
|
||||
{
|
||||
strncat(xargs_cmd, " rootdev=md0", 0x270 - strlen(xargs_cmd) - 1);
|
||||
upload_pongo_file(handle, **ramdisk_to_upload, ramdisk_dmg_len);
|
||||
issue_pongo_command(handle, "ramdisk");
|
||||
}
|
||||
#ifdef NO_BINPACK
|
||||
if (binpack_dmg_len != 0)
|
||||
#endif
|
||||
{
|
||||
upload_pongo_file(handle, **overlay_to_upload, binpack_dmg_len);
|
||||
issue_pongo_command(handle, "overlay");
|
||||
}
|
||||
issue_pongo_command(handle, xargs_cmd);
|
||||
if (pongo_full) goto done;
|
||||
if (checkrain_option_enabled(host_flags, host_option_pongo_full)) goto done;
|
||||
issue_pongo_command(handle, "bootx");
|
||||
LOG(LOG_INFO, "Booting Kernel...");
|
||||
if (dfuhelper_thr_running) {
|
||||
@@ -70,4 +76,123 @@ done:
|
||||
device_has_booted = true;
|
||||
set_spin(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int issue_pongo_command(usb_device_handle_t handle, char *command)
|
||||
{
|
||||
uint32_t outpos = 0;
|
||||
uint32_t outlen = 0;
|
||||
int ret = USB_RET_SUCCESS;
|
||||
uint8_t in_progress = 1;
|
||||
if (command == NULL) goto fetch_output;
|
||||
size_t len = strlen(command);
|
||||
char command_buf[512];
|
||||
char stdout_buf[0x2000];
|
||||
if (len > (CMD_LEN_MAX - 2))
|
||||
{
|
||||
LOG(LOG_ERROR, "Pongo command %s too long (max %d)", command, CMD_LEN_MAX - 2);
|
||||
return EINVAL;
|
||||
}
|
||||
if (verbose < 3 || verbose > 4) {
|
||||
LOG(LOG_VERBOSE, "Executing PongoOS command: '%s'", command);
|
||||
} else {
|
||||
printf("%s\n", command);
|
||||
}
|
||||
snprintf(command_buf, 512, "%s\n", command);
|
||||
len = strlen(command_buf);
|
||||
ret = USBControlTransfer(handle, 0x21, 4, 1, 0, 0, NULL, NULL);
|
||||
if (ret)
|
||||
goto bad;
|
||||
ret = USBControlTransfer(handle, 0x21, 3, 0, 0, (uint32_t)len, command_buf, NULL);
|
||||
fetch_output:
|
||||
while (in_progress) {
|
||||
ret = USBControlTransfer(handle, 0xa1, 2, 0, 0, (uint32_t)sizeof(in_progress), &in_progress, NULL);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
ret = USBControlTransfer(handle, 0xa1, 1, 0, 0, 0x1000, stdout_buf + outpos, &outlen);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
write_stdout(stdout_buf + outpos, outlen);
|
||||
outpos += outlen;
|
||||
if (outpos > 0x1000)
|
||||
{
|
||||
memmove(stdout_buf, stdout_buf + outpos - 0x1000, 0x1000);
|
||||
outpos = 0x1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret != USB_RET_SUCCESS)
|
||||
{
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
bad:
|
||||
if (ret != USB_RET_SUCCESS)
|
||||
{
|
||||
if (ret == USB_RET_NOT_RESPONDING)
|
||||
return 0;
|
||||
if (command != NULL && (!strncmp("boot", command, 4) && ret == USB_RET_IO))
|
||||
return 0;
|
||||
LOG(LOG_ERROR, "USB error: %s", usb_strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned int buf_len)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = USBControlTransfer(handle, 0x21, 1, 0, 0, 4, &buf_len, NULL);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
ret = USBBulkUpload(handle, buf, buf_len);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void io_start(stuff_t *stuff)
|
||||
{
|
||||
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, &stuff->handle);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_create: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
}
|
||||
pthread_join(stuff->th, NULL);
|
||||
}
|
||||
|
||||
void io_stop(stuff_t *stuff)
|
||||
{
|
||||
int r = pthread_cancel(stuff->th);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_cancel: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
}
|
||||
r = pthread_join(stuff->th, NULL);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_join: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
}
|
||||
}
|
||||
|
||||
void write_stdout(char *buf, uint32_t len)
|
||||
{
|
||||
while(len > 0) {
|
||||
if (verbose >= 3) {
|
||||
ssize_t s = write(1, buf, len);
|
||||
if(s < 0) {
|
||||
LOG(LOG_ERROR, "write: %s", strerror(errno));
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
buf += s;
|
||||
len -= s;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
+66
-56
@@ -1,8 +1,3 @@
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <form.h>
|
||||
#include <menu.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -14,78 +9,93 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
int redraw_screen() {
|
||||
erase();
|
||||
resizeterm(24, 80);
|
||||
box(stdscr, 0, 0);
|
||||
mvaddstr(0, 80 - strlen("[palera1n version " PALERAIN_VERSION "]") - 2 , "[palera1n version " PALERAIN_VERSION "]");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int destroy_window() {
|
||||
endwin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int init_window() {
|
||||
setlocale(LC_ALL, NULL);
|
||||
initscr();
|
||||
if (has_colors() == TRUE) {
|
||||
start_color();
|
||||
init_pair(MSG_COLOR, COLOR_YELLOW, COLOR_BLACK);
|
||||
init_pair(ICON_COLOR, COLOR_WHITE, COLOR_BLACK);
|
||||
}
|
||||
int height, width;
|
||||
getmaxyx(stdscr, height, width);
|
||||
if (width < 80 || height < 24) {
|
||||
LOG(LOG_ERROR, "Terminal size must be at least 80x24");
|
||||
setenv(
|
||||
"NEWT_COLORS",
|
||||
"root=,black\n"
|
||||
"border=lightgray,black\n"
|
||||
"title=lightgray,black\n"
|
||||
"roottext=red,black\n"
|
||||
"label=lightgray,black\n"
|
||||
"entry=lightgray,black\n"
|
||||
"window=red,black\n"
|
||||
"textbox=lightgray,black\n"
|
||||
"button=black,lightgray\n"
|
||||
"compactbutton=lightgray,black\n"
|
||||
"listbox=lightgray,black\n"
|
||||
"actlistbox=black,lightgray\n"
|
||||
"actsellistbox=black,lightgray\n"
|
||||
"checkbox=lightgray,black\n"
|
||||
"actcheckbox=black,lightgray\n",
|
||||
0);
|
||||
|
||||
tui_started = true;
|
||||
newtInit();
|
||||
int cols, rows;
|
||||
newtGetScreenSize(&cols, &rows);
|
||||
if (cols < 80 || rows < 24) {
|
||||
newtFinished();
|
||||
tui_started = false;
|
||||
LOG(LOG_FATAL, "Terminal size must be at least 80x24");
|
||||
return -1;
|
||||
}
|
||||
if (has_colors() == FALSE) {
|
||||
LOG(LOG_VERBOSE2, "Terminal without color support detected");
|
||||
}
|
||||
cbreak();
|
||||
noecho();
|
||||
keypad(stdscr, TRUE);
|
||||
LOG(LOG_VERBOSE3, "cols: %d, rows: %d\n", cols, rows);
|
||||
newtCls();
|
||||
newtSetColor(PI_LOG_COLOR, "yellow", "black");
|
||||
newtSetColor(PI_STEP_CURRENT, "lightgray", "black");
|
||||
newtSetColor(PI_STEP_OTHER, "gray", "black");
|
||||
newtDrawRootText(0, 0, "palera1n version 2.0.0");
|
||||
newtPushHelpLine(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int tui() {
|
||||
int ret = MAIN_SCREEN;
|
||||
init_window();
|
||||
int ret = 0;
|
||||
if ((ret = init_window())) return ret;
|
||||
ret = MAIN_SCREEN;
|
||||
while (1) {
|
||||
redraw_screen();
|
||||
switch (ret) {
|
||||
case ERROR_SCREEN:
|
||||
goto out;
|
||||
break;
|
||||
case EXIT_SCREEN:
|
||||
goto out;
|
||||
break;
|
||||
case MAIN_SCREEN:
|
||||
ret = tui_screen_main();
|
||||
break;
|
||||
case OPTIONS_SCREEN:
|
||||
ret = tui_screen_options();
|
||||
break;
|
||||
case ENTER_RECOVERY_SCREEN:
|
||||
ret = tui_screen_enter_recovery();
|
||||
break;
|
||||
case ENTER_DFU_SCREEN:
|
||||
ret = tui_screen_enter_dfu();
|
||||
break;
|
||||
case JAILBREAKING_SCREEN:
|
||||
ret = tui_screen_jailbreak();
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
goto out;
|
||||
case ERROR_SCREEN:
|
||||
goto out;
|
||||
break;
|
||||
case EXIT_SCREEN:
|
||||
goto out;
|
||||
break;
|
||||
case MAIN_SCREEN:
|
||||
ret = tui_screen_main();
|
||||
break;
|
||||
case OPTIONS_SCREEN:
|
||||
ret = tui_screen_options();
|
||||
break;
|
||||
case ENTER_RECOVERY_SCREEN:
|
||||
ret = tui_screen_enter_recovery();
|
||||
break;
|
||||
case ENTER_DFU_SCREEN:
|
||||
ret = tui_screen_enter_dfu();
|
||||
break;
|
||||
case JAILBREAKING_SCREEN:
|
||||
ret = tui_screen_jailbreak();
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
goto out;
|
||||
}
|
||||
newtPopWindow();
|
||||
}
|
||||
out:
|
||||
destroy_window();
|
||||
return ret;
|
||||
newtFinished();
|
||||
tui_started = false;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,8 +1,3 @@
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <form.h>
|
||||
#include <menu.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -14,7 +9,7 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_enter_dfu() { return JAILBREAKING_SCREEN; }
|
||||
@@ -1,8 +1,3 @@
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <form.h>
|
||||
#include <menu.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -14,7 +9,7 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_enter_recovery() { return ENTER_DFU_SCREEN; }
|
||||
@@ -1,8 +1,3 @@
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <form.h>
|
||||
#include <menu.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -14,7 +9,7 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_jailbreak() { return EXIT_SCREEN; }
|
||||
+30
-93
@@ -1,8 +1,3 @@
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <form.h>
|
||||
#include <menu.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -14,97 +9,39 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
tui_screen_t tui_screen_main() {
|
||||
int ret = -1;
|
||||
mvaddstr(1, 2, "Welcome to palera1n!");
|
||||
move(2,1);
|
||||
whline(stdscr, ACS_HLINE, 80 - 2);
|
||||
move(5,2);
|
||||
attron(COLOR_PAIR(MSG_COLOR));
|
||||
mvaddstr(4,2, "Connect your iPhone, iPad, or iPod Touch");
|
||||
mvaddstr(5,2, "to begin.");
|
||||
attroff(COLOR_PAIR(MSG_COLOR));
|
||||
attron(COLOR_PAIR(ICON_COLOR));
|
||||
mvaddwstr(2, 43, L" MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM ");
|
||||
mvaddwstr(3, 44, L"MMMMMMMMMMMMMWNOddONWMMMMMMMMMMMMM");
|
||||
mvaddwstr(4, 44, L"MMMMMMMMMMMMWNx. .xNWMMMMMMMMMMMM");
|
||||
mvaddwstr(5, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM");
|
||||
mvaddwstr(6, 44, L"MMMMMMMMMMMMW0;....;OWMMMMMMMMMMMM");
|
||||
mvaddwstr(7, 44, L"MMMMMMMMMMMWXo'.....lKWMMMMMMMMMMM");
|
||||
mvaddwstr(8, 44, L"MMMMMMMMMMWNkc;'....'dNWMMMMMMMMMM");
|
||||
mvaddwstr(9, 44, L"MMMMMMMMMMN0dc:,''''.:ONWMMMMMMMMM");
|
||||
mvaddwstr(10, 44, L"MMMMMMMMMWKxllc;,'''',lKWMMMMMMMMM");
|
||||
mvaddwstr(11, 44, L"MMMMMMMMWNkoolc;,,,,;;:xXWMMMMMMMM");
|
||||
mvaddwstr(12, 44, L"MMMMMMMMW0olllc;,,,,,,,:OWMMMMMMMM");
|
||||
mvaddwstr(13, 44, L"MMMMMMMMNOollc:,'....'';xNMMMMMMMM");
|
||||
mvaddwstr(14, 44, L"MMMMMMMMW0dllc:,''''''':OWMMMMMMMM");
|
||||
mvaddwstr(15, 44, L"MMMMMMMMWN0dc::;;,,,,,cONWMMMMMMMM");
|
||||
mvaddwstr(16, 44, L"MMMMMMMMMMWXOxoc::cldkXWMMMMMMMMMM");
|
||||
mvaddwstr(17, 44, L"MMMMMMMMMMMMWWNNXXNNWWMMMMMMMMMMMM");
|
||||
mvaddwstr(18, 44, L"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");
|
||||
mvaddstr(7, 2, "Made by: Nick Chan, Mineek, Tom, Nebula,");
|
||||
mvaddstr(8, 2, "llsc12, Nathan");
|
||||
move(9, 2);
|
||||
whline(stdscr, ACS_HLINE, 40);
|
||||
mvaddstr(10, 2, "Thanks to: nyuszika7h, Procursus Team");
|
||||
mvaddstr(11, 2, "dora2ios, m1sta, Serena, xerub, tihmstar");
|
||||
mvaddstr(12, 2, "sbingner, checkra1n team (Siguza, Axi0mx");
|
||||
mvaddstr(13, 2, "argp et al.)");
|
||||
move(14, 2);
|
||||
whline(stdscr, ACS_HLINE, 40);
|
||||
mvaddstr(19, 2, "palera1n is NOT affinated with checkra1n");
|
||||
mvaddstr(20, 2, "Note: Backup your stuff. Use at your own risk.");
|
||||
mvaddstr(19, 78 - strlen("@palera1n"), "@palera1n");
|
||||
mvaddstr(20, 78 - strlen("https://palera.in"), "https://palera.in");
|
||||
attroff(COLOR_PAIR(ICON_COLOR));
|
||||
move(21,1);
|
||||
whline(stdscr, ACS_HLINE, 80 - 2);
|
||||
move(22, 40);
|
||||
|
||||
ITEM* main_buttons[4];
|
||||
MENU* main_menu;
|
||||
|
||||
main_buttons[0] = new_item(MAIN_OPTIONS, "");
|
||||
main_buttons[1] = new_item(MAIN_START, "");
|
||||
main_buttons[2] = new_item(MAIN_EXIT, "");
|
||||
main_buttons[3] = NULL;
|
||||
main_menu = new_menu(main_buttons);
|
||||
item_opts_off(main_buttons[1], O_SELECTABLE);
|
||||
|
||||
set_menu_format(main_menu, 1, 40);
|
||||
set_menu_sub(main_menu, derwin(stdscr, 0, 0, 22, 50));
|
||||
post_menu(main_menu);
|
||||
raw();
|
||||
refresh();
|
||||
while (1) {
|
||||
int ch = getch();
|
||||
if (ch == KEY_LEFT) {
|
||||
menu_driver(main_menu, REQ_LEFT_ITEM);
|
||||
} else if (ch == KEY_RIGHT) {
|
||||
menu_driver(main_menu, REQ_RIGHT_ITEM);
|
||||
} else if (ch == 10) {
|
||||
if (!(item_opts(current_item(main_menu)) & O_SELECTABLE)) continue;
|
||||
// fprintf(stderr, "Button %s pressed\n", current_item(main_menu)->name.str);
|
||||
if (!strcmp(current_item(main_menu)->name.str, MAIN_EXIT)) {
|
||||
ret = EXIT_SCREEN;
|
||||
} else if (!strcmp(current_item(main_menu)->name.str, MAIN_START)) {
|
||||
ret = ENTER_RECOVERY_SCREEN;
|
||||
} else if (!strcmp(current_item(main_menu)->name.str, MAIN_OPTIONS)) {
|
||||
ret = OPTIONS_SCREEN;
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
refresh();
|
||||
int ret = MAIN_SCREEN;
|
||||
bool can_start = false;
|
||||
newtCenteredWindow(WIDTH, HEIGHT, NULL);
|
||||
newtComponent optionsButton = newtCompactButton(46, 18, "Options");
|
||||
newtComponent startButton = newtCompactButton(57, 18, "Start");
|
||||
newtComponent exitButton = newtCompactButton(66, 18, "Exit");
|
||||
newtComponent welcome = newtLabel(1, 0, "Welcome to palera1n!");
|
||||
newtComponent deviceMsg = newtTextbox(1, 2, 40, 3, NEWT_FLAG_WRAP);
|
||||
set_tui_log(deviceMsg);
|
||||
LOG(LOG_INFO, "Connect your iPhone, iPad or iPod Touch to begin.");
|
||||
newtTextboxSetColors(deviceMsg, PI_LOG_COLOR, PI_LOG_COLOR);
|
||||
set_tui_log(deviceMsg);
|
||||
newtComponent form = newtForm(NULL, NULL, 0);
|
||||
newtFormAddComponents(form, optionsButton, startButton, exitButton, welcome,
|
||||
deviceMsg, NULL);
|
||||
newtRunForm(form);
|
||||
newtRefresh();
|
||||
newtComponent buttonPressed = newtFormGetCurrent(form);
|
||||
if (buttonPressed == optionsButton) {
|
||||
ret = OPTIONS_SCREEN;
|
||||
} else if (buttonPressed == startButton) {
|
||||
if (can_start)
|
||||
ret = ENTER_RECOVERY_SCREEN;
|
||||
else
|
||||
ret = MAIN_SCREEN;
|
||||
} else if (buttonPressed == exitButton) {
|
||||
ret = EXIT_SCREEN;
|
||||
}
|
||||
end:
|
||||
noraw();
|
||||
unpost_menu(main_menu);
|
||||
free_menu(main_menu);
|
||||
free_item(main_buttons[0]);
|
||||
free_item(main_buttons[1]);
|
||||
free_item(main_buttons[2]);
|
||||
set_tui_log(NULL);
|
||||
newtFormDestroy(form);
|
||||
return ret;
|
||||
}
|
||||
+57
-37
@@ -1,8 +1,3 @@
|
||||
#define NCURSES_WIDECHAR 1
|
||||
|
||||
#include <ncurses.h>
|
||||
#include <form.h>
|
||||
#include <menu.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -14,44 +9,69 @@
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#include <tui.h>
|
||||
|
||||
void bitfield_check_cb(newtComponent box, void* data) {
|
||||
if (newtCheckboxGetValue(box) == ' ') {
|
||||
*((tui_bit_info_t*)data)->flags_p = *((tui_bit_info_t*)data)->flags_p &~ ((tui_bit_info_t*)data)->opt;
|
||||
} else if (newtCheckboxGetValue(box) == '*') {
|
||||
*((tui_bit_info_t*)data)->flags_p |= ((tui_bit_info_t*)data)->opt;
|
||||
} else assert(0);
|
||||
}
|
||||
|
||||
|
||||
tui_screen_t tui_screen_options() {
|
||||
tui_screen_t ret = EXIT_SCREEN;
|
||||
ITEM* back_button[2];
|
||||
MENU* back_menu;
|
||||
back_button[0] = new_item("Back", "");
|
||||
back_button[1] = NULL;
|
||||
back_menu = new_menu(back_button);
|
||||
tui_bit_info_t verbose_info = { &kpf_flags, checkrain_option_verbose_boot };
|
||||
tui_bit_info_t rootful_info = { &palerain_flags, palerain_option_rootful };
|
||||
tui_bit_info_t setup_rootful_info = { &palerain_flags, palerain_option_setup_rootful };
|
||||
tui_bit_info_t force_revert_info = { &checkrain_flags, checkrain_option_force_revert };
|
||||
tui_bit_info_t safemode_info = { &checkrain_flags, checkrain_option_safemode };
|
||||
|
||||
move(21, 1);
|
||||
hline(ACS_HLINE, 80 - 2);
|
||||
|
||||
set_menu_format(back_menu, 1, 10);
|
||||
set_menu_sub(back_menu, derwin(stdscr, 0, 0, 22, 68));
|
||||
post_menu(back_menu);
|
||||
|
||||
FORM* options_form;
|
||||
FIELD* options[3];
|
||||
static checkrain_option_t flower_flags = 0, flower_option_flower_chain = (1 << 0);
|
||||
tui_bit_info_t flower_chain_info = { &flower_flags, flower_option_flower_chain };
|
||||
|
||||
const char* bootargs_entered = NULL;
|
||||
int ret = MAIN_SCREEN;
|
||||
|
||||
refresh();
|
||||
newtCenteredWindow(WIDTH, HEIGHT, NULL);
|
||||
newtComponent backButton = newtCompactButton(66, 18, "Back");
|
||||
|
||||
while(1) {
|
||||
int ch = getch();
|
||||
if (ch == 10) {
|
||||
if (!(item_opts(current_item(back_menu)) & O_SELECTABLE)) continue;
|
||||
if (!strcmp(current_item(back_menu)->name.str, BACK_BUTTON)) {
|
||||
ret = MAIN_SCREEN;
|
||||
}
|
||||
goto end;
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
end:
|
||||
unpost_menu(back_menu);
|
||||
free_item(back_button[0]);
|
||||
free_menu(back_menu);
|
||||
newtComponent optionsNotice = newtTextbox(1, 0, WIDTH - 2, 3, NEWT_FLAG_WRAP);
|
||||
newtTextboxSetText(optionsNotice, "You may set the following options. If you don't know what they mean you'll probably have no reason to set them.");
|
||||
// newtTextboxSetColors(optionsNotice, NEWT_COLORSET_LABEL, NEWT_COLORSET_LABEL);
|
||||
|
||||
newtComponent verboseBootBox = newtCheckbox(1, 3, "Verbose boot", CHECKBOX_STATE(kpf_flags, checkrain_option_verbose_boot), NULL, NULL);
|
||||
newtComponent rootfulBox = newtCheckbox(1, 4, "Rootful", CHECKBOX_STATE(palerain_flags, palerain_option_rootful), NULL, NULL);
|
||||
newtComponent rootfulSetupBox = newtCheckbox(1, 5, "Setup fakefs", CHECKBOX_STATE(palerain_flags, palerain_option_setup_rootful), NULL, NULL);
|
||||
newtComponent forceRevertBox = newtCheckbox(1, 6, "Restore system", CHECKBOX_STATE(checkrain_flags, checkrain_option_force_revert), NULL, NULL);
|
||||
newtComponent safeModeBox = newtCheckbox(1, 7, "Safe mode", CHECKBOX_STATE(checkrain_flags, checkrain_option_safemode), NULL, NULL);
|
||||
|
||||
newtComponentAddCallback(verboseBootBox, bitfield_check_cb, &verbose_info);
|
||||
newtComponentAddCallback(rootfulBox, bitfield_check_cb, &rootful_info);
|
||||
newtComponentAddCallback(rootfulSetupBox, bitfield_check_cb, &setup_rootful_info);
|
||||
newtComponentAddCallback(forceRevertBox, bitfield_check_cb, &force_revert_info);
|
||||
newtComponentAddCallback(safeModeBox, bitfield_check_cb, &safemode_info);
|
||||
|
||||
newtComponent bootCmdlineLabel = newtLabel(1, 8, "Kernel command line:");
|
||||
newtComponent bootCmdlineEntry = newtEntry(1, 9, &xargs_cmd[6], WIDTH - 2, &bootargs_entered, NEWT_ENTRY_SCROLL);
|
||||
|
||||
newtComponent flowerChainBox = newtCheckbox(1, 10, "Flower chain", CHECKBOX_STATE(flower_flags, flower_option_flower_chain), NULL, NULL);
|
||||
newtComponentAddCallback(flowerChainBox, bitfield_check_cb, &flower_chain_info);
|
||||
|
||||
|
||||
newtComponent form = newtForm(NULL, NULL, 0);
|
||||
newtFormAddComponents(form, backButton, verboseBootBox, rootfulBox,
|
||||
rootfulSetupBox, forceRevertBox, safeModeBox, bootCmdlineLabel,
|
||||
bootCmdlineEntry, flowerChainBox, optionsNotice,
|
||||
NULL);
|
||||
newtRunForm(form);
|
||||
newtRefresh();
|
||||
snprintf(xargs_cmd, 0x270, "xargs %s", bootargs_entered);
|
||||
newtComponent buttonPressed = newtFormGetCurrent(form);
|
||||
if (buttonPressed == backButton) {
|
||||
ret = MAIN_SCREEN;
|
||||
} else ret = MAIN_SCREEN;
|
||||
newtFormDestroy(form);
|
||||
return ret;
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* pongoOS - https://checkra.in
|
||||
*
|
||||
* Copyright (C) 2019-2022 checkra1n team
|
||||
*
|
||||
* This file is part of pongoOS.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <fcntl.h> // open
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> // exit, strtoull
|
||||
#include <string.h> // strlen, strerror, memcpy, memmove
|
||||
#include <unistd.h> // close
|
||||
#include <wordexp.h>
|
||||
#include <sys/mman.h> // mmap, munmap
|
||||
#include <sys/stat.h> // fstst
|
||||
#include <mach/mach.h>
|
||||
|
||||
#include <palerain.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
|
||||
|
||||
const char *usb_strerror(usb_ret_t err)
|
||||
{
|
||||
return mach_error_string(err);
|
||||
}
|
||||
|
||||
usb_ret_t USBControlTransfer(usb_device_handle_t handle, uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t wLength, void *data, uint32_t *wLenDone)
|
||||
{
|
||||
IOUSBDevRequest request =
|
||||
{
|
||||
.bmRequestType = bmRequestType,
|
||||
.bRequest = bRequest,
|
||||
.wValue = wValue,
|
||||
.wIndex = wIndex,
|
||||
.wLength = wLength,
|
||||
.pData = data,
|
||||
};
|
||||
usb_ret_t ret = (*handle)->ControlRequest(handle, 0, &request);
|
||||
if(wLenDone) *wLenDone = request.wLenDone;
|
||||
return ret;
|
||||
}
|
||||
|
||||
usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, uint32_t len)
|
||||
{
|
||||
return (*handle)->WritePipe(handle, 2, data, len);
|
||||
}
|
||||
|
||||
static void FoundDevice(void *refCon, io_iterator_t it)
|
||||
{
|
||||
stuff_t *stuff = refCon;
|
||||
if(stuff->regID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
io_service_t usbDev = MACH_PORT_NULL;
|
||||
while((usbDev = IOIteratorNext(it)))
|
||||
{
|
||||
uint64_t regID;
|
||||
kern_return_t ret = IORegistryEntryGetRegistryEntryID(usbDev, ®ID);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("IORegistryEntryGetRegistryEntryID: %s", mach_error_string(ret));
|
||||
goto next;
|
||||
}
|
||||
SInt32 score = 0;
|
||||
IOCFPlugInInterface **plugin = NULL;
|
||||
ret = IOCreatePlugInInterfaceForService(usbDev, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin, &score);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("IOCreatePlugInInterfaceForService(usbDev): %s", mach_error_string(ret));
|
||||
goto next;
|
||||
}
|
||||
HRESULT result = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*)&stuff->dev);
|
||||
(*plugin)->Release(plugin);
|
||||
if(result != 0)
|
||||
{
|
||||
ERR("QueryInterface(dev): 0x%x", result);
|
||||
goto next;
|
||||
}
|
||||
ret = (*stuff->dev)->USBDeviceOpenSeize(stuff->dev);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("USBDeviceOpenSeize: %s", mach_error_string(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = (*stuff->dev)->SetConfiguration(stuff->dev, 1);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("SetConfiguration: %s", mach_error_string(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
IOUSBFindInterfaceRequest request =
|
||||
{
|
||||
.bInterfaceClass = kIOUSBFindInterfaceDontCare,
|
||||
.bInterfaceSubClass = kIOUSBFindInterfaceDontCare,
|
||||
.bInterfaceProtocol = kIOUSBFindInterfaceDontCare,
|
||||
.bAlternateSetting = kIOUSBFindInterfaceDontCare,
|
||||
};
|
||||
io_iterator_t iter = MACH_PORT_NULL;
|
||||
ret = (*stuff->dev)->CreateInterfaceIterator(stuff->dev, &request, &iter);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("CreateInterfaceIterator: %s", mach_error_string(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
io_service_t usbIntf = MACH_PORT_NULL;
|
||||
while((usbIntf = IOIteratorNext(iter)))
|
||||
{
|
||||
ret = IOCreatePlugInInterfaceForService(usbIntf, kIOUSBInterfaceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin, &score);
|
||||
IOObjectRelease(usbIntf);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("IOCreatePlugInInterfaceForService(usbIntf): %s", mach_error_string(ret));
|
||||
continue;
|
||||
}
|
||||
result = (*plugin)->QueryInterface(plugin, CFUUIDGetUUIDBytes(kIOUSBInterfaceInterfaceID), (LPVOID*)&stuff->handle);
|
||||
(*plugin)->Release(plugin);
|
||||
if(result != 0)
|
||||
{
|
||||
ERR("QueryInterface(intf): 0x%x", result);
|
||||
continue;
|
||||
}
|
||||
ret = (*stuff->handle)->USBInterfaceOpen(stuff->handle);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("USBInterfaceOpen: %s", mach_error_string(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
io_start(stuff);
|
||||
stuff->regID = regID;
|
||||
while((usbIntf = IOIteratorNext(iter))) IOObjectRelease(usbIntf);
|
||||
IOObjectRelease(iter);
|
||||
while((usbDev = IOIteratorNext(it))) IOObjectRelease(usbDev);
|
||||
IOObjectRelease(usbDev);
|
||||
return;
|
||||
}
|
||||
(*stuff->handle)->Release(stuff->handle);
|
||||
stuff->handle = NULL;
|
||||
}
|
||||
IOObjectRelease(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
next:;
|
||||
if(stuff->dev)
|
||||
{
|
||||
(*stuff->dev)->USBDeviceClose(stuff->dev);
|
||||
(*stuff->dev)->Release(stuff->dev);
|
||||
stuff->dev = NULL;
|
||||
}
|
||||
IOObjectRelease(usbDev);
|
||||
}
|
||||
}
|
||||
|
||||
static void LostDevice(void *refCon, io_iterator_t it)
|
||||
{
|
||||
stuff_t *stuff = refCon;
|
||||
io_service_t usbDev = MACH_PORT_NULL;
|
||||
while((usbDev = IOIteratorNext(it)))
|
||||
{
|
||||
uint64_t regID;
|
||||
kern_return_t ret = IORegistryEntryGetRegistryEntryID(usbDev, ®ID);
|
||||
IOObjectRelease(usbDev);
|
||||
if(ret == KERN_SUCCESS && stuff->regID == regID)
|
||||
{
|
||||
io_stop(stuff);
|
||||
stuff->regID = 0;
|
||||
(*stuff->handle)->USBInterfaceClose(stuff->handle);
|
||||
(*stuff->handle)->Release(stuff->handle);
|
||||
(*stuff->dev)->USBDeviceClose(stuff->dev);
|
||||
(*stuff->dev)->Release(stuff->dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const int pongo_usb_vendor = PONGO_USB_VENDOR;
|
||||
static const int pongo_usb_product = PONGO_USB_PRODUCT;
|
||||
|
||||
int wait_for_pongo(void) {
|
||||
kern_return_t ret;
|
||||
stuff_t stuff;
|
||||
io_iterator_t found, lost;
|
||||
|
||||
void* cfdict_keys[3];
|
||||
void* cfdict_values[3];
|
||||
|
||||
cfdict_keys[0] = (void*)CFSTR("IOProviderClass");
|
||||
cfdict_keys[1] = (void*)CFSTR("idVendor");
|
||||
cfdict_keys[2] = (void*)CFSTR("idProduct");
|
||||
|
||||
cfdict_values[0] = (void*)CFSTR("IOUSBDevice");
|
||||
cfdict_values[1] = (void*)CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pongo_usb_vendor);
|
||||
cfdict_values[2] = (void*)CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &pongo_usb_product);
|
||||
|
||||
CFDictionaryRef cfdict = CFDictionaryCreate(kCFAllocatorDefault, (const void**)cfdict_keys, (const void**)cfdict_values, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||
IONotificationPortRef notifyPort = IONotificationPortCreate(kIOMasterPortDefault);
|
||||
|
||||
CFRetain(cfdict);
|
||||
// CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPort), kCFRunLoopDefaultMode);
|
||||
|
||||
ret = IOServiceAddMatchingNotification(notifyPort, kIOFirstMatchNotification, cfdict, &FoundDevice, &stuff, &found);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("IOServiceAddMatchingNotification: %s", mach_error_string(ret));
|
||||
return -1;
|
||||
}
|
||||
FoundDevice(&stuff, found);
|
||||
|
||||
CFRetain(cfdict);
|
||||
ret = IOServiceAddMatchingNotification(notifyPort, kIOTerminatedNotification, cfdict, &LostDevice, &stuff, &lost);
|
||||
if(ret != KERN_SUCCESS)
|
||||
{
|
||||
ERR("IOServiceAddMatchingNotification: %s", mach_error_string(ret));
|
||||
return -1;
|
||||
}
|
||||
LostDevice(&stuff, lost);
|
||||
// CFRunLoopRun();
|
||||
while (get_spin()) {
|
||||
sleep(1);
|
||||
}
|
||||
CFRelease(cfdict);
|
||||
return 0;
|
||||
}
|
||||
@@ -24,8 +24,7 @@
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef USE_LIBUSB
|
||||
#include <errno.h>
|
||||
#include <fcntl.h> // open
|
||||
#include <pthread.h>
|
||||
@@ -38,20 +37,11 @@
|
||||
#include <sys/mman.h> // mmap, munmap
|
||||
#include <sys/stat.h> // fstst
|
||||
|
||||
#include <common.h>
|
||||
#include <palerain.h>
|
||||
#define ERR(...) LOG(LOG_VERBOSE, __VA_ARGS__)
|
||||
|
||||
// Keep in sync with Pongo
|
||||
#define PONGO_USB_VENDOR 0x05ac
|
||||
#define PONGO_USB_PRODUCT 0x4141
|
||||
#define CMD_LEN_MAX 512
|
||||
#define UPLOADSZ_MAX (1024 * 1024 * 128)
|
||||
|
||||
typedef struct stuff stuff_t;
|
||||
|
||||
static void io_start(stuff_t *stuff);
|
||||
static void io_stop(stuff_t *stuff);
|
||||
|
||||
void io_start(stuff_t *stuff);
|
||||
void io_stop(stuff_t *stuff);
|
||||
|
||||
const char *usb_strerror(usb_ret_t err)
|
||||
{
|
||||
@@ -122,13 +112,6 @@ usb_ret_t USBBulkUpload(usb_device_handle_t handle, void *data, int len)
|
||||
return LIBUSB_SUCCESS;
|
||||
}
|
||||
|
||||
struct stuff
|
||||
{
|
||||
pthread_t th;
|
||||
libusb_device *dev;
|
||||
usb_device_handle_t handle;
|
||||
};
|
||||
|
||||
static int FoundDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_event event, void *arg)
|
||||
{
|
||||
LOG(LOG_VERBOSE, "PongoOS USB Device connected");
|
||||
@@ -196,7 +179,7 @@ static int LostDevice(libusb_context *ctx, libusb_device *dev, libusb_hotplug_ev
|
||||
|
||||
int wait_for_pongo(void)
|
||||
{
|
||||
stuff_t stuff = {};
|
||||
stuff_t stuff;
|
||||
libusb_hotplug_callback_handle hp[2];
|
||||
|
||||
int r = libusb_init(NULL);
|
||||
@@ -240,7 +223,7 @@ int wait_for_pongo(void)
|
||||
|
||||
for(ssize_t i = 0; i < sz; ++i)
|
||||
{
|
||||
struct libusb_device_descriptor desc = {};
|
||||
struct libusb_device_descriptor desc;
|
||||
r = libusb_get_device_descriptor(list[i], &desc);
|
||||
if(r != LIBUSB_SUCCESS)
|
||||
{
|
||||
@@ -280,124 +263,4 @@ int wait_for_pongo(void)
|
||||
libusb_exit(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void io_start(stuff_t *stuff)
|
||||
{
|
||||
int r = pthread_create(&stuff->th, NULL, &pongo_usb_callback, &stuff->handle);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_create: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
}
|
||||
pthread_join(stuff->th, NULL);
|
||||
}
|
||||
|
||||
static void io_stop(stuff_t *stuff)
|
||||
{
|
||||
int r = pthread_cancel(stuff->th);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_cancel: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
}
|
||||
r = pthread_join(stuff->th, NULL);
|
||||
if(r != 0)
|
||||
{
|
||||
ERR("pthread_join: %s", strerror(r));
|
||||
exit(-1); // TODO: ok with libusb?
|
||||
}
|
||||
}
|
||||
|
||||
static void write_stdout(char *buf, uint32_t len)
|
||||
{
|
||||
while(len > 0) {
|
||||
if (verbose >= 3) {
|
||||
ssize_t s = write(1, buf, len);
|
||||
if(s < 0) {
|
||||
LOG(LOG_ERROR, "write: %s", strerror(errno));
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
buf += s;
|
||||
len -= s;
|
||||
} else break;
|
||||
}
|
||||
}
|
||||
|
||||
int issue_pongo_command(usb_device_handle_t handle, char *command)
|
||||
{
|
||||
uint32_t outpos = 0;
|
||||
uint32_t outlen = 0;
|
||||
int ret = USB_RET_SUCCESS;
|
||||
uint8_t in_progress = 1;
|
||||
if (command == NULL) goto fetch_output;
|
||||
size_t len = strlen(command);
|
||||
char command_buf[512];
|
||||
char stdout_buf[0x2000];
|
||||
if (len > (CMD_LEN_MAX - 2))
|
||||
{
|
||||
LOG(LOG_ERROR, "Pongo command %s too long (max %d)", command, CMD_LEN_MAX - 2);
|
||||
return EINVAL;
|
||||
}
|
||||
if (verbose < 3 || verbose > 4) {
|
||||
LOG(LOG_VERBOSE, "Executing PongoOS command: '%s'", command);
|
||||
} else {
|
||||
printf("%s\n", command);
|
||||
}
|
||||
snprintf(command_buf, 512, "%s\n", command);
|
||||
len = strlen(command_buf);
|
||||
ret = USBControlTransfer(handle, 0x21, 4, 1, 0, 0, NULL, NULL);
|
||||
if (ret)
|
||||
goto bad;
|
||||
ret = USBControlTransfer(handle, 0x21, 3, 0, 0, (uint32_t)len, command_buf, NULL);
|
||||
fetch_output:
|
||||
while (in_progress) {
|
||||
ret = USBControlTransfer(handle, 0xa1, 2, 0, 0, (uint32_t)sizeof(in_progress), &in_progress, NULL);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
ret = USBControlTransfer(handle, 0xa1, 1, 0, 0, 0x1000, stdout_buf + outpos, &outlen);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
write_stdout(stdout_buf + outpos, outlen);
|
||||
outpos += outlen;
|
||||
if (outpos > 0x1000)
|
||||
{
|
||||
memmove(stdout_buf, stdout_buf + outpos - 0x1000, 0x1000);
|
||||
outpos = 0x1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ret != USB_RET_SUCCESS)
|
||||
{
|
||||
goto bad;
|
||||
}
|
||||
}
|
||||
bad:
|
||||
if (ret != USB_RET_SUCCESS)
|
||||
{
|
||||
if (ret == USB_RET_NOT_RESPONDING)
|
||||
return 0;
|
||||
if (command != NULL && (!strncmp("boot", command, 4) && ret == USB_RET_IO))
|
||||
return 0;
|
||||
LOG(LOG_ERROR, "USB error: %s", usb_strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
int upload_pongo_file(usb_device_handle_t handle, unsigned char *buf, unsigned int buf_len)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = USBControlTransfer(handle, 0x21, 1, 0, 0, 4, &buf_len, NULL);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
ret = USBBulkUpload(handle, buf, buf_len);
|
||||
if (ret == USB_RET_SUCCESS)
|
||||
{
|
||||
LOG(LOG_VERBOSE, "Uploaded %llu bytes to PongoOS", (unsigned long long)buf_len);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user