aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-09-01 20:56:54 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-09-01 20:56:54 +0200
commit8d3fa82d8246a08d2c7899963ad7cf61b7a4563c (patch)
treea15c744045369d5594e3520775bd178a39aea386
parent0c381fa2cb5d45f550817a78a00eb993bbe7005f (diff)
downloadmblaze-8d3fa82d8246a08d2c7899963ad7cf61b7a4563c.tar.gz
seq: blaze822_home_file: guard missing entry in /etc/passwd or empty $HOME
-rw-r--r--seq.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/seq.c b/seq.c
index 75f9e3c..159c81c 100644
--- a/seq.c
+++ b/seq.c
@@ -24,8 +24,15 @@ blaze822_home_file(char *basename)
if (!homedir)
homedir = getenv("HOME");
+ if (homedir && !*homedir)
+ homedir = 0;
+ if (!homedir) {
+ struct passwd *pw = getpwuid(getuid());
+ if (pw)
+ homedir = pw->pw_dir;
+ }
if (!homedir)
- homedir = getpwuid(getuid())->pw_dir;
+ return "/dev/null/homeless";
snprintf(path, sizeof path, "%s/%s", homedir, basename);