summaryrefslogtreecommitdiffstats
path: root/pcp/PCPDynamicColumn.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2022-08-14 19:58:03 +0200
committerBenBE <BenBE@geshi.org>2022-08-22 21:32:49 +0200
commit62d59403d92abaf256604bfc17e76c85ce64ea35 (patch)
treed863afd15fb7c091d826907f9b310803a6035e7f /pcp/PCPDynamicColumn.c
parent5aa207f9af6622583fd60edebaef1c3ed19ab91d (diff)
Add fallback for HOME environment variable
If the environment variable HOME is not set, try to get the home directory from the systems password database.
Diffstat (limited to 'pcp/PCPDynamicColumn.c')
-rw-r--r--pcp/PCPDynamicColumn.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/pcp/PCPDynamicColumn.c b/pcp/PCPDynamicColumn.c
index aab25253..33c6d72a 100644
--- a/pcp/PCPDynamicColumn.c
+++ b/pcp/PCPDynamicColumn.c
@@ -14,6 +14,7 @@ in the source distribution for its full text.
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
+#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -194,6 +195,12 @@ void PCPDynamicColumns_init(PCPDynamicColumns* columns) {
const char* home = getenv("HOME");
char* path;
+ if (!xdgConfigHome && !home) {
+ const struct passwd* pw = getpwuid(getuid());
+ if (pw)
+ home = pw->pw_dir;
+ }
+
columns->table = Hashtable_new(0, true);
/* developer paths - PCP_HTOP_DIR=./pcp ./pcp-htop */

© 2014-2024 Faster IT GmbH | imprint | privacy policy