Bug 268245 - [NEW PORT] www/tor-browser - native port for FreeBSD
Summary: [NEW PORT] www/tor-browser - native port for FreeBSD
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Jesper Schmitz Mouridsen
URL: https://www.torproject.org/download/
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-08 15:24 UTC by Martin Filla
Modified: 2023-02-12 15:35 UTC (History)
4 users (show)

See Also:


Attachments
tor-browser.shar.tar.gz (74.27 KB, application/gzip)
2022-12-08 15:24 UTC, Martin Filla
no flags Details
example torrc (704 bytes, text/plain)
2022-12-10 21:26 UTC, Jesper Schmitz Mouridsen
no flags Details
tor-browser.shar.tar.gz (73.93 KB, application/gzip)
2022-12-12 13:53 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (73.95 KB, application/gzip)
2022-12-12 20:17 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (73.90 KB, application/gzip)
2022-12-13 12:10 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (73.83 KB, application/gzip)
2022-12-13 15:25 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (73.82 KB, application/gzip)
2022-12-13 19:18 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (73.76 KB, application/gzip)
2022-12-14 17:55 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (73.77 KB, application/gzip)
2022-12-14 19:39 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (74.02 KB, application/gzip)
2022-12-15 10:18 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (74.01 KB, application/gzip)
2022-12-15 13:30 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (74.02 KB, application/gzip)
2022-12-18 09:01 UTC, Martin Filla
no flags Details
tor-browser.shar.tar.gz (75.42 KB, application/gzip)
2022-12-20 09:42 UTC, Martin Filla
no flags Details
add option PULSEAUDIO (688 bytes, patch)
2022-12-21 18:08 UTC, Vladimir Druzenko
no flags Details | Diff
Move profile dir to subfolder (1.80 KB, patch)
2023-01-16 18:15 UTC, Jesper Schmitz Mouridsen
jsm: maintainer-approval? (freebsd)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Filla 2022-12-08 15:24:01 UTC
Created attachment 238635 [details]
tor-browser.shar.tar.gz

Hi,
I prepared a native port for the tor-browser.

===========================================================================
====> Running Q/A tests (stage-qa)
Warning: Bad symlink '/usr/local/bin/firefox' pointing to an absolute pathname '/usr/local/lib/firefox/firefox'
Warning: you may not need USES=desktop-file-utils
Warning: Possible REINPLACE_CMD issues:
- - REINPLACE_CMD ran, but did not modify file contents: config/baseconfig.mk
- - REINPLACE_CMD ran, but did not modify file contents: config/baseconfig.mk
- - REINPLACE_CMD ran, but did not modify file contents: xpcom/io/SpecialSystemDirectory.cpp
====> Checking for pkg-plist issues (check-plist)
===> Parsing plist
===> Checking for items in STAGEDIR missing from pkg-plist
===> Checking for items in pkg-plist which are not in STAGEDIR
===> No pkg-plist issues found (check-plist)
=>> Checking for staging violations... done
=======================<phase: package        >============================
===>  Building package for tor-browser-s.f.t.b.102.5.0.e.12.0.1.b4
===========================================================================
=>> Recording filesystem state for preinst... done
=======================<phase: install        >============================
===>  Installing for tor-browser-s.f.t.b.102.5.0.e.12.0.1.b4
===>  Checking if tor-browser is already installed
===>   Registering installation for tor-browser-s.f.t.b.102.5.0.e.12.0.1.b4
[freebsd131x64-2022Q4] Installing tor-browser-s.f.t.b.102.5.0.e.12.0.1.b4...
===> SECURITY REPORT: 
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/lib/firefox/libxul.so

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.
===========================================================================
=>> Checking shared library dependencies
 0x0000000000000001 NEEDED               Shared library: [libX11-xcb.so.1]
 0x0000000000000001 NEEDED               Shared library: [libX11.so.6]
 0x0000000000000001 NEEDED               Shared library: [libXcomposite.so.1]
 0x0000000000000001 NEEDED               Shared library: [libXdamage.so.1]
 0x0000000000000001 NEEDED               Shared library: [libXext.so.6]
 0x0000000000000001 NEEDED               Shared library: [libXfixes.so.3]
 0x0000000000000001 NEEDED               Shared library: [libXrandr.so.2]
 0x0000000000000001 NEEDED               Shared library: [libaom.so.3]
 0x0000000000000001 NEEDED               Shared library: [libatk-1.0.so.0]
 0x0000000000000001 NEEDED               Shared library: [libc++.so.1]
 0x0000000000000001 NEEDED               Shared library: [libc.so.7]
 0x0000000000000001 NEEDED               Shared library: [libcairo-gobject.so.2]
 0x0000000000000001 NEEDED               Shared library: [libcairo.so.2]
 0x0000000000000001 NEEDED               Shared library: [libcxxrt.so.1]
 0x0000000000000001 NEEDED               Shared library: [libdav1d.so.6]
 0x0000000000000001 NEEDED               Shared library: [libdl.so.1]
 0x0000000000000001 NEEDED               Shared library: [libevent-2.1.so.7]
 0x0000000000000001 NEEDED               Shared library: [libffi.so.8]
 0x0000000000000001 NEEDED               Shared library: [libfontconfig.so.1]
 0x0000000000000001 NEEDED               Shared library: [libfreetype.so.6]
 0x0000000000000001 NEEDED               Shared library: [libgcc_s.so.1]
 0x0000000000000001 NEEDED               Shared library: [libgdk-3.so.0]
 0x0000000000000001 NEEDED               Shared library: [libgdk_pixbuf-2.0.so.0]
 0x0000000000000001 NEEDED               Shared library: [libgio-2.0.so.0]
 0x0000000000000001 NEEDED               Shared library: [libglib-2.0.so.0]
 0x0000000000000001 NEEDED               Shared library: [libgobject-2.0.so.0]
 0x0000000000000001 NEEDED               Shared library: [libgtk-3.so.0]
 0x0000000000000001 NEEDED               Shared library: [libharfbuzz.so.0]
 0x0000000000000001 NEEDED               Shared library: [libicui18n.so.71]
 0x0000000000000001 NEEDED               Shared library: [libicuuc.so.71]
 0x0000000000000001 NEEDED               Shared library: [liblgpllibs.so]
 0x0000000000000001 NEEDED               Shared library: [libm.so.5]
 0x0000000000000001 NEEDED               Shared library: [libmozavutil.so]
 0x0000000000000001 NEEDED               Shared library: [libmozgtk.so]
 0x0000000000000001 NEEDED               Shared library: [libmozsqlite3.so]
 0x0000000000000001 NEEDED               Shared library: [libmozwayland.so]
 0x0000000000000001 NEEDED               Shared library: [libnspr4.so]
 0x0000000000000001 NEEDED               Shared library: [libnss3.so]
 0x0000000000000001 NEEDED               Shared library: [libnssutil3.so]
 0x0000000000000001 NEEDED               Shared library: [libpango-1.0.so.0]
 0x0000000000000001 NEEDED               Shared library: [libpixman-1.so.0]
 0x0000000000000001 NEEDED               Shared library: [libplc4.so]
 0x0000000000000001 NEEDED               Shared library: [libpng16.so.16]
 0x0000000000000001 NEEDED               Shared library: [libsmime3.so]
 0x0000000000000001 NEEDED               Shared library: [libssl3.so]
 0x0000000000000001 NEEDED               Shared library: [libthr.so.3]
 0x0000000000000001 NEEDED               Shared library: [libutil.so.9]
 0x0000000000000001 NEEDED               Shared library: [libvpx.so.7]
 0x0000000000000001 NEEDED               Shared library: [libwebp.so.7]
 0x0000000000000001 NEEDED               Shared library: [libwebpdemux.so.2]
 0x0000000000000001 NEEDED               Shared library: [libxcb-shm.so.0]
 0x0000000000000001 NEEDED               Shared library: [libxcb.so.1]
 0x0000000000000001 NEEDED               Shared library: [libxul.so]
 0x0000000000000001 NEEDED               Shared library: [libz.so.6]
=======================<phase: deinstall      >============================
===>  Deinstalling for tor-browser
===>   Deinstalling tor-browser-s.f.t.b.102.5.0.e.12.0.1.b4
Updating database digests format: .......... done
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
	tor-browser: s.f.t.b.102.5.0.e.12.0.1.b4

Number of packages to be removed: 1

The operation will free 286 MiB.
[freebsd131x64-2022Q4] [1/1] Deinstalling tor-browser-s.f.t.b.102.5.0.e.12.0.1.b4...
[freebsd131x64-2022Q4] [1/1] Deleting files for tor-browser-s.f.t.b.102.5.0.e.12.0.1.b4: .......... done
===========================================================================
Comment 1 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2022-12-08 19:04:09 UTC
These settings seems to give the browser a connected state


In about:config set the following:
extensions.torlauncher.prompt_at_startup	false	
extensions.torlauncher.socks_port_flags	IPv6Traffic PreferIPv6 KeepAliveIsolateSOCKSAuth	
extensions.torlauncher.tor_path	/usr/local/bin/tor	
extensions.torlauncher.tordatadir_path	/usr/local/lib/firefox/TorBrowser/Tor/.data	
extensions.torlauncher.torrc_fixup_version	2



mkdir -p /usr/local/lib/firefox/TorBrowser/Tor/ and your user should be able to read and write to it
in /usr/local/lib/firefox/TorBrowser/Tor/ create torrc-defaults with the following contents:
# torrc-defaults for Tor Browser
AvoidDiskWrites 1
# Where to send logging messages.  Format is minSeverity[-maxSeverity]
# (stderr|stdout|syslog|file FILENAME).
Log notice stdout
CookieAuthentication 1
DormantCanceledByStartup 1
ClientTransportPlugin meek_lite,obfs2,obfs3,obfs4,scramblesuit exec /usr/local/bin/obfs4proxy
#EOF

start the browser with TOR_CONTROL_PASSWD="`openssl rand --hex 30`" /usr/local/lib/firefox/firefox  --class "Tor Browser" --name "Tor Browser"
Comment 2 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2022-12-08 19:34:13 UTC
(In reply to Jesper Schmitz Mouridsen from comment #1)
Also one needs a /home/Tor dir writeable by the user launching the browser..
Comment 3 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2022-12-10 21:26:50 UTC
Created attachment 238701 [details]
example torrc

The tor launcher is not really working automatically so:

Manually starting tor for the tor browser, set extensions.torlauncher.start_tor 
to false in about:config

start tor as your user tor-f torrc. the file is in the attachments: 'example torrc'

start the browser with:
TOR_CONTROL_PASSWD='"yourpassword"' /usr/local/lib/firefox/firefox --class Tor Browser --name Tor Browser

note the double quotes in single quotes are intentional
Comment 4 Martin Filla 2022-12-12 13:53:16 UTC
Created attachment 238727 [details]
tor-browser.shar.tar.gz

Thanks Jesper Schmitz Mouridsen for patches.
Fixed bugs with connecting to the tor network
Comment 5 Martin Filla 2022-12-12 20:17:06 UTC
Created attachment 238739 [details]
tor-browser.shar.tar.gz

Fi distinfo and master site
Comment 6 Martin Filla 2022-12-13 12:10:19 UTC
Created attachment 238754 [details]
tor-browser.shar.tar.gz
Comment 7 Martin Filla 2022-12-13 15:25:12 UTC
Created attachment 238763 [details]
tor-browser.shar.tar.gz
Comment 8 Martin Filla 2022-12-13 19:18:29 UTC
Created attachment 238768 [details]
tor-browser.shar.tar.gz
Comment 9 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2022-12-14 11:48:09 UTC
(In reply to Martin Filla from comment #8)
files/patch-browser_branding_unofficial_default512.png is not needed, please remove and then we should be good to merge.
Comment 10 Martin Filla 2022-12-14 17:55:17 UTC
Created attachment 238788 [details]
tor-browser.shar.tar.gz

removed patch patch-browser_branding_unofficial_default512.png
Comment 11 Martin Filla 2022-12-14 19:39:56 UTC
Created attachment 238792 [details]
tor-browser.shar.tar.gz

disabled MOZ_TELEMETRY_REPORTING
Comment 12 Martin Filla 2022-12-15 10:18:06 UTC
Created attachment 238811 [details]
tor-browser.shar.tar.gz
Comment 13 Martin Filla 2022-12-15 13:30:54 UTC
Created attachment 238819 [details]
tor-browser.shar.tar.gz
Comment 14 Martin Filla 2022-12-18 09:01:06 UTC
Created attachment 238887 [details]
tor-browser.shar.tar.gz
Comment 15 Martin Filla 2022-12-20 09:42:03 UTC
Created attachment 238940 [details]
tor-browser.shar.tar.gz
Comment 16 commit-hook freebsd_committer freebsd_triage 2022-12-21 12:08:16 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ab304cc0281bb7828921273f8f1d2741ae8a19be

commit ab304cc0281bb7828921273f8f1d2741ae8a19be
Author:     Martin Filla <freebsd@sysctl.cz>
AuthorDate: 2022-12-21 11:41:49 +0000
Commit:     Jesper Schmitz Mouridsen <jsm@FreeBSD.org>
CommitDate: 2022-12-21 12:01:07 +0000

    www/tor-browser: New port

     Reuse patches from www/firefox
     against tor-project's tor-browser source,
     and configure as tor-browser.

    PR:             268245

 www/Makefile                                       |     1 +
 www/tor-browser/Makefile (new)                     |    97 +
 www/tor-browser/distinfo (new)                     |     3 +
 www/tor-browser/files/patch-addon-search (new)     |    53 +
 .../files/patch-browser-app-nsBrowserApp.cpp (new) |    14 +
 ...ch-browser_app_profile_000-tor-browser.js (new) |    23 +
 .../files/patch-bug1269654_comment5 (new)          |    43 +
 .../files/patch-bug1504834_comment10 (new)         |    36 +
 .../files/patch-bug1504834_comment5 (new)          |    85 +
 .../files/patch-bug1504834_comment9 (new)          |    49 +
 www/tor-browser/files/patch-bug1559213 (new)       |   122 +
 .../files/patch-bug1612181_comment1 (new)          |   191 +
 www/tor-browser/files/patch-bug1626236 (new)       |    92 +
 www/tor-browser/files/patch-bug1628567 (new)       |    32 +
 www/tor-browser/files/patch-bug1640982 (new)       |    17 +
 www/tor-browser/files/patch-bug1659612 (new)       |    35 +
 www/tor-browser/files/patch-bug1664115 (new)       |    82 +
 www/tor-browser/files/patch-bug1680982 (new)       |   388 +
 www/tor-browser/files/patch-bug1716707 (new)       |    56 +
 .../files/patch-bug1729459_comment12 (new)         |    93 +
 www/tor-browser/files/patch-bug1773070 (new)       |    26 +
 www/tor-browser/files/patch-bug847568 (new)        |   292 +
 .../patch-dom_media_flac_FlacDecoder.cpp (new)     |    23 +
 www/tor-browser/files/patch-env-api-keys (new)     |    21 +
 .../patch-gfx_skia_skia_src_core_SkCpu.cpp (new)   |    32 +
 .../files/patch-libwebrtc-generate (new)           |   159 +
 .../files/patch-libwebrtc-generated (new)          | 70292 +++++++++++++++++++
 .../files/patch-memory_mozalloc_throw__gcc.h (new) |    69 +
 www/tor-browser/files/patch-pipewire_init (new)    |    92 +
 ...python_mozbuild_mozbuild_gn__processor.py (new) |    39 +
 ..._libwebrtc_third__party_pffft_src_pffft.c (new) |    10 +
 .../patch-third__party_sqlite3_src_moz.build (new) |    12 +
 ...ononents_tor-launcher_TorLauncherUtil.jsm (new) |    20 +
 ..._compononents_tor-launcher_TorProcess.jsm (new) |    22 +
 .../patch-tools_profiler_core_patform.cpp (new)    |    51 +
 www/tor-browser/files/tor-browser.desktop.in (new) |     9 +
 www/tor-browser/files/torrc-defaults.in (new)      |     4 +
 www/tor-browser/pkg-descr (new)                    |    15 +
 38 files changed, 72700 insertions(+)
Comment 17 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2022-12-21 12:10:39 UTC
Committed, with added pkg-desc.
Thanks!
Comment 18 Vladimir Druzenko freebsd_committer freebsd_triage 2022-12-21 15:39:14 UTC
Need possibility (option) to build without the pulseaudio - I can create the patch.
Comment 19 Vladimir Druzenko freebsd_committer freebsd_triage 2022-12-21 18:08:53 UTC
Created attachment 238960 [details]
add option PULSEAUDIO

Tested on 13.1-p5 amd64: build and run.
Comment 20 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2023-01-16 15:52:39 UTC
(In reply to VVD from comment #18)
I will just include 

.include "${.CURDIR}/../../www/firefox/Makefile.options"

.include <bsd.port.options.mk>


Which will take care of the options
Comment 21 Vladimir Druzenko freebsd_committer freebsd_triage 2023-01-16 16:03:05 UTC
(In reply to Jesper Schmitz Mouridsen from comment #20)
Very good solution!
Thanks!
Comment 22 Jesper Schmitz Mouridsen freebsd_committer freebsd_triage 2023-01-16 18:15:22 UTC
Created attachment 239504 [details]
Move profile dir to subfolder

and adds the default firefox options,
and remove redundant LIB_DEPENDS included by
uses gecko
Comment 23 commit-hook freebsd_committer freebsd_triage 2023-02-12 15:35:10 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5ab09c70073a08928f4b3fc3930167dbea964845

commit 5ab09c70073a08928f4b3fc3930167dbea964845
Author:     Jesper Schmitz Mouridsen <jsm@FreeBSD.org>
AuthorDate: 2023-02-12 15:06:41 +0000
Commit:     Rene Ladan <rene@FreeBSD.org>
CommitDate: 2023-02-12 15:34:10 +0000

    www/tor-browser: various improvements

    - use a dedicated directory [1]
    - enable building without PulseAudio, use Gecko framework more [2]

    No PORTREVISION bump because the next commit will update the port
    to a new version.
    PR:             268584 [1]
    PR:             268245 [2] (attachment 3 [details])
    Approved by:    maintainer timeout (freebsd@sysctl.cz, 6 weeks)

 www/tor-browser/Makefile                                   |  8 +-------
 .../files/patch-toolkit_xre_nsXREDirPRovider.cpp (new)     | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 7 deletions(-)