Index: /trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp
===================================================================
--- /trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp	(revision 87600)
+++ /trunk/src/VBox/NetworkServices/NAT/VBoxNetLwipNAT.cpp	(revision 87601)
@@ -131,4 +131,7 @@
     friend class NATNetworkListener;
 
+    /** Home folder location; used as default directory for several paths. */
+    com::Utf8Str m_strHome;
+
     struct proxy_options m_ProxyOptions;
     struct sockaddr_in m_src4;
@@ -172,4 +175,5 @@
 private:
     int comInit();
+    int homeInit();
     int logInit();
 
@@ -328,4 +332,7 @@
         return rc;
 
+    /* Get the home folder location.  It's ok if it fails. */
+    homeInit();
+
     /*
      * We get the network name on the command line.  Get hold of its
@@ -474,11 +481,9 @@
     }
 
-    com::Bstr bstr;
-    hrc = virtualbox->COMGETTER(HomeFolder)(bstr.asOutParam());
-    AssertComRCReturn(hrc, VERR_NOT_FOUND);
-    if (!bstr.isEmpty())
-    {
-        com::Utf8Str strTftpRoot(com::Utf8StrFmt("%ls%c%s",
-                                     bstr.raw(), RTPATH_DELIMITER, "TFTP"));
+
+    if (m_strHome.isNotEmpty())
+    {
+        com::Utf8Str strTftpRoot(com::Utf8StrFmt("%s%c%s",
+                                     m_strHome.c_str(), RTPATH_DELIMITER, "TFTP"));
         char *pszStrTemp;       // avoid const char ** vs char **
         rc = RTStrUtf8ToCurrentCP(&pszStrTemp, strTftpRoot.c_str());
@@ -556,4 +561,40 @@
 
     return VINF_SUCCESS;
+}
+
+
+/**
+ * Get the VirtualBox home folder.
+ *
+ * It is used as the base directory for the default release log file
+ * and for the TFTP root location.
+ */
+int VBoxNetLwipNAT::homeInit()
+{
+    HRESULT hrc;
+    int rc;
+
+    com::Bstr bstrHome;
+    hrc = virtualbox->COMGETTER(HomeFolder)(bstrHome.asOutParam());
+    if (SUCCEEDED(hrc))
+    {
+        m_strHome = bstrHome;
+        return VINF_SUCCESS;
+    }
+
+    /*
+     * In the unlikely event that we have failed to retrieve
+     * HomeFolder via the API, try the fallback method.  Note that
+     * despite "com" namespace it does not use COM.
+     */
+    char szHome[RTPATH_MAX] = "";
+    rc = com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome), false);
+    if (RT_SUCCESS(rc))
+    {
+        m_strHome = szHome;
+        return VINF_SUCCESS;
+    }
+
+    return rc;
 }
 
@@ -1526,15 +1567,4 @@
     int rc;
 
-    /*
-     * NB: Contrary to what the "com" namespace might suggest, both
-     * this call, and the call below to create the release logger are
-     * NOT actually COM related in any way and can be used before COM
-     * is initialized.
-     */
-    char szHome[RTPATH_MAX];
-    rc = com::GetVBoxUserHomeDirectory(szHome, sizeof(szHome), false);
-    if (RT_FAILURE(rc))
-        return rc;
-
     const std::string &strNetworkName = getNetworkName();
     if (strNetworkName.empty())
@@ -1553,10 +1583,12 @@
     }
 
+    const char *pcszLogFile = NULL;
     char szLogFile[RTPATH_MAX];
-    cch = RTStrPrintf(szLogFile, sizeof(szLogFile),
-                      "%s%c%s.log", szHome, RTPATH_DELIMITER, szNetwork);
-    if (cch >= sizeof(szLogFile))
-    {
-        return VERR_BUFFER_OVERFLOW;
+    if (m_strHome.isNotEmpty())
+    {
+        cch = RTStrPrintf(szLogFile, sizeof(szLogFile),
+                          "%s%c%s.log", m_strHome.c_str(), RTPATH_DELIMITER, szNetwork);
+        if (cch < sizeof(szLogFile))
+            pcszLogFile = szLogFile;
     }
 
@@ -1574,14 +1606,15 @@
 
     char szEnvVarBase[128];
+    const char *pcszEnvVarBase = szEnvVarBase;
     cch = RTStrPrintf(szEnvVarBase, sizeof(szEnvVarBase),
                       "VBOXNET_%s_RELEASE_LOG", szNetwork);
     if (cch >= sizeof(szEnvVarBase))
-        return VERR_BUFFER_OVERFLOW;
+        pcszEnvVarBase = NULL;
 
     rc = com::VBoxLogRelCreate("NAT Network",
-                               szLogFile,
+                               pcszLogFile,
                                RTLOGFLAGS_PREFIX_TIME_PROG,
                                "all all.restrict -default.restrict",
-                               szEnvVarBase,
+                               pcszEnvVarBase,
                                RTLOGDEST_FILE,
                                32768 /* cMaxEntriesPerGroup */,
