Updated stubs, improved PHP7 compatibility

This commit is contained in:
Christopher Vagnetoft 2016-07-21 03:08:06 +02:00
parent 10f4f09a34
commit 9f8cf0bf38
10 changed files with 35 additions and 15 deletions

View File

@ -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.

View File

@ -1,5 +1,7 @@
<?php
define("APP_VERSION", "0.1-pre");
require_once __DIR__."/../vendor/autoload.php";
require_once __DIR__."/systemtest.php";
if (file_exists(__DIR__."/banner.php"))

View File

@ -2,6 +2,13 @@
if (!is_callable("gnupg_init")) {
fprintf(STDERR, "Error: The PHP GnuPG extension is not installed.\n\n");
fprintf(STDERR," * Debian/Ubuntu: Resolve with 'sudo apt-get install php5-gnupg' (or 'php7-gnupg')\n");
if (PHP_VERSION_ID >= 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();
}

View File

@ -16,6 +16,7 @@
},
"require": {
"symfony/console": "^3.0",
"symfony/yaml": "^3.0"
"symfony/yaml": "^3.0",
"noccylabs/downloader": "@dev"
}
}

BIN
makephar

Binary file not shown.

View File

@ -6,6 +6,5 @@ author: Noccy <cvagnetoft@gmail.com>
lang: bash
---
echo "Hello World"
echo "This is executing in bash! Woot"
info "Hello World"
exec "ls -al"

View File

@ -57,6 +57,7 @@ class Hotfix
break;
case 'php':
$exec = "/usr/bin/env php";
$head = "<?php require_once \"".__DIR__."/../../vendor/autoload.php\"; ".file_get_contents(__DIR__."/../stubs/php.stub");
break;
default:
fprintf(STDERR, "Error: Unsupported language %s\n", $lang);

View File

@ -44,7 +44,11 @@ class Loader
} else {
list ($body, $signature) = explode($sigHeader, $hotfix);
$signature = $sigHeader.$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 ];
}
}

View File

@ -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());
}

View File

@ -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"