[tor-commits] [sandboxed-tor-browser/master] Bug #20847: Make Print to File work.

yawning at torproject.org yawning at torproject.org
Thu Dec 1 20:50:14 UTC 2016


commit 7cefb4c8013800b9c445e7c99e34b9ddf670841c
Author: Yawning Angel <yawning at schwanenlied.me>
Date:   Thu Dec 1 20:38:45 2016 +0000

    Bug #20847: Make Print to File work.
    
    At least this was simple to fix, printing is handled by Gtk, and the
    appropriate backend was missing.
---
 .../internal/sandbox/application.go                | 30 +++++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/cmd/sandboxed-tor-browser/internal/sandbox/application.go b/src/cmd/sandboxed-tor-browser/internal/sandbox/application.go
index 7620802..1e8696d 100644
--- a/src/cmd/sandboxed-tor-browser/internal/sandbox/application.go
+++ b/src/cmd/sandboxed-tor-browser/internal/sandbox/application.go
@@ -554,30 +554,52 @@ func (h *hugbox) appendRestrictedGtk2() ([]string, string, error) {
 		libAdwaita   = "libadwaita.so"
 		libPixmap    = "libpixmap.so"
 		libPngLoader = "libpixbufloader-png.so"
+		libPrintFile = "libprintbackend-file.so"
 
-		gtkSubDir = "gtk-2.0/2.10.0/engines"
-		gdkSubDir = "gdk-pixbuf-2.0/2.10.0/loaders"
+		engineSubDir = "gtk-2.0/2.10.0/engines"
+		printSubDir  = "gtk-2.0/2.10.0/printbackends"
+		gdkSubDir    = "gdk-pixbuf-2.0/2.10.0/loaders"
 	)
 
 	gtkLibs := []string{}
 	gtkLibPath := ""
+	setGtkPath := false
 
 	// Figure out where the system keeps the Gtk+-2.0 theme libraries,
 	// and bind mount in Adwaita and Pixmap.
-	adwaitaPath := findDistributionDependentLibs(gtkSubDir, libAdwaita)
+	adwaitaPath := findDistributionDependentLibs(engineSubDir, libAdwaita)
 	if adwaitaPath != "" {
 		gtkEngineDir, _ := filepath.Split(adwaitaPath)
 		normGtkEngineDir := filepath.Join(restrictedLibDir, "gtk-2.0", "2.10.0", "engines")
 		h.roBind(adwaitaPath, filepath.Join(normGtkEngineDir, libAdwaita), false)
 		h.roBind(filepath.Join(gtkEngineDir, libPixmap), filepath.Join(normGtkEngineDir, libPixmap), true)
-		h.setenv("GTK_PATH", filepath.Join(restrictedLibDir, "gtk-2.0"))
 
+		setGtkPath = true
 		gtkLibs = append(gtkLibs, libAdwaita)
 		gtkLibPath = gtkLibPath + ":" + gtkEngineDir
 	} else {
 		log.Printf("sandbox: Failed to find gtk-2.0 libadwaita.so.")
 	}
 
+	// Figure out where the system keeps the Gtk+-2.0 print backends,
+	// and bind mount in the file one.
+	printFilePath := findDistributionDependentLibs(printSubDir, libPrintFile)
+	if printFilePath != "" {
+		gtkPrintDir, _ := filepath.Split(printFilePath)
+		normGtkPrintDir := filepath.Join(restrictedLibDir, "gtk-2.0", "2.10.0", "printbackends")
+		h.roBind(printFilePath, filepath.Join(normGtkPrintDir, libPrintFile), false)
+
+		setGtkPath = true
+		gtkLibs = append(gtkLibs, libPrintFile)
+		gtkLibPath = gtkLibPath + ":" + gtkPrintDir
+	} else {
+		log.Printf("sandbox: Failed to find gtk-2.0 libprintbackend-file.so.")
+	}
+
+	if setGtkPath {
+		h.setenv("GTK_PATH", filepath.Join(restrictedLibDir, "gtk-2.0"))
+	}
+
 	// Figure out if the system gdk-pixbuf-2.0 needs loaders for common
 	// file formats.  Arch and Fedora 25 do not.  Debian does.  As far as
 	// I can tell, the only file format we actually care about is PNG.



More information about the tor-commits mailing list