-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #365 from MusicDin/fix/socket-win
Fix unix socket check on Windows
- Loading branch information
Showing
3 changed files
with
31 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
//go:build !windows | ||
|
||
package lxd | ||
|
||
import ( | ||
"log" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
// IsSocketWritable returns true if user has write permissions for socket on the given path. | ||
func IsSocketWritable(socketPath string) bool { | ||
err := unix.Access(socketPath, unix.W_OK) | ||
if err != nil { | ||
log.Printf("[DEBUG] Unix socket %q: %v", socketPath, err) | ||
return false | ||
} | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build windows | ||
|
||
package lxd | ||
|
||
// IsSocketWritable always returns true when os is windows. | ||
func IsSocketWritable(socketPath string) bool { | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters