Commit Graph

4 Commits

Author SHA1 Message Date
Derek McGowan
f7a2e09ef8 Fix lint issues
Cleanup server test

Signed-off-by: Derek McGowan <derek@mcg.dev>
2022-01-21 12:04:30 -08:00
Michael Crosby
0690b20898 Add apache license to files
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-06-27 17:49:06 -04:00
Stephen J Day
256c17bccd
ttrpc: use os.Getuid/os.Getgid directly
Because of issues with glibc, using the `os/user` package can cause when
calling `user.Current()`. Neither the Go maintainers or glibc developers
could be bothered to fix it, so we have to work around it by calling the
uid and gid functions directly. This is probably better because we don't
actually use much of the data provided in the `user.User` struct.

This required some refactoring to have better control over when the uid
and gid are resolved. Rather than checking the current user on every
connection, we now resolve it once at initialization. To test that this
provided an improvement in performance, a benchmark was added.
Unfortunately, this exposed a regression in the performance of unix
sockets in Go when `(*UnixConn).File` is called. The underlying culprit
of this performance regression is still at large.

The following open issues describe the underlying problem in more
detail:

https://github.com/golang/go/issues/13470
https://sourceware.org/bugzilla/show_bug.cgi?id=19341

In better news, I now have an entire herd of shaved yaks.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-30 20:21:50 -08:00
Stephen J Day
d4983e717b
ttrpc: implement unix socket credentials
Because ttrpc can be used with abstract sockets, it is critical to
ensure that only certain users can connect to the unix socket. This is
of particular interest in the primary use case of containerd, where a
shim may run as root and any user can connection.

With this, we get a few nice features. The first is the concept of a
`Handshaker` that allows one to intercept each connection and replace it
with one of their own. The enables credential checks and other measures,
such as tls. The second is that servers now support configuration. This
allows one to inject a handshaker for each connection. Other options
will be added in the future.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-30 16:11:14 -08:00