💾 Archived View for thrig.me › blog › 2023 › 11 › 17 › amfora.patch captured on 2024-07-09 at 02:00:31.

View Raw

More Information

⬅️ Previous capture (2023-12-28)

-=-=-=-=-=-=-

--- amfora.go
+++ amfora.go
@@ -13,6 +13,8 @@ import (
 	"github.com/makeworld-the-better-one/amfora/display"
 	"github.com/makeworld-the-better-one/amfora/logger"
 	"github.com/makeworld-the-better-one/amfora/subscriptions"
+
+	"suah.dev/protect"
 )
 
 var (
@@ -22,6 +24,18 @@ var (
 )
 
 func main() {
+	protect.Pledge("cpath dns inet rpath stdio tty unveil wpath")
+	hpath, _ := os.UserHomeDir()
+	protect.Unveil("/etc/ssl", "r")
+	protect.Unveil(filepath.Join(hpath, ".cache/amfora"), "crw")
+	protect.Unveil(filepath.Join(hpath, ".config/amfora"), "crw")
+	protect.Unveil(filepath.Join(hpath, ".local/share/amfora"), "crw")
+	protect.Unveil(filepath.Join(hpath, "var/gemini"), "r")
+	protect.Unveil(filepath.Join(hpath, "var/log/urls"), "cw")
+	protect.Unveil(filepath.Join(hpath, "tmp"), "crw")
+	protect.Unveil(filepath.Join(hpath, "/tmp"), "crw")
+	protect.UnveilBlock()
+
 	log, err := logger.GetLogger()
 	if err != nil {
 		panic(err)
--- display/download.go
+++ display/download.go
@@ -83,7 +83,7 @@ func dlInit() {
 		frame.SetTitleColor(tcell.ColorWhite)
 	}
 
-	chm.AddButtons([]string{"Open", "Download", "Cancel"})
+	chm.AddButtons([]string{"Download", "Cancel"})
 	chm.SetBorder(true)
 	chm.GetFrame().SetTitleAlign(cview.AlignCenter)
 	chm.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
@@ -138,7 +138,7 @@ func dlChoice(text, u string, resp *gemini.Response) {
 	var choice string
 
 	if mediaHandler.NoPrompt {
-		choice = "Open"
+		choice = "Download"
 	} else {
 		dlChoiceModal.SetText(text)
 		panels.ShowPanel(PanelDownloadChoiceModal)
--- display/handlers.go
+++ display/handlers.go
@@ -6,18 +6,17 @@ import (
 	"mime"
 	"net"
 	"net/url"
+	"os"
 	"os/exec"
 	"path"
 	"strings"
 
--- go.mod
+++ go.mod
@@ -19,6 +19,7 @@ require (
 	github.com/spf13/viper v1.16.0
 	github.com/stretchr/testify v1.8.4
 	golang.org/x/text v0.13.0
+	suah.dev/protect v1.2.0
 )
 
 require (