@@ -77,7 +77,11 @@ public function getLinuxDistribution(): string
77
77
private function getFromEtcRelease (): string
78
78
{
79
79
$ file = $ this ->rootFolder . '/etc/*-release ' ;
80
- foreach (glob ($ file ) as $ path ) {
80
+ $ filesFound = glob ($ file );
81
+ if (!$ filesFound ) {
82
+ return '' ;
83
+ }
84
+ foreach ($ filesFound as $ path ) {
81
85
$ content = file_get_contents ($ path );
82
86
preg_match ('/^ID=(?<version>.*)$/m ' , $ content , $ matches );
83
87
if (isset ($ matches ['version ' ])) {
@@ -102,26 +106,36 @@ public function getFromLsbRelease(): string
102
106
103
107
private function isDebian (): string
104
108
{
105
- if (file_exists ($ this ->rootFolder . '/etc/debian_version ' )) {
106
- return 'Debian ' ;
109
+ if ($ this ->isInOpenBasedir ($ this ->rootFolder . '/etc/debian_version ' )) {
110
+ if (file_exists ($ this ->rootFolder . '/etc/debian_version ' )) {
111
+ return 'Debian ' ;
112
+ }
107
113
}
108
- if (!$ this ->runSafe ('type apt 2>/dev/null >/dev/null & ' )) {
114
+ if (!$ this ->runSafe ('type apt ' )) {
109
115
return '' ;
110
116
}
111
117
return 'Debian ' ;
112
118
}
113
119
114
120
private function isAlpine (): string
115
121
{
116
- if (!$ this ->runSafe ('type apk 2>/dev/null >/dev/null & ' )) {
122
+ if (!$ this ->runSafe ('type apk ' )) {
117
123
return '' ;
118
124
}
119
125
return 'Alpine ' ;
120
126
}
121
127
122
128
private function runSafe (string $ command ): string
123
129
{
124
- $ output = shell_exec ($ command . ' 2>/dev/null >/dev/null & ' );
130
+ $ output = shell_exec ($ command . ' 2>/dev/null ' );
125
131
return (string ) $ output ;
126
132
}
133
+
134
+ private function isInOpenBasedir (string $ path ): bool {
135
+ $ openBasedir = ini_get ('open_basedir ' );
136
+ if (empty ($ openBasedir ) || strpos ($ openBasedir , $ path ) !== false ) {
137
+ return true ;
138
+ }
139
+ return false ;
140
+ }
127
141
}
0 commit comments