Skip to content
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

Merged
merged 9 commits into from
Mar 30, 2017
Merged

Several 2.0 regression fixes #876

merged 9 commits into from
Mar 30, 2017

Conversation

kontsevoy
Copy link
Contributor

@kontsevoy kontsevoy commented Mar 26, 2017

I recommend reviewing this PR by looking at each commit individually. Commits are well-annotated and easy to understand.

The summary:

  1. Fixed BoltDB backend: 'path' is not set, initializing teleport with config file. #867 by "promoting" a top-level data_dir configuration value into back-end's params section. This was the original intent, there was even code which was looking up for this value, but it was never copied.
  2. Fixed Every log message under systemd is logged twice #875 by properly switching between syslog and stderr. Also cleaned up logging initialization, it's much easier to understand now.
  3. Found and killed some dead code: there was a function nobody ever called.
  4. Added comments here and there
  5. Fixed Makefile in build.assets so it doesn't destroy VERSION variable anymore, so when you call make -C build.assets release you get a properly formatted tarball.
  6. Fixed SSH exec unit test on OSX.
  7. Fixed 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!

@russjones
Copy link
Contributor

I can reproduce the forwarding request denied issue, let me hunt that down.

@russjones
Copy link
Contributor

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 UNIX(4) manpage: UNIX-domain addresses are variable-length file system pathnames of at most 104 characters..

I shortened the UUID to the first 8 characters and also made the tests more cross platform friendly (used os.TempDir instead of /tmp because macOS temporary directories look something like /var/folders/00/l7kftvrn2tx7cv0_w2x_c4_c0000gn/T/).

Copy link
Contributor

@klizhentas klizhentas left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

@kontsevoy kontsevoy Mar 28, 2017

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

Copy link
Contributor

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.

Copy link
Contributor

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:

#867

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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 :)

@@ -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]))
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@klizhentas klizhentas Mar 28, 2017

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two other options:

  1. 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 itself teleport-{random number}-{pid}.socket and still be under the 104 character limit.

  2. 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 itself teleport-{pid}.socket.

Copy link
Contributor

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

@russjones
Copy link
Contributor

@klizhentas Made the changes you suggested, can you approve?

kontsevoy and others added 6 commits March 29, 2017 17:12
- 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
@@ -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)
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

@russjones
Copy link
Contributor

@klizhentas Tested your fix, works on macOS as well.

@klizhentas
Copy link
Contributor

@russjones let's merge then

@russjones russjones merged commit 176e0f5 into master Mar 30, 2017
@russjones russjones deleted the ev/fixes branch March 30, 2017 22:23
hatched pushed a commit to hatched/teleport-merge that referenced this pull request Nov 30, 2022
* 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
hatched pushed a commit that referenced this pull request Dec 20, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants