-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Several 2.0 regression fixes #876
Conversation
I can reproduce the |
The reason the agent forwarding test was failing on macOS while passing on Linux was due to the path length restrictions on macOS for Unix sockets. From the the I shortened the UUID to the first 8 characters and also made the tests more cross platform friendly (used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@russjones spotted some issues
if cfg.Auth.StorageConfig.Params == nil { | ||
cfg.Auth.StorageConfig.Params = backend.Params{} | ||
} | ||
cfg.Auth.StorageConfig.Params["data_dir"] = cfg.DataDir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@russjones this overwrites the user-supplied value at all times, what should not be the case. We should only overwrite the value if user haven't supplied the value. You can fix that yourself as @kontsevoy is OOO at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@klizhentas there are no user-supplied values in StorageConfig.Params
[1]. Storage config is a static, backend-specific YAML configuration, with "data_dir" being a reserved word. In fact, we guarantee the presence of "data_dir" in .Params
(and back-end code expects it to be there) This needs to be reflected in backend developer README. In other words, this behavior is as-designed.
[1] Bolt used to accept an arbitrary JSON string, so that's why you think there are user-supplied values. This is no longer true since the Great Christmas-2016 Back-end Redesign
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think users can supply Params["path"] for backend, at least what I have observed in configs and the code, so I don't quite understand the fix then. Why is it setting "data_dir" and not "path" like for example "boltdb" requires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My question basically is - can you explain to me how does this change fixes the case reported here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@russjones: @kontsevoy explained to me how it works, so this part lgtm, please fix the part with socket path and merge the whole thing
lib/srv/proxy.go
Outdated
log.Debugf("proxy connecting to host=%v port=%v, exact port=%v\n", t.host, t.port, useExactPort) | ||
|
||
ips, err := net.LookupHost(t.host) | ||
log.Debugf("host lookup (%v)=%v, err=%v", t.host, ips, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem with err=
is that it will be 99% of the time equal to err=nil
and grep catches it all the time, so we should try to make it less verbose even for debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by "grep catches it all the time"? adding error logging here helped me solve DNS-related issue on a customer POC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your error logs look like host lookup (%v)=%v err=nil
, so If I grep for gre logs err I will get all these false positives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k, kill it. I'm not attached to it :)
lib/srv/sshserver.go
Outdated
@@ -878,7 +878,7 @@ func (s *Server) handleAgentForward(ch ssh.Channel, req *ssh.Request, ctx *ctx) | |||
ctx.setAgent(clientAgent, authChan) | |||
|
|||
pid := os.Getpid() | |||
socketPath := filepath.Join(os.TempDir(), fmt.Sprintf("teleport-agent-%v.socket", uuid.New())) | |||
socketPath := filepath.Join(os.TempDir(), fmt.Sprintf("teleport-agent-%v.socket", uuid.New()[0:8])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@russjones it's a bit too late for me now, what are the chances of collision for this given your change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a comment: most UNIX tools use their own PID instead of UUID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they also create random temp dir though, not in root /tmp dir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two other options:
-
We create the socket under
/var/run/teleport/
. This way our socket files are on the same place on all platforms. We can name the socket itselfteleport-{random number}-{pid}.socket
and still be under the 104 character limit. -
We do this instead:
ioutil.TempDir(os.TempDir(), "teleport-")
which will create/tmp/teleport-699583643
on Linux and/var/folders/00/l7kftvrn2tx7cv0_w2x_c4_c0000gn/T/teleport-699583643
on macOS. We can name the socket itselfteleport-{pid}.socket
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@russjones let's go with option 2. because it protects us from collisions on the implementation level - AFAIK golang checks for collisions
@klizhentas Made the changes you suggested, can you approve? |
- Added comments to explain the purpose of clientConfig.HostPort - Fixed typo - Fixed docker-based 'make release' to include Teleport version into the produced tarball - More informative logging around host lookups
- Fixed logging. Closes #875 - Removed dead code - Fixed 'exec' tests on OSX
lib/srv/sshserver_test.go
Outdated
@@ -238,7 +239,8 @@ func (s *SrvSuite) TestAgentForward(c *C) { | |||
_, err = io.WriteString(writer, fmt.Sprintf("printenv %v\n\r", teleport.SSHAuthSock)) | |||
c.Assert(err, IsNil) | |||
|
|||
re := regexp.MustCompile(`/tmp/[^\s]+`) | |||
pattern := fmt.Sprintf(`%vteleport-[0-9]+[^\s]+`, os.TempDir()) | |||
re := regexp.MustCompile(pattern) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not actually the line that has the problem, but it's the loop below:
for i := 0; i < 3; i++ {
_, err = reader.Read(buf)
c.Assert(err, IsNil)
matches = re.FindStringSubmatch(string(buf))
if len(matches) != 0 {
break
}
time.Sleep(50 * time.Millisecond)
}
On Linux tests hang on the line _, err = reader.Read(buf)
. Works fine on macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me try to fix that
@klizhentas Tested your fix, works on macOS as well. |
@russjones let's merge then |
* Show error when auth settings return `u2f` second factor option - Handles `u2f` cfg returned from v9 - Push users to use webauthn * Conditionally render adding passwordless device based on if pwdless is enabled * Fix brief flash rendering of buttons before attempt success state * Add soft warning for firefox users for passwordless login or register
* Show error when auth settings return `u2f` second factor option - Handles `u2f` cfg returned from v9 - Push users to use webauthn * Conditionally render adding passwordless device based on if pwdless is enabled * Fix brief flash rendering of buttons before attempt success state * Add soft warning for firefox users for passwordless login or register
I recommend reviewing this PR by looking at each commit individually. Commits are well-annotated and easy to understand.
The summary:
data_dir
configuration value into back-end'sparams
section. This was the original intent, there was even code which was looking up for this value, but it was never copied.build.assets
so it doesn't destroyVERSION
variable anymore, so when you callmake -C build.assets release
you get a properly formatted tarball.SSH exec
unit test on OSX.forwarding request denied
unit test that failed on macOS.Notes
I am at Kubecon, so if you see issues with this PR please fix yourself, do not wait for me to return. Thanks!