diff options
author | stilez <stilez@users.noreply.github.com> | 2017-01-05 10:44:20 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-01-05 10:44:44 -0200 |
commit | 46237e23f35db70a917939609061dce7b7f955f9 (patch) | |
tree | 644885ccf273039aacb1d1a9062c89be31ad9ab8 /src/usr/local/www/status_gateways.php | |
parent | d31a02b89dd6485d718059816e9395ad382b95c8 (diff) | |
download | pfsense-46237e23f35db70a917939609061dce7b7f955f9.zip pfsense-46237e23f35db70a917939609061dce7b7f955f9.tar.gz |
get_pkg_info() fallback using pkg info if no local copy of repo catalog
*Current behaviour*
At the moment, get_pkg_info() is used to get all information on packages. The parameter _$local_only_ is set to request info directly from the local copy of the repo catalog (using -U) without requesting the remote repo catalog or updating the local copy from the remote repo catalog. If the calling code wants only installed pkgs, it filters the returned list of pkgs looking for _$pkg['installed'] == true_.
There's a couple of problems with this method as it stands, due to the behaviour of pkg search -U.
1. When the remote catalog is requested and the request failed, the local copy is also deleted. If this happens, then pkg search returns an error even with -U, so even if all we wanted was to know from get_pkg_info() was the names of locally installed packages, it can't be used for this (even though this info doesn't need access to a remote repo catalog)
2. This behaviour, and the use of get_pkg_info() as the main method to get a list of installed pfSense packages and their data, means that any time we don't have a network connection or for any reason get_pkg_info() fails to access the repo catalog remotely, we become blocked from *any* inquiry, lookup, listing, or action on *all* optional packages, even if our desired action wouldn't need remote access to complete. We remain unable to do these things until remote repo access is obtained again and a catalog copy can be re-acquired.
3. This also means that nothing to do with getting installed package information or removal can occur offline either.
*Change made*
It's likely that when code explicitly requests $local_only, it isn't expecting or requiring the local copy to be up to date. So I've modified the code as follows:
1. New optional parameter $installed_only to explicitly request installed pkg info only (faster if we know that no remote request will be needed)
2. If $local_only is set and pkg search failed, retry falling back to pkg info to at least provide info on matching installed packages. This is probably more helpful than returning an error, as the assumption with $local_only is not "latest data in repo" so no harm done, and it allows pkg code to at least operate on local pkgs at all times, if not other pkgs in the repo.
(cherry picked from commit e47af756de79d4e8b0356cf22f72f62f09e9ad7d)
Diffstat (limited to 'src/usr/local/www/status_gateways.php')
0 files changed, 0 insertions, 0 deletions