Skip to content

Commit 1f7ef7a

Browse files
Merge pull request #489 from jaredhendrickson13/next_patch
fix: restrict upgrade path to v1 releases only
2 parents 4bd6910 + b9b214a commit 1f7ef7a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pfSense-pkg-API/files/etc/inc/api/models/APISystemAPIVersionRead.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class APISystemAPIVersionRead extends APIModel {
107107
if ($release["prerelease"] === false or isset($pkg_config["allow_pre_release"])) {
108108
# Loop through the assets of each release and check if our version of pfSense is supported
109109
foreach ($release["assets"] as $asset) {
110-
if (str_starts_with($asset["name"], "pfSense-" . $pf_version)) {
110+
if ($asset["name"] === "pfSense-$pf_version-pkg-API.pkg") {
111111
# The first item of our list is the latest release, mark it as such.
112112
if ($count === 0) {
113113
$versions[$release["tag_name"]] = $release["name"] . " - Latest";

pfSense-pkg-API/files/usr/local/share/pfSense-pkg-API/manage.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616
require_once("api/framework/APITools.inc");
17+
require_once("api/models/APISystemAPIVersionRead.inc");
1718

1819
function build_endpoints() {
1920
# Import each endpoint class
@@ -84,8 +85,9 @@ function sync() {
8485

8586
function update() {
8687
$pf_version = APITools\get_pfsense_version()["base"];
88+
$latest_version = APISystemAPIVersionRead::get_latest_api_version();
8789
echo shell_exec("/usr/sbin/pkg delete -y pfSense-pkg-API");
88-
echo shell_exec("/usr/sbin/pkg -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/latest/download/pfSense-".$pf_version."-pkg-API.pkg");
90+
echo shell_exec("/usr/sbin/pkg -C /dev/null add https://github.com/jaredhendrickson13/pfsense-api/releases/download/$latest_version/pfSense-".$pf_version."-pkg-API.pkg");
8991
echo shell_exec("/etc/rc.restart_webgui");
9092
}
9193

0 commit comments

Comments
 (0)