in internal/pipewatcher/pipewatcher_linux.go [34:67]
func createNamedPipe(ctx context.Context, pipePath string, mode uint32) error {
pipeDir := filepath.Dir(pipePath)
_, err := os.Stat(pipeDir)
if err != nil && os.IsNotExist(err) {
// The perm 0755 is compatible with distros /etc/ directory.
if err := os.MkdirAll(pipeDir, 0755); err != nil {
return err
}
}
if _, err := os.Stat(pipePath); err != nil {
if os.IsNotExist(err) {
if err := syscall.Mkfifo(pipePath, mode); err != nil {
return fmt.Errorf("failed to create named pipe: %+v", err)
}
} else {
return fmt.Errorf("failed to stat file: " + pipePath)
}
}
restorecon, err := exec.LookPath("restorecon")
if err != nil {
galog.Infof("No restorecon available, not restoring SELinux context of: %s", pipePath)
return nil
}
opts := run.Options{Name: restorecon, Args: []string{pipePath}, OutputType: run.OutputNone}
if _, err := run.WithContext(ctx, opts); err != nil {
return fmt.Errorf("failed to restore SELinux context of: %s, %w", pipePath, err)
}
return nil
}