summaryrefslogtreecommitdiffstats
path: root/etc/inc/pkg-utils.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2014-07-01 15:22:42 -0400
committerjim-p <jimp@pfsense.org>2014-07-01 15:22:42 -0400
commitc55dfc4a9b4020533e6ec25278fc772b33ff2b93 (patch)
tree4a0e35d70f05c7301b5db9d63e215d250e578736 /etc/inc/pkg-utils.inc
parentc5f9fb72655ce9b87ba7a8dad5cadeb1acd20150 (diff)
downloadpfsense-c55dfc4a9b4020533e6ec25278fc772b33ff2b93.zip
pfsense-c55dfc4a9b4020533e6ec25278fc772b33ff2b93.tar.gz
Detect if an unofficial package repository is in use and warn the user. Part of issue #484 (more to go)
Diffstat (limited to 'etc/inc/pkg-utils.inc')
-rw-r--r--etc/inc/pkg-utils.inc30
1 files changed, 30 insertions, 0 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index 1174f79..016f027 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -1411,4 +1411,34 @@ function get_pkg_interfaces_select_source($include_localhost=false) {
}
return $ssifs;
}
+
+function verify_all_package_servers() {
+ global $config, $g;
+ /* If an alternate package repository is defined, check it before
+ checking the default. */
+ if (isset($config['system']['altpkgrepo']['enable']) && !empty($config['system']['altpkgrepo']['xmlrpcbaseurl'])) {
+ return verify_package_server($config['system']['altpkgrepo']['xmlrpcbaseurl']);
+ } else {
+ return verify_package_server($g['xmlrpcbaseurl']);
+ }
+}
+
+/* Check if the active package server is a valid default or if it has been
+ altered. */
+function verify_package_server($server) {
+ /* Define the expected default package server domains. Include
+ preceding "." to prevent matching from being too liberal. */
+ $default_package_domains = array('.pfsense.org', '.pfsense.com', '.netgate.com');
+
+ /* For this test we only need to check the hostname. */
+ $xmlrpcbase = parse_url($server, PHP_URL_HOST);
+
+ foreach ($default_package_domains as $dom) {
+ if (substr($xmlrpcbase, -(strlen($dom))) == $dom) {
+ return true;
+ }
+ }
+ return false;
+}
+
?>
OpenPOWER on IntegriCloud