From 9f8cf0bf387edcf86ed1ce4753bf9db452a750d4 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Thu, 21 Jul 2016 03:08:06 +0200 Subject: [PATCH] Updated stubs, improved PHP7 compatibility --- README.md | 5 +++++ bin/bootstrap.php | 2 ++ bin/systemtest.php | 9 ++++++++- composer.json | 3 ++- makephar | Bin 30830 -> 34111 bytes share/nullpatch.fix | 5 ++--- src/Hotfix/Hotfix.php | 1 + src/Hotfix/Loader.php | 14 +++++++++----- src/HotfixApplication.php | 2 +- src/stubs/bash.stub | 9 +++++---- 10 files changed, 35 insertions(+), 15 deletions(-) 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 ebb2ac90efa4abf9c43fd7c21ae7e705de3e92ec..f3ebc9c4f58ec5a6e98330e576afe6196116e60e 100755 GIT binary patch delta 3186 zcmcguO>7iZ9B-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R`Vn}wZ4x7a&fTLvCunjaio8h1*qUo9rmwpU5n65Yc-ytHMP%&WU1i=qGS zOf*d*txessZPxk}XGT^7=7BxH6Z@W+3oMtCYg{QQZ0F_OTMd`@HnfFxkL@{&heR4o z8G_(7wIY?Vj}c)Ft+2MKp&n3c)-^V~6;Tg1I6;#96!#UxKXHMA+}T{@q~Knr&LU~6@< z=T?OMaZq6sWBVBC-Zado1Jy^>eG)hiRelr*MfOLleTU2~l_xPQK4w;|Jc(iPF|%R? z#^V2dSPYlRb+h8>|9V)gzTbcQc*`d@_gim$yJ2zp#os!v$NswiLhSGbmf?F)(mXJ|&~ZoOzaS@@E-Ufqota1|T~e zM4JXY_nWLCtHc8mZ~-bc<>5RuxmQ+RU?Cqw6^OoO>@{KX6Io@j5nOT>VA@sA08CfN z*@5Yuat>hnkDL{lwv-3co6F>rm?l?fO=*KiUU**PRFI9!fIjZWDXQ(P}-mR*~ zH2J)d%;XI!W&(cs3b~2dsRbE{MS98kd1;d?G|uuXp$I8$4$x#`)Kf_+&CE$jEz-3E zGc+`TI5*Z^yJ*#%vqo=3nLsOq1>GcsGBsUd1$dzMY1IN=Zg$v94V~QGP+O zo>EMnlAcO&NokVxW_9~K_RW 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"