summaryrefslogtreecommitdiffstats
path: root/modules-available/locations
diff options
context:
space:
mode:
authorJonathan Bauer2017-09-05 15:56:17 +0200
committerJonathan Bauer2017-09-05 15:56:17 +0200
commitf46409bf74e42de6490a7d80f319c132c3d6a43c (patch)
tree6b2f0e7ce391fd47a870182a3a468fce25f353f5 /modules-available/locations
parent[locationinfo] Add backend for Microsoft Exchange Server (diff)
downloadslx-admin-f46409bf74e42de6490a7d80f319c132c3d6a43c.tar.gz
slx-admin-f46409bf74e42de6490a7d80f319c132c3d6a43c.tar.xz
slx-admin-f46409bf74e42de6490a7d80f319c132c3d6a43c.zip
[locations] fix missing locationId on ip/uuid ...
... when the client's ip falls within a known range but its uuid has not been recorded yet and the client requests its config by uuid.
Diffstat (limited to 'modules-available/locations')
-rw-r--r--modules-available/locations/inc/location.inc.php37
1 files changed, 18 insertions, 19 deletions
diff --git a/modules-available/locations/inc/location.inc.php b/modules-available/locations/inc/location.inc.php
index 8b2ef262..e3fd35b7 100644
--- a/modules-available/locations/inc/location.inc.php
+++ b/modules-available/locations/inc/location.inc.php
@@ -285,29 +285,28 @@ class Location
{
$locationId = false;
$ipLoc = self::getFromIp($ip);
- if ($ipLoc !== false && $uuid !== false) {
- // Machine ip maps to a location, and we have a client supplied uuid
- $uuidLoc = self::getFromMachineUuid($uuid);
- if ($uuidLoc === $ipLoc) {
- $locationId = $uuidLoc;
- } else if ($uuidLoc !== false) {
- // Validate that the location the IP maps to is in the chain we get using the
- // location determined by the uuid
- $uuidLocations = self::getLocationRootChain($uuidLoc);
- $ipLocations = self::getLocationRootChain($ipLoc);
- if (in_array($uuidLoc, $ipLocations) // UUID loc is further up, OK
- || (in_array($ipLoc, $uuidLocations) && count($ipLocations) + 1 >= count($uuidLocations)) // UUID is max one level deeper than IP loc, accept as well
- ) {
- // Close enough, allow
+ if ($ipLoc !== false) {
+ // Set locationId to ipLoc for now, it will be overwritten later if another case applies.
+ $locationId = $ipLoc;
+ if ($uuid !== false) {
+ // Machine ip maps to a location, and we have a client supplied uuid (which might not be known if the client boots for the first time)
+ $uuidLoc = self::getFromMachineUuid($uuid);
+ if ($uuidLoc === $ipLoc) {
$locationId = $uuidLoc;
- } else {
+ } else if ($uuidLoc !== false) {
+ // Validate that the location the IP maps to is in the chain we get using the
+ // location determined by the uuid
+ $uuidLocations = self::getLocationRootChain($uuidLoc);
+ $ipLocations = self::getLocationRootChain($ipLoc);
+ if (in_array($uuidLoc, $ipLocations) // UUID loc is further up, OK
+ || (in_array($ipLoc, $uuidLocations) && count($ipLocations) + 1 >= count($uuidLocations)) // UUID is max one level deeper than IP loc, accept as well
+ ) {
+ // Close enough, allow
+ $locationId = $uuidLoc;
+ }
// UUID and IP disagree too much, play safe and ignore the UUID
- $locationId = $ipLoc;
}
}
- } else if ($ipLoc !== false) {
- // No uuid, but ip maps to location; use that
- $locationId = $ipLoc;
}
return $locationId;
}