Skip to content

Commit cafe146

Browse files
committed
Add documented fallback
1 parent ef59a2b commit cafe146

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/sentry_os.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,21 @@ sentry__get_os_context(void)
334334
sentry_value_set_by_key(
335335
os, "version", sentry_value_new_string(uts.release));
336336

337+
/**
338+
* The file /etc/os-release takes precedence over /usr/lib/os-release.
339+
* Applications should check for the former, and exclusively use its data if
340+
* it exists, and only fall back to /usr/lib/os-release if it is missing.
341+
* Applications should not read data from both files at the same time.
342+
*
343+
* From: https://www.freedesktop.org/software/systemd/man/latest/os-release.html#Description
344+
*/
337345
sentry_value_t os_dist = get_linux_os_release("/etc/os-release");
338-
if (!sentry_value_is_null(os_dist)) {
346+
if (sentry_value_is_null(os_dist)) {
347+
os_dist = get_linux_os_release("/usr/lib/os-release");
348+
if (sentry_value_is_null(os_dist)) {
349+
sentry_value_set_by_key(os, "distribution", os_dist);
350+
}
351+
} else {
339352
sentry_value_set_by_key(os, "distribution", os_dist);
340353
}
341354

0 commit comments

Comments
 (0)