diff --git a/README.md b/README.md index f73d343..315f510 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,8 @@ HotFix; Quickly patch and fix system $ hotfix sign test.hotfix + +## Building the executable + +Included is `makephar`, a utility to create highly compressed self-executable +php archives. diff --git a/bin/bootstrap.php b/bin/bootstrap.php index 6fefdcc..8179951 100644 --- a/bin/bootstrap.php +++ b/bin/bootstrap.php @@ -1,5 +1,7 @@ = 7) { + fprintf(STDERR, "Resolve using pecl:\n sudo pecl install gnupg-1.4.0RC1\n"); + fprintf(STDERR, " echo 'extension=gnupg.so' | sudo tee /etc/php/7.0/mods-available/gnupg.ini\n"); + fprintf(STDERR, " sudo phpenmod gnupg\n"); + } else { + fprintf(STDERR," * Debian/Ubuntu: Resolve with 'sudo apt-get install php5-gnupg'\n"); + fprintf(STDERR," * Any distro: Resolve with 'sudp pecl install gnupg', follow instructions to enable.\n"); + } die(); } diff --git a/composer.json b/composer.json index d8aaa89..71fb238 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ }, "require": { "symfony/console": "^3.0", - "symfony/yaml": "^3.0" + "symfony/yaml": "^3.0", + "noccylabs/downloader": "@dev" } } diff --git a/makephar b/makephar index ebb2ac9..f3ebc9c 100755 Binary files a/makephar and b/makephar differ diff --git a/share/nullpatch.fix b/share/nullpatch.fix index e816889..0e00a84 100644 --- a/share/nullpatch.fix +++ b/share/nullpatch.fix @@ -6,6 +6,5 @@ author: Noccy lang: bash --- -echo "Hello World" - -echo "This is executing in bash! Woot" +info "Hello World" +exec "ls -al" diff --git a/src/Hotfix/Hotfix.php b/src/Hotfix/Hotfix.php index c4df8d2..5a510fa 100644 --- a/src/Hotfix/Hotfix.php +++ b/src/Hotfix/Hotfix.php @@ -57,6 +57,7 @@ class Hotfix break; case 'php': $exec = "/usr/bin/env php"; + $head = "verifySignature($body, $signature); + if (!$insecure) { + $signer = $this->verifySignature($body, $signature); + } else { + $signer = null; + } } return new Hotfix($body, $signer); } @@ -64,6 +68,10 @@ class Loader $fingerprint = $sigInfo[0]['fingerprint']; $keyInfo = gnupg_keyinfo($gpg, $fingerprint); + if (empty($keyInfo)) { + throw new \Exception("Unknown signer (key id {$sigInfo[0]['fingerprint']})"); + } + $subKeys = $keyInfo[0]['subkeys']; $keyId = null; foreach ($subKeys as $subKey) { @@ -73,10 +81,6 @@ class Loader } } - if (empty($keyInfo)) { - throw new \Exception("Unknown signer (key id {$sigInfo[0]['fingerprint']})"); - } - return [ $keyInfo[0], $keyId ]; } } diff --git a/src/HotfixApplication.php b/src/HotfixApplication.php index 98652b2..04c192d 100644 --- a/src/HotfixApplication.php +++ b/src/HotfixApplication.php @@ -8,7 +8,7 @@ class HotfixApplication extends Application { public function __construct() { - parent::__construct("Hotfixer", "0.1"); + parent::__construct("Hotfix", APP_VERSION." (".PHAR_BUILD_DATE.")"); $this->add(new Command\ApplyCommand()); $this->add(new Command\SignCommand()); } diff --git a/src/stubs/bash.stub b/src/stubs/bash.stub index db928bb..34ba3f4 100644 --- a/src/stubs/bash.stub +++ b/src/stubs/bash.stub @@ -2,14 +2,15 @@ test -e /etc/lsb-release && source /etc/lsb-release function exec() { echo -e "\e[36;1m[exec]\e[36;21m $*\e[0m" - LOG=$(tempfile -p exec) - $@ &>$LOG + # LOG=$(tempfile -p exec) + $@ + # &>$LOG EC=$? if [ $EC -gt 0 ]; then echo -e "\e[31;1m[warn]\e[31;21m Command completed with exitcode $EC\e[0m" - tail -n5 $LOG | awk '{ print " " $0 }' + # tail -n5 $LOG | awk '{ print " " $0 }' fi - rm $LOG + # rm $LOG } function info() { echo -e "\e[32;1m[info]\e[32;21m $*\e[0m"