diff --git a/group/description.go b/group/description.go index be7c276..53671d6 100644 --- a/group/description.go +++ b/group/description.go @@ -380,7 +380,14 @@ func rewriteDescriptionFile(filename string, desc *Description) error { return ErrDescriptionsNotWritable } - f, err := os.CreateTemp(path.Dir(filename), "*.temp") + dir := filepath.Dir(filename) + + err = os.MkdirAll(dir, 0700) + if err != nil { + return err + } + + f, err := os.CreateTemp(dir, "*.temp") if err != nil { return err } diff --git a/group/description_test.go b/group/description_test.go index 9e9221c..387cc18 100644 --- a/group/description_test.go +++ b/group/description_test.go @@ -306,3 +306,15 @@ func TestWritableGroups(t *testing.T) { ) } } + +func TestSubGroup(t *testing.T) { + err := setupTest(t.TempDir(), t.TempDir(), true) + if err != nil { + t.Fatalf("setupTest: %v", err) + } + + err = UpdateDescription("dir/test", "", &Description{}) + if err != nil { + t.Fatalf("UpdateDescription: got %v", err) + } +}