From 286210889c8fa3e380f8af352b7cfc563c8bbb57 Mon Sep 17 00:00:00 2001
From: Leonardo Arias Fonseca <agami@riseup.net>
Date: Sat, 13 Sep 2025 20:53:12 -0600
Subject: [PATCH] Write files without execution permission

Fixes #43

Bug: https://github.com/emicklei/dot/issues/43
Forwarded: https://github.com/emicklei/dot/pull/44
---
 dotx/composite.go      | 2 +-
 dotx/composite_test.go | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/dotx/composite.go b/dotx/composite.go
index 509445c..0cb6174 100644
--- a/dotx/composite.go
+++ b/dotx/composite.go
@@ -130,7 +130,7 @@ func (s *Composite) ExportFile() error {
 	if s.kind != ExternalGraph {
 		return errors.New("ExportFile is only applicable to a ExternalGraph Composite")
 	}
-	return os.WriteFile(s.ExportFilename(), []byte(s.Graph.String()), os.ModePerm)
+	return os.WriteFile(s.ExportFilename(), []byte(s.Graph.String()), 0666)
 }
 
 // Export writes the DOT file for a Composite after building the content (child) graph using the build function.
diff --git a/dotx/composite_test.go b/dotx/composite_test.go
index d19cfd5..a6bbd35 100644
--- a/dotx/composite_test.go
+++ b/dotx/composite_test.go
@@ -33,7 +33,7 @@ func TestExampleSubsystemSameGraph(t *testing.T) {
 	sub3 := sub2.Node("subcomponent 3")
 	sub2.Input("in3", sub3)
 
-	os.WriteFile("TestExampleSubsystemSameGraph.dot", []byte(g.String()), os.ModePerm)
+	os.WriteFile("TestExampleSubsystemSameGraph.dot", []byte(g.String()), 0666)
 }
 
 func TestExampleSubsystemExternalGraph(t *testing.T) {
@@ -63,7 +63,7 @@ func TestExampleSubsystemExternalGraph(t *testing.T) {
 		})
 	})
 
-	os.WriteFile("TestExampleSubsystemExternalGraph.dot", []byte(g.String()), os.ModePerm)
+	os.WriteFile("TestExampleSubsystemExternalGraph.dot", []byte(g.String()), 0666)
 }
 
 func TestAttrOnSubsystem(t *testing.T) {
@@ -87,7 +87,7 @@ func TestCompositeWithUnusedIOSameGraph(t *testing.T) {
 	sub.Input("in", c1)
 	sub.Output("out", c1)
 
-	os.WriteFile("TestCompositeWithUnusedIOSameGraph.dot", []byte(g.String()), os.ModePerm)
+	os.WriteFile("TestCompositeWithUnusedIOSameGraph.dot", []byte(g.String()), 0666)
 }
 
 func TestConnectToComposites(t *testing.T) {
