Skip to content

Commit a2919f5

Browse files
committed
OS (Linux): acquire more os info from lsb-release if missing from os-release
Fix #1521
1 parent 680978b commit a2919f5

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/detection/os/os_linux.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@
1111
#define FF_STR_INDIR(x) #x
1212
#define FF_STR(x) FF_STR_INDIR(x)
1313

14-
static inline bool allRelevantValuesSet(const FFOSResult* result)
15-
{
16-
return result->id.length > 0
17-
&& result->name.length > 0
18-
&& result->prettyName.length > 0
19-
;
20-
}
21-
2214
static bool parseLsbRelease(const char* fileName, FFOSResult* result)
2315
{
2416
return ffParsePropFileValues(fileName, 4, (FFpropquery[]) {
@@ -275,18 +267,17 @@ static void detectOS(FFOSResult* os)
275267
if(os->prettyName.length == 0)
276268
ffStrbufAppendS(&os->prettyName, "Bedrock Linux");
277269

278-
if(parseOsRelease("/bedrock" FASTFETCH_TARGET_DIR_ETC "/os-release", os) && allRelevantValuesSet(os))
279-
return;
270+
parseOsRelease("/bedrock" FASTFETCH_TARGET_DIR_ETC "/os-release", os);
271+
return;
280272
}
281273

282274
// Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff
283275

284-
if((parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os) ||
285-
parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os)) &&
286-
allRelevantValuesSet(os))
287-
return;
288-
289-
parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os);
276+
parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os);
277+
if (os->id.length == 0 || os->version.length == 0 || os->prettyName.length == 0 || os->codename.length == 0)
278+
parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os);
279+
if (os->id.length == 0 || os->name.length > 0 || os->prettyName.length > 0)
280+
parseOsRelease(FASTFETCH_TARGET_DIR_USR "/lib/os-release", os);
290281
}
291282

292283
void ffDetectOSImpl(FFOSResult* os)

0 commit comments

Comments
 (0)