Skip to content

Commit bd9302d

Browse files
committed
Tried to fix various issues that came up with the new bookworm image
1 parent bf9936d commit bd9302d

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

backend/_headers.php

+21-21
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
55
header("Access-Control-Allow-Headers: Content-Type");
66
$request_headers = apache_request_headers();
7-
$http_origin = $request_headers['Origin'];
8-
$allowed_http_origins = array(
9-
"http://192.168.178.4.1",
10-
"https://192.168.178.4.1",
11-
"http://honeypi.local",
12-
"https://honeypi.local",
13-
"http://honeypi.fritz.box",
14-
"https://honeypi.fritz.box",
15-
"http://localhost:4200",
16-
"https://localhost:4200"
17-
);
18-
$host = parse_url($http_origin, PHP_URL_HOST);
19-
$tmp = explode('.',$host); $n = count($tmp);
20-
$tld = $tmp[($n-2)].".".$tmp[($n-1)]; //top-level domain
21-
$isHomeNetwork = strpos($host, "192.168.");
22-
23-
if (in_array($http_origin, $allowed_http_origins) || in_array($tld, array("local", "honeypi")) || $isHomeNetwork !== false) {
24-
// This function is actually not bullet-proof
25-
@header("Access-Control-Allow-Origin: " . $http_origin);
7+
if( isset($request_headers['Origin'])) {
8+
$http_origin = $request_headers['Origin'];
9+
$allowed_http_origins = array(
10+
"http://192.168.178.4.1",
11+
"https://192.168.178.4.1",
12+
"http://honeypi.local",
13+
"https://honeypi.local",
14+
"http://honeypi.fritz.box",
15+
"https://honeypi.fritz.box",
16+
"http://localhost:4200",
17+
"https://localhost:4200"
18+
);
19+
$host = parse_url($http_origin, PHP_URL_HOST);
20+
$tmp = explode('.',$host); $n = count($tmp);
21+
$tld = $tmp[($n-2)].".".$tmp[($n-1)]; //top-level domain
22+
$isHomeNetwork = strpos($host, "192.168.");
23+
if (in_array($http_origin, $allowed_http_origins) || in_array($tld, array("local", "honeypi")) || $isHomeNetwork !== false) {
24+
// This function is actually not bullet-proof
25+
@header("Access-Control-Allow-Origin: " . $http_origin);
26+
}
27+
header("Vary: Origin");
2628
}
27-
header("Vary: Origin");
28-
2929
// nocache
3030
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
3131
header("Cache-Control: post-check=0, pre-check=0", false);

backend/control.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function shutdown() {
1616
shell_exec("sudo systemctl disable hostapd.service");
1717
shell_exec("sudo systemctl stop dnsmasq.service");
1818
shell_exec("sudo systemctl disable dnsmasq.service");
19-
shell_exec("sudo shutdown -h 0");
19+
shell_exec("sudo shutdown -h now");
2020
}
2121
function stop_honeypi() {
2222
shell_exec("sudo systemctl stop honeypi.service");

backend/update.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121

2222
// function for shell script
2323
function updateGit() {
24-
return shell_exec("sudo git reset HEAD --hard && sudo git pull");
24+
chdir($GLOBALS['honeyPiHome']);
25+
$out = shell_exec("cd ".$GLOBALS['honeyPiHome']." 2>&1");
26+
$out .= shell_exec("cd ".$GLOBALS['honeyPiHome']." && sudo git config --global --add safe.directory ".$GLOBALS['honeyPiHome']." 2>&1");
27+
$out .= shell_exec("cd ".$GLOBALS['honeyPiHome']." && sudo git reset HEAD --hard 2>&1");
28+
$out .= shell_exec("cd ".$GLOBALS['honeyPiHome']." && sudo git pull 2>&1");
29+
return $out;
2530
}
2631
function update($stable) {
2732
return shell_exec("sudo sh ".$GLOBALS['honeyPiHome']."/update.sh ".(INT)$stable."");
@@ -118,12 +123,10 @@ function getVersionInfo($isStable) {
118123
return $obj;
119124
}
120125

126+
# Add Working dir to output
121127
$output = new \stdClass();
122-
// switch working dir
123-
$output->chdir = "Changed working dir from ";
124-
$output->chdir .= getcwd() . "\n";
125-
chdir($GLOBALS['honeyPiHome']);
126-
$output->chdir .= " to " . getcwd() . "\n";
128+
$output->chdir = "Working dir: ";
129+
$output->chdir .= getcwd();
127130

128131
if (isset($_GET['mode']))
129132
{

0 commit comments

Comments
 (0)