File 0001-handle-HOME-not-being-set.patch of Package icecream

From 6f79da339b3fd946b46932d61f30a117918de7b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <l.lunak@suse.cz>
Date: Tue, 16 Jul 2013 15:46:06 +0200
Subject: [PATCH] handle $HOME not being set

---
 client/main.cpp |  2 +-
 daemon/main.cpp | 11 ++++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/client/main.cpp b/client/main.cpp
index d72ce9d..638dbda 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -335,7 +335,7 @@ int main(int argc, char **argv)
     if (!local_daemon)
         local_daemon = Service::createChannel( "/var/run/iceccd.socket" );
 
-    if (!local_daemon) {
+    if (!local_daemon && getenv("HOME")) {
         string path = getenv("HOME");
         path += "/.iceccd.socket";
         local_daemon = Service::createChannel( path );
diff --git a/daemon/main.cpp b/daemon/main.cpp
index 28ec158..5d7e430 100644
--- a/daemon/main.cpp
+++ b/daemon/main.cpp
@@ -553,9 +553,14 @@ bool Daemon::setup_listen_fds()
         unlink(myaddr.sun_path);
         old_umask = umask(0);
     } else { // Started by user.
-        strncpy(myaddr.sun_path, getenv("HOME"), sizeof(myaddr.sun_path)-1);
-        strncat(myaddr.sun_path, "/.iceccd.socket", sizeof(myaddr.sun_path)-1-strlen(myaddr.sun_path));
-        unlink(myaddr.sun_path);
+        if( getenv( "HOME" )) {
+            strncpy(myaddr.sun_path, getenv("HOME"), sizeof(myaddr.sun_path)-1);
+            strncat(myaddr.sun_path, "/.iceccd.socket", sizeof(myaddr.sun_path)-1-strlen(myaddr.sun_path));
+            unlink(myaddr.sun_path);
+        } else {
+            log_error() << "launched by user, but $HOME not set" << endl;
+            return false;
+        }
     }
 
     if (bind(unix_listen_fd, (struct sockaddr*)&myaddr, sizeof(myaddr)) < 0) {
-- 
1.8.1.4