[tbb-commits] [tor-browser/tor-browser-52.4.0esr-7.5-1] Bug 13398: at startup, browser gleans user FULL NAME (real name, given name) from O/S

gk at torproject.org gk at torproject.org
Wed Oct 4 09:25:24 UTC 2017


commit e3b99866dbdc29a2949d0a53806b99a94f34cc73
Author: Richard Pospesel <richard at torproject.org>
Date:   Fri Sep 29 15:35:31 2017 -0700

    Bug 13398: at startup, browser gleans user FULL NAME (real name, given name) from O/S
    
    ifdef'd out offending code in each platform based on existance of
    TOR_BROWSER_VERSION and return empty string instead.
---
 toolkit/components/startup/nsUserInfoMac.mm   | 24 ++++++++++++++++++++----
 toolkit/components/startup/nsUserInfoUnix.cpp | 20 ++++++++++++++++++++
 toolkit/components/startup/nsUserInfoWin.cpp  | 22 ++++++++++++++++++++--
 3 files changed, 60 insertions(+), 6 deletions(-)

diff --git a/toolkit/components/startup/nsUserInfoMac.mm b/toolkit/components/startup/nsUserInfoMac.mm
index 1895cf177353..175e9637c422 100644
--- a/toolkit/components/startup/nsUserInfoMac.mm
+++ b/toolkit/components/startup/nsUserInfoMac.mm
@@ -19,11 +19,14 @@ NS_IMETHODIMP
 nsUserInfo::GetFullname(char16_t **aFullname)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
-  
+#ifndef TOR_BROWSER_VERSION
   NS_ConvertUTF8toUTF16 fullName([NSFullUserName() UTF8String]);
   *aFullname = ToNewUnicode(fullName);
   return NS_OK;
-  
+#else
+  *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
+  return *aFullname ? NS_OK : NS_ERROR_FAILURE;
+#endif
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
 }
 
@@ -31,11 +34,14 @@ NS_IMETHODIMP
 nsUserInfo::GetUsername(char **aUsername)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
-  
+#ifndef TOR_BROWSER_VERSION
   nsAutoCString username([NSUserName() UTF8String]);
   *aUsername = ToNewCString(username);
   return NS_OK;
-  
+#else
+  *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
+  return *aUsername ? NS_OK : NS_ERROR_FAILURE;
+#endif
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
 }
 
@@ -63,15 +69,21 @@ nsUserInfo::GetPrimaryEmailAddress(nsCString &aEmailAddress)
 NS_IMETHODIMP 
 nsUserInfo::GetEmailAddress(char **aEmailAddress)
 {
+#ifndef TOR_BROWSER_VERSION
   nsAutoCString email;
   if (NS_SUCCEEDED(GetPrimaryEmailAddress(email))) 
     *aEmailAddress = ToNewCString(email);
   return NS_OK;
+#else
+  *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
+  return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
 NS_IMETHODIMP 
 nsUserInfo::GetDomain(char **aDomain)
 {
+#ifndef TOR_BROWSER_VERSION
   nsAutoCString email;
   if (NS_SUCCEEDED(GetPrimaryEmailAddress(email))) {
     int32_t index = email.FindChar('@');
@@ -81,4 +93,8 @@ nsUserInfo::GetDomain(char **aDomain)
     }
   }
   return NS_OK;
+#else
+  *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
+  return *aDomain ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
diff --git a/toolkit/components/startup/nsUserInfoUnix.cpp b/toolkit/components/startup/nsUserInfoUnix.cpp
index 71bc46da2573..6c8b35443139 100644
--- a/toolkit/components/startup/nsUserInfoUnix.cpp
+++ b/toolkit/components/startup/nsUserInfoUnix.cpp
@@ -36,6 +36,7 @@ NS_IMPL_ISUPPORTS(nsUserInfo,nsIUserInfo)
 NS_IMETHODIMP
 nsUserInfo::GetFullname(char16_t **aFullname)
 {
+#ifndef TOR_BROWSER_VERSION
     struct passwd *pw = nullptr;
 
     pw = getpwuid (geteuid());
@@ -76,11 +77,16 @@ nsUserInfo::GetFullname(char16_t **aFullname)
         return NS_OK;
 
     return NS_ERROR_FAILURE;
+#else
+    *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
+    return *aFullname ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
 NS_IMETHODIMP 
 nsUserInfo::GetUsername(char * *aUsername)
 {
+#ifndef TOR_BROWSER_VERSION
     struct passwd *pw = nullptr;
 
     // is this portable?  those are POSIX compliant calls, but I need to check
@@ -95,11 +101,16 @@ nsUserInfo::GetUsername(char * *aUsername)
     *aUsername = strdup(pw->pw_name);
 
     return NS_OK;
+#else
+    *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
+    return *aUsername ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
 NS_IMETHODIMP 
 nsUserInfo::GetDomain(char * *aDomain)
 {
+#ifndef TOR_BROWSER_VERSION
     nsresult rv = NS_ERROR_FAILURE;
 
     struct utsname buf;
@@ -132,11 +143,16 @@ nsUserInfo::GetDomain(char * *aDomain)
     }
     
     return rv;
+#else
+    *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
+    return *aDomain ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
 NS_IMETHODIMP 
 nsUserInfo::GetEmailAddress(char * *aEmailAddress)
 {
+#ifndef TOR_BROWSER_VERSION
     // use username + "@" + domain for the email address
 
     nsresult rv;
@@ -163,5 +179,9 @@ nsUserInfo::GetEmailAddress(char * *aEmailAddress)
     *aEmailAddress = ToNewCString(emailAddress);
     
     return NS_OK;
+#else
+    *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
+    return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
diff --git a/toolkit/components/startup/nsUserInfoWin.cpp b/toolkit/components/startup/nsUserInfoWin.cpp
index b27a2c483b1c..04552d7310f9 100644
--- a/toolkit/components/startup/nsUserInfoWin.cpp
+++ b/toolkit/components/startup/nsUserInfoWin.cpp
@@ -30,6 +30,7 @@ nsUserInfo::GetUsername(char **aUsername)
 {
   NS_ENSURE_ARG_POINTER(aUsername);
   *aUsername = nullptr;
+#ifndef TOR_BROWSER_VERSION
 
   // ULEN is the max username length as defined in lmcons.h
   wchar_t username[UNLEN +1];
@@ -39,6 +40,10 @@ nsUserInfo::GetUsername(char **aUsername)
 
   *aUsername = ToNewUTF8String(nsDependentString(username));
   return (*aUsername) ? NS_OK : NS_ERROR_FAILURE;
+#else
+  *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
+  return *aUsername ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
 NS_IMETHODIMP
@@ -46,6 +51,7 @@ nsUserInfo::GetFullname(char16_t **aFullname)
 {
   NS_ENSURE_ARG_POINTER(aFullname);
   *aFullname = nullptr;
+#ifndef TOR_BROWSER_VERSION
 
   wchar_t fullName[512];
   DWORD size = mozilla::ArrayLength(fullName);
@@ -91,6 +97,10 @@ nsUserInfo::GetFullname(char16_t **aFullname)
   }
 
   return (*aFullname) ? NS_OK : NS_ERROR_FAILURE;
+#else
+  *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
+  return *aFullname ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
 NS_IMETHODIMP
@@ -98,7 +108,7 @@ nsUserInfo::GetDomain(char **aDomain)
 {
   NS_ENSURE_ARG_POINTER(aDomain);
   *aDomain = nullptr;
-
+#ifndef TOR_BROWSER_VERSION
   const DWORD level = 100;
   LPBYTE info;
   NET_API_STATUS status = NetWkstaGetInfo(nullptr, level, &info);
@@ -110,6 +120,10 @@ nsUserInfo::GetDomain(char **aDomain)
   }
 
   return (*aDomain) ? NS_OK : NS_ERROR_FAILURE;
+#else
+  *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
+  return *aDomain ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }
 
 NS_IMETHODIMP
@@ -117,7 +131,7 @@ nsUserInfo::GetEmailAddress(char **aEmailAddress)
 {
   NS_ENSURE_ARG_POINTER(aEmailAddress);
   *aEmailAddress = nullptr;
-
+#ifndef TOR_BROWSER_VERSION
   // RFC3696 says max length of an email address is 254
   wchar_t emailAddress[255];
   DWORD size = mozilla::ArrayLength(emailAddress);
@@ -130,4 +144,8 @@ nsUserInfo::GetEmailAddress(char **aEmailAddress)
 
   *aEmailAddress = ToNewUTF8String(nsDependentString(emailAddress));
   return (*aEmailAddress) ? NS_OK : NS_ERROR_FAILURE;
+#else
+  *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
+  return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
+#endif
 }



More information about the tbb-commits mailing list