Skip to content

Permission denied when try to watch for dir with one of files which have --wx------ permissions #270

@achernetsky

Description

@achernetsky

Hello,

I am sorry, I don't know this is a bug or something.

Which operating system (GOOS) and version are you using?

ProductName:	Mac OS X
ProductVersion:	10.14
BuildVersion:	18A391

Steps to reproduce

  1. cd /tmp && mkdir fsnotify_permission_denied
  2. cd fsnotify_permission_denied
  3. touch test1.log test2.log
  4. chmod 0300 test2.log
  5. go run main.go
// main.go

package main

import (
	"log"

	"github.com/fsnotify/fsnotify"
)

func ExampleNewWatcher() {
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		log.Fatal(err)
	}
	defer watcher.Close()

	err = watcher.Add("/tmp/fsnotify_permission_denied")
	if err != nil {
		log.Fatal("fatal: ", err)
	}
}

func main() {
	ExampleNewWatcher()
}

As result

$ go run main.go
2018/10/02 16:21:08 fatal: permission denied
exit status 1

Why is it try open file with 0700 permissions?

watchfd, err = unix.Open(name, openMode, 0700)

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions