aboutsummaryrefslogtreecommitdiff
path: root/modules/computer/os.c
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2017-07-06 14:30:50 -0500
committerLeandro Pereira <leandro@hardinfo.org>2017-07-09 11:54:46 -0700
commit889fc87a59f1814cd56c0d18a5b5e04a0ea09be5 (patch)
tree9d1d3961d81c2486d463ff2ae51497370751780f /modules/computer/os.c
parent217f76dc404d9d7fc4fcf40694e6db18fbfd67fb (diff)
OS: Improve C library detection
Based on a patch from Ubuntu/Debian.
Diffstat (limited to 'modules/computer/os.c')
-rw-r--r--modules/computer/os.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/modules/computer/os.c b/modules/computer/os.c
index 3caf6c26..264f718a 100644
--- a/modules/computer/os.c
+++ b/modules/computer/os.c
@@ -25,40 +25,40 @@ static gchar *
get_libc_version(void)
{
FILE *libc;
- gchar buf[256], *tmp, *p;
+ gchar buf[256], *tmp, *p, *ret = NULL;
char *libc_paths[] = {
- "/lib/ld-uClibc.so.0", "/lib64/ld-uClibc.so.0",
- "/lib/libc.so.6", "/lib64/libc.so.6"
- };
- int i;
-
- for (i=0; i < 4; i++) {
- if (g_file_test(libc_paths[i], G_FILE_TEST_EXISTS)) break;
- }
- switch (i) {
- case 0: case 1: return g_strdup("uClibc Library");
- case 2: case 3: break; // gnu libc, continue processing
- default: goto err;
- }
-
- libc = popen(libc_paths[i], "r");
- if (!libc) goto err;
-
- (void)fgets(buf, 256, libc);
- if (pclose(libc)) goto err;
-
- tmp = strstr(buf, "version ");
- if (!tmp) goto err;
+ "/lib/ld-uClibc.so.0", "/lib64/ld-uClibc.so.0",
+ "/lib/libc.so.6", "/lib64/libc.so.6", "/lib/x86_64-linux-gnu/libc.so.6",
+ };
+ int i;
- p = strchr(tmp, ',');
- if (p) *p = '\0';
- else goto err;
+ for (i=0; i < 4; i++) {
+ if (g_file_test(libc_paths[i], G_FILE_TEST_EXISTS)) break;
+ }
+ switch (i) {
+ case 0: case 1:
+ ret = g_strdup("uClibc Library");
+ break;
+ case 2: case 3: case 4:
+ ret = g_strdup("GNU C Library (GLIBC)");
+ /* fall through and try to do better */
+ default:
+ memset(buf, 0, 256);
+ libc = popen("ldconfig -V", "r");
+ if (!libc) goto err;
+ (void)fgets(buf, 255, libc);
+ if (pclose(libc)) goto err;
+ tmp = strstr(buf, " ");
+ if (!tmp) goto err;
+ p = strstr(buf, "\n");
+ if (p) *p = 0;
+ g_free(ret);
+ ret = g_strdup_printf("%s", tmp + 1);
+ break;
+ }
- return g_strdup_printf(_("GNU C Library version %s (%sstable)"),
- strchr(tmp, ' ') + 1,
- strstr(buf, " stable ") ? "" : _("un"));
- err:
- return g_strdup(_("Unknown"));
+err:
+ return (ret) ? ret : g_strdup(_("Unknown"));
}
#include <gdk/gdkx.h>
@@ -109,7 +109,7 @@ detect_desktop_environment(OperatingSystem * os)
} else {
unknown:
os->desktop = NULL;
-
+
if (!g_getenv("DISPLAY")) {
os->desktop = g_strdup(_("Terminal"));
} else {