From 8c337dcc2489c94960276cbc428261838e106f60 Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Sun, 13 Dec 2015 18:12:18 +0100 Subject: [PATCH] block all write flags instead of checking for O_RDONLY --- filter_readonly.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/filter_readonly.go b/filter_readonly.go index 54672e6..0ff67a7 100644 --- a/filter_readonly.go +++ b/filter_readonly.go @@ -42,10 +42,10 @@ func (r *ReadOnlyFilter) Remove(n string) error { } func (r *ReadOnlyFilter) OpenFile(name string, flag int, perm os.FileMode) (File, error) { - if flag&os.O_RDONLY != 0 { - return nil, nil + if flag&(os.O_WRONLY|syscall.O_RDWR|os.O_APPEND|os.O_CREATE|os.O_TRUNC) != 0 { + return nil, syscall.EPERM } - return nil, syscall.EPERM + return nil, nil } func (r *ReadOnlyFilter) Open(n string) (File, error) {