forked from jdel/sspks
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsign.php
37 lines (33 loc) · 1.17 KB
/
sign.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
$spkname = $_GET["spk"];
$spk = __DIR__ . '/' . $spkname;
$gpg = __DIR__ . '/gpg';
$sign = __DIR__ . '/codesign.php';
if (file_exists($sign)) {
$sign = "php codesign.php --sign=".$spk." --keydir=".$gpg." --keyfpr=@keyid@";
if (is_readable($gpg.'/secring.gpg') && is_readable($gpg.'/pubring.gpg')) {
if (is_writable($spk)) {
exec($sign, $output, $retval);
if ($retval > 0) {
$message = "Something went wrong while signing this package.";
file_put_contents('sspks.log', date("Y-m-d H:i:s").": ".$sign.PHP_EOL, FILE_APPEND);
file_put_contents('sspks.log', date("Y-m-d H:i:s").": ".implode(",", $output).PHP_EOL, FILE_APPEND);
} else {
$message = "";
}
} else {
$retval = -1;
$message = "Cannot sign ".basename($spkname)." because this package is read only.";
}
} else {
$retval = -1;
$message = "Cannot read the encryption key because the key rings are protected.";
}
} else {
$retval = -1;
$message = "Signing Package is not supported because gpg2 was not installed...";
}
$response = array('state' => $retval, 'message' => $message, 'details' => $output);
header('Content-Type: application/json');
echo json_encode($response);
?>