Protect regular files from FIFO setup
This commit is contained in:
committed by
Brandon McGinty
parent
dcffa1efa1
commit
43d7addc15
@@ -87,7 +87,16 @@ func setup_fifo(fn string) (chan string, error) {
|
||||
if fn == "" {
|
||||
return t, nil
|
||||
}
|
||||
os.Remove(fn)
|
||||
if info, err := os.Lstat(fn); err == nil {
|
||||
if info.Mode()&os.ModeNamedPipe == 0 {
|
||||
return t, fmt.Errorf("FIFO path %q already exists and is not a FIFO", fn)
|
||||
}
|
||||
if err := os.Remove(fn); err != nil {
|
||||
return t, err
|
||||
}
|
||||
} else if !os.IsNotExist(err) {
|
||||
return t, err
|
||||
}
|
||||
err := syscall.Mkfifo(fn, 0600)
|
||||
if err != nil {
|
||||
return t, err
|
||||
|
||||
Reference in New Issue
Block a user