Ticket #13398: 0001-Bug-13398-at-startup-browser-gleans-user-FULL-NAME-r.patch

File 0001-Bug-13398-at-startup-browser-gleans-user-FULL-NAME-r.patch, 7.0 KB (added by pospeselr, 21 months ago)

Properly formatted patch, no code changes

  • toolkit/components/startup/nsUserInfoMac.mm

    From b993a9669b66b43523be31b122cdcc464c891972 Mon Sep 17 00:00:00 2001
    From: Richard Pospesel <richard@torproject.org>
    Date: Fri, 29 Sep 2017 15:35:31 -0700
    Subject: [PATCH] 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 b NS_IMETHODIMP 
    1919nsUserInfo::GetFullname(char16_t **aFullname)
    2020{
    2121  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    22  
     22#ifndef TOR_BROWSER_VERSION
    2323  NS_ConvertUTF8toUTF16 fullName([NSFullUserName() UTF8String]);
    2424  *aFullname = ToNewUnicode(fullName);
    2525  return NS_OK;
    26  
     26#else
     27  *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
     28  return *aFullname ? NS_OK : NS_ERROR_FAILURE;
     29#endif
    2730  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    2831}
    2932
    NS_IMETHODIMP 
    3134nsUserInfo::GetUsername(char **aUsername)
    3235{
    3336  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT
    34  
     37#ifndef TOR_BROWSER_VERSION
    3538  nsAutoCString username([NSUserName() UTF8String]);
    3639  *aUsername = ToNewCString(username);
    3740  return NS_OK;
    38  
     41#else
     42  *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
     43  return *aUsername ? NS_OK : NS_ERROR_FAILURE;
     44#endif
    3945  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT
    4046}
    4147
    nsUserInfo::GetPrimaryEmailAddress(nsCString &aEmailAddress) 
    6369NS_IMETHODIMP
    6470nsUserInfo::GetEmailAddress(char **aEmailAddress)
    6571{
     72#ifndef TOR_BROWSER_VERSION
    6673  nsAutoCString email;
    6774  if (NS_SUCCEEDED(GetPrimaryEmailAddress(email)))
    6875    *aEmailAddress = ToNewCString(email);
    6976  return NS_OK;
     77#else
     78  *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
     79  return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
     80#endif
    7081}
    7182
    7283NS_IMETHODIMP
    7384nsUserInfo::GetDomain(char **aDomain)
    7485{
     86#ifndef TOR_BROWSER_VERSION
    7587  nsAutoCString email;
    7688  if (NS_SUCCEEDED(GetPrimaryEmailAddress(email))) {
    7789    int32_t index = email.FindChar('@');
    nsUserInfo::GetDomain(char **aDomain) 
    8193    }
    8294  }
    8395  return NS_OK;
     96#else
     97  *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
     98  return *aDomain ? NS_OK : NS_ERROR_FAILURE;
     99#endif
    84100}
  • toolkit/components/startup/nsUserInfoUnix.cpp

    diff --git a/toolkit/components/startup/nsUserInfoUnix.cpp b/toolkit/components/startup/nsUserInfoUnix.cpp
    index 71bc46da2573..6c8b35443139 100644
    a b NS_IMPL_ISUPPORTS(nsUserInfo,nsIUserInfo) 
    3636NS_IMETHODIMP
    3737nsUserInfo::GetFullname(char16_t **aFullname)
    3838{
     39#ifndef TOR_BROWSER_VERSION
    3940    struct passwd *pw = nullptr;
    4041
    4142    pw = getpwuid (geteuid());
    nsUserInfo::GetFullname(char16_t **aFullname) 
    7677        return NS_OK;
    7778
    7879    return NS_ERROR_FAILURE;
     80#else
     81    *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
     82    return *aFullname ? NS_OK : NS_ERROR_FAILURE;
     83#endif
    7984}
    8085
    8186NS_IMETHODIMP
    8287nsUserInfo::GetUsername(char * *aUsername)
    8388{
     89#ifndef TOR_BROWSER_VERSION
    8490    struct passwd *pw = nullptr;
    8591
    8692    // is this portable?  those are POSIX compliant calls, but I need to check
    nsUserInfo::GetUsername(char * *aUsername) 
    95101    *aUsername = strdup(pw->pw_name);
    96102
    97103    return NS_OK;
     104#else
     105    *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
     106    return *aUsername ? NS_OK : NS_ERROR_FAILURE;
     107#endif
    98108}
    99109
    100110NS_IMETHODIMP
    101111nsUserInfo::GetDomain(char * *aDomain)
    102112{
     113#ifndef TOR_BROWSER_VERSION
    103114    nsresult rv = NS_ERROR_FAILURE;
    104115
    105116    struct utsname buf;
    nsUserInfo::GetDomain(char * *aDomain) 
    132143    }
    133144   
    134145    return rv;
     146#else
     147    *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
     148    return *aDomain ? NS_OK : NS_ERROR_FAILURE;
     149#endif
    135150}
    136151
    137152NS_IMETHODIMP
    138153nsUserInfo::GetEmailAddress(char * *aEmailAddress)
    139154{
     155#ifndef TOR_BROWSER_VERSION
    140156    // use username + "@" + domain for the email address
    141157
    142158    nsresult rv;
    nsUserInfo::GetEmailAddress(char * *aEmailAddress) 
    163179    *aEmailAddress = ToNewCString(emailAddress);
    164180   
    165181    return NS_OK;
     182#else
     183    *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
     184    return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
     185#endif
    166186}
    167187
  • toolkit/components/startup/nsUserInfoWin.cpp

    diff --git a/toolkit/components/startup/nsUserInfoWin.cpp b/toolkit/components/startup/nsUserInfoWin.cpp
    index b27a2c483b1c..04552d7310f9 100644
    a b nsUserInfo::GetUsername(char **aUsername) 
    3030{
    3131  NS_ENSURE_ARG_POINTER(aUsername);
    3232  *aUsername = nullptr;
     33#ifndef TOR_BROWSER_VERSION
    3334
    3435  // ULEN is the max username length as defined in lmcons.h
    3536  wchar_t username[UNLEN +1];
    nsUserInfo::GetUsername(char **aUsername) 
    3940
    4041  *aUsername = ToNewUTF8String(nsDependentString(username));
    4142  return (*aUsername) ? NS_OK : NS_ERROR_FAILURE;
     43#else
     44  *aUsername = ToNewUTF8String(NS_LITERAL_STRING(""));
     45  return *aUsername ? NS_OK : NS_ERROR_FAILURE;
     46#endif
    4247}
    4348
    4449NS_IMETHODIMP
    nsUserInfo::GetFullname(char16_t **aFullname) 
    4651{
    4752  NS_ENSURE_ARG_POINTER(aFullname);
    4853  *aFullname = nullptr;
     54#ifndef TOR_BROWSER_VERSION
    4955
    5056  wchar_t fullName[512];
    5157  DWORD size = mozilla::ArrayLength(fullName);
    nsUserInfo::GetFullname(char16_t **aFullname) 
    9197  }
    9298
    9399  return (*aFullname) ? NS_OK : NS_ERROR_FAILURE;
     100#else
     101  *aFullname = ToNewUnicode(NS_LITERAL_STRING(""));
     102  return *aFullname ? NS_OK : NS_ERROR_FAILURE;
     103#endif
    94104}
    95105
    96106NS_IMETHODIMP
    nsUserInfo::GetDomain(char **aDomain) 
    98108{
    99109  NS_ENSURE_ARG_POINTER(aDomain);
    100110  *aDomain = nullptr;
    101 
     111#ifndef TOR_BROWSER_VERSION
    102112  const DWORD level = 100;
    103113  LPBYTE info;
    104114  NET_API_STATUS status = NetWkstaGetInfo(nullptr, level, &info);
    nsUserInfo::GetDomain(char **aDomain) 
    110120  }
    111121
    112122  return (*aDomain) ? NS_OK : NS_ERROR_FAILURE;
     123#else
     124  *aDomain = ToNewUTF8String(NS_LITERAL_STRING(""));
     125  return *aDomain ? NS_OK : NS_ERROR_FAILURE;
     126#endif
    113127}
    114128
    115129NS_IMETHODIMP
    nsUserInfo::GetEmailAddress(char **aEmailAddress) 
    117131{
    118132  NS_ENSURE_ARG_POINTER(aEmailAddress);
    119133  *aEmailAddress = nullptr;
    120 
     134#ifndef TOR_BROWSER_VERSION
    121135  // RFC3696 says max length of an email address is 254
    122136  wchar_t emailAddress[255];
    123137  DWORD size = mozilla::ArrayLength(emailAddress);
    nsUserInfo::GetEmailAddress(char **aEmailAddress) 
    130144
    131145  *aEmailAddress = ToNewUTF8String(nsDependentString(emailAddress));
    132146  return (*aEmailAddress) ? NS_OK : NS_ERROR_FAILURE;
     147#else
     148  *aEmailAddress = ToNewUTF8String(NS_LITERAL_STRING(""));
     149  return *aEmailAddress ? NS_OK : NS_ERROR_FAILURE;
     150#endif
    133151}