-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement AF_UNIX sockets on Windows
See moby/moby#36442 Signed-off-by: Marat Radchenko <[email protected]>
- Loading branch information
1 parent
5df8d2b
commit 11b4407
Showing
9 changed files
with
92 additions
and
49 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
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
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
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
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
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,32 @@ | ||
//go:build unix | ||
|
||
package sockets | ||
|
||
import ( | ||
"net" | ||
"os" | ||
"syscall" | ||
"testing" | ||
) | ||
|
||
func createTestUnixSocket(t *testing.T, path string) (listener net.Listener) { | ||
uid, gid := os.Getuid(), os.Getgid() | ||
perms := os.FileMode(0660) | ||
l, err := NewUnixSocketWithOpts(path, WithChown(uid, gid), WithChmod(perms)) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
p, err := os.Stat(path) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if p.Mode().Perm() != perms { | ||
t.Fatalf("unexpected file permissions: expected: %#o, got: %#o", perms, p.Mode().Perm()) | ||
} | ||
if stat, ok := p.Sys().(*syscall.Stat_t); ok { | ||
if stat.Uid != uint32(uid) || stat.Gid != uint32(gid) { | ||
t.Fatalf("unexpected file ownership: expected: %d:%d, got: %d:%d", uid, gid, stat.Uid, stat.Gid) | ||
} | ||
} | ||
return l | ||
} |
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,14 @@ | ||
package sockets | ||
|
||
import ( | ||
"net" | ||
"testing" | ||
) | ||
|
||
func createTestUnixSocket(t *testing.T, path string) (listener net.Listener) { | ||
l, err := NewUnixSocketWithOpts(path) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
return l | ||
} |
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,9 @@ | ||
//go:build unix | ||
|
||
package sockets | ||
|
||
import "syscall" | ||
|
||
func umask(newmask int) (oldmask int) { | ||
return syscall.Umask(0777) | ||
} |
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,5 @@ | ||
package sockets | ||
|
||
func umask(newmask int) (oldmask int) { | ||
return newmask | ||
} |