daemon: Don't abort when $PATH is undefined.
authorLudovic Courtès <ludo@gnu.org>
Wed, 9 Apr 2014 21:05:42 +0000 (23:05 +0200)
committerLudovic Courtès <ludo@gnu.org>
Wed, 9 Apr 2014 21:05:42 +0000 (23:05 +0200)
* nix/nix-daemon/guix-daemon.cc (main): Check whether getenv ("PATH")
  returns NULL before blindly initializing 'search_path'.  Before that
  'guix-daemon' would abort when run in an environment where 'PATH' is
  undefined.

nix/nix-daemon/guix-daemon.cc

index 7181516..0bb9f75 100644 (file)
@@ -257,8 +257,14 @@ main (int argc, char *argv[])
 
       /* Hackily help 'local-store.cc' find our 'guix-authenticate' program, which
         is known as 'OPENSSL_PATH' here.  */
-      std::string search_path (getenv ("PATH"));
-      search_path = settings.nixLibexecDir + ":" + search_path;
+      std::string search_path;
+      search_path = settings.nixLibexecDir;
+      if (getenv ("PATH") != NULL)
+       {
+         search_path += ":";
+         search_path += getenv ("PATH");
+       }
+
       setenv ("PATH", search_path.c_str (), 1);
 
       /* Use our substituter by default.  */