Skip to content

Commit

Permalink
Don't throw if open_basedir is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebraNorth committed Dec 11, 2024
1 parent 4a021fb commit 9ad8607
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/SDK/Resource/Detectors/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ private function getLinuxId(): ?string

foreach ($paths as $path) {
$file = $this->dir . $path;
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);

return $contents !== false ? trim($contents) : null;
try {
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);

return $contents !== false ? trim($contents) : null;
}
} catch (ErrorException $ex) {

Check failure on line 62 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

UndefinedClass

src/SDK/Resource/Detectors/Host.php:62:22: UndefinedClass: Class, interface or enum named OpenTelemetry\SDK\Resource\Detectors\ErrorException does not exist (see https://psalm.dev/019)

Check failure on line 62 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

Caught class OpenTelemetry\SDK\Resource\Detectors\ErrorException not found.

Check warning on line 62 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

OpenTelemetry\SDK\Resource\Detectors\Host has uncovered dependency on OpenTelemetry\SDK\Resource\Detectors\ErrorException (SDK)
// This may occur if open_basedir is enabled.
}
}

Expand All @@ -66,10 +70,14 @@ private function getLinuxId(): ?string
private function getBsdId(): ?string
{
$file = $this->dir . self::PATH_ETC_HOSTID;
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);
try {
if (is_file($file) && is_readable($file)) {
$contents = file_get_contents($file);

return $contents !== false ? trim($contents) : null;
return $contents !== false ? trim($contents) : null;
}
} catch (ErrorException $ex) {

Check failure on line 79 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

UndefinedClass

src/SDK/Resource/Detectors/Host.php:79:18: UndefinedClass: Class, interface or enum named OpenTelemetry\SDK\Resource\Detectors\ErrorException does not exist (see https://psalm.dev/019)

Check failure on line 79 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

Caught class OpenTelemetry\SDK\Resource\Detectors\ErrorException not found.

Check warning on line 79 in src/SDK/Resource/Detectors/Host.php

View workflow job for this annotation

GitHub Actions / php (8.5, true, --ignore-platform-reqs)

OpenTelemetry\SDK\Resource\Detectors\Host has uncovered dependency on OpenTelemetry\SDK\Resource\Detectors\ErrorException (SDK)
// This may occur if open_basedir is enabled.
}

$out = exec('which kenv && kenv -q smbios.system.uuid');
Expand Down

0 comments on commit 9ad8607

Please sign in to comment.