tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsis-no-underscore.patch (1460B)


      1 The `_` environment variable is a variable that is set by bash and some other
      2 shells to point to the executable they use when executing a command. That is,
      3 when executing `foo` from the command line, the shell sets `_` to
      4 `/usr/bin/foo` (assuming that's where foo is).
      5 
      6 However, nothing else does the same, so when e.g. a python program uses
      7 `subprocess.Popen` to run another program, it doesn't set `_`. Worse, if that
      8 python program itself was invoked from a shell, `_` would be set to e.g.
      9 `/usr/bin/python3`.
     10 
     11 So when nsis is invoked from a program that is not a shell, but the process
     12 ancestry has a process that was a shell, `_` may be set to the first
     13 intermediary program rather than nsis, which defeats nsis's assumption that `_`
     14 would contain the nsis path. Ironically, nsis also has more reliable fallbacks
     15 (using e.g.  /proc/self/exe), but somehow prefers `_`.
     16 
     17 We remove the reliance of `_` entirely, for simplicity's sake.
     18 
     19 
     20 diff -ruN nsis-3.07-src.orig/Source/util.cpp nsis-3.07-src/Source/util.cpp
     21 --- nsis-3.07-src.orig/Source/util.cpp	2021-09-02 09:25:48.489016918 +0900
     22 +++ nsis-3.07-src/Source/util.cpp	2021-09-02 09:26:21.158814484 +0900
     23 @@ -810,10 +810,7 @@
     24   assert(rc == 0);
     25   return tstring(CtoTString(temp_buf));
     26 #else /* Linux/BSD/POSIX/etc */
     27 -  const TCHAR *envpath = _tgetenv(_T("_"));
     28 -  if (envpath)
     29 -    return get_full_path(envpath);
     30 -  else {
     31 +  {
     32     char *path = NULL, *pathtmp;
     33     size_t len = 100;
     34     int nchars;