-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
auth: ENOTDIR not handled when user's HOME is not a directory #10696
Comments
Some users explicitly have their home directories set to `/dev/null`. When opening a file that's "under that directory", instead of getting the normal `ENOENT`, one should expect to get `ENOTDIR`. Unfortunately, due to the variety of cases under which `ENOTDIR` is returned, the go team has declined to include ENOTDIR in `ErrNotExist`. (https://golang.org/issues/18974) This leaves explicitly testing for `ENOTDIR`, which (fortunately) appears to be one of two errnos that are defined in the `syscall` package for windows as well as all *nix platforms. resolves: googleapis#10696
Some users explicitly have their home directories set to `/dev/null`. When opening a file that's "under that directory", instead of getting the normal `ENOENT`, one should expect to get `ENOTDIR`. Unfortunately, due to the variety of cases under which `ENOTDIR` is returned, the go team has declined to include ENOTDIR in `ErrNotExist`. (https://golang.org/issues/18974) This leaves explicitly testing for `ENOTDIR`, which (fortunately) appears to be one of two errnos that are defined in the `syscall` package for windows as well as all *nix platforms. resolves: googleapis#10696
Some users explicitly have their home directories set to `/dev/null`. When opening a file that's "under that directory", instead of getting the normal `ENOENT`, one should expect to get `ENOTDIR`. Unfortunately, due to the variety of cases under which `ENOTDIR` is returned, the go team has declined to include ENOTDIR in `ErrNotExist`. (https://golang.org/issues/18974) This leaves explicitly testing for `ENOTDIR`, which (fortunately) appears to be one of two errnos that are defined in the `syscall` package for windows as well as all *nix platforms. Resolves: googleapis#10696
I've opened #10697 |
@dfinkel Thank you for reporting this. Reviewing your PR now. |
I think the correct thing here is to not check for any special errors at all. I have come across this case in the past and discussed it with the Go team. There are legacy syscall reasons why ENOTDIR is not a not exists. Instead we should treat any error as the not exist case here. This was the conclusion reached for https://go-review.git.corp.google.com/c/oauth2/+/493695 as well. Happy to accept a PR for this style of fix. |
Some users explicitly have their home directories set to `/dev/null`. When opening a file that's "under that directory", instead of getting the normal `ENOENT`, one should expect to get `ENOTDIR`. Unfortunately, due to the variety of cases under which `ENOTDIR` is returned, the go team has declined to include ENOTDIR in `ErrNotExist`. (https://golang.org/issues/18974) The most robust solution in this case (following [1]) is to treat any read error as `errSourceUnavailable`. This has the mixed-benefit of also covering EPERM. (hopefully this doesn't make it too hard to track down permissions problems for secure connect users) Resolves: googleapis#10696 [1]: https://go-review.googlesource.com/c/oauth2/+/493695
Some users explicitly have their home directories set to `/dev/null`. When opening a file that's "under that directory", instead of getting the normal `ENOENT`, one should expect to get `ENOTDIR`. Unfortunately, due to the variety of cases under which `ENOTDIR` is returned, the go team has declined to include ENOTDIR in `ErrNotExist`. (https://golang.org/issues/18974) The most robust solution in this case (following [1]) is to treat any read error as `errSourceUnavailable`. This has the mixed-benefit of also covering EPERM. (hopefully this doesn't make it too hard to track down permissions problems for secure connect users) Resolves: googleapis#10696 [1]: https://go-review.googlesource.com/c/oauth2/+/493695
Some users explicitly have their home directories set to `/dev/null`. When opening a file that's "under that directory", instead of getting the normal `ENOENT`, one should expect to get `ENOTDIR`. Unfortunately, due to the variety of cases under which `ENOTDIR` is returned, the go team has declined to include ENOTDIR in `ErrNotExist`. (https://golang.org/issues/18974) The most robust solution in this case (following [1]) is to treat any read error as `errSourceUnavailable`. This has the mixed-benefit of also covering EPERM. (hopefully this doesn't make it too hard to track down permissions problems for secure connect users) Resolves: googleapis#10696 [1]: https://go-review.googlesource.com/c/oauth2/+/493695
Some users explicitly have their home directories set to `/dev/null`. When opening a file that's "under that directory", instead of getting the normal `ENOENT`, one should expect to get `ENOTDIR`. Unfortunately, due to the variety of cases under which `ENOTDIR` is returned, the go team has declined to include ENOTDIR in `ErrNotExist`. (https://golang.org/issues/18974) The most robust solution in this case (following [1]) is to treat any read error as `errSourceUnavailable`. This has the mixed-benefit of also covering EPERM. (hopefully this doesn't make it too hard to track down permissions problems for secure connect users) Resolves: googleapis#10696 [1]: https://go-review.googlesource.com/c/oauth2/+/493695
Some users explicitly have their home directories set to /dev/null. When opening a file that's "under that directory", instead of getting the normal ENOENT, one should expect to get ENOTDIR. Unfortunately, due to the variety of cases under which ENOTDIR is returned, the go team has declined to include ENOTDIR in ErrNotExist. (https://golang.org/issues/18974) The most robust solution in this case (following 1) is to treat any read error as errSourceUnavailable. This has the mixed-benefit of also covering EPERM. (hopefully this doesn't make it too hard to track down permissions problems for secure connect users) Resolves: #10696
Client
trace, but really the
auth
package.Environment
Alpine Docker on GKE when running as the
guest
user which has a home directory set to/dev/null
.Code and Dependencies
Mostly irrelevant, but the code that initializes the opencensus exporter/client is:
Expected behavior
The trace client (or any other GCP client) initializes without any client certificate. (using the GKE/GCE metadata server oauth credentials)
Actual behavior
Setting up the opencensus stackdriver trace exporter fails with this error:
It appears that because the user's home directory (as set in
/etc/passwd
) is explicitly set to/dev/null
, and that's not a directory, the explicit path that's constructed here fails withENOTDIR
, which doesn't matchos.ErrNotExist
, so it falls through and returnsENOTDIR
, when this is supposed to be a default code-path. (called from here)Additional context
We started seeing this following an upgrade to include
google.golang.org/api v0.188.0
It appears that #10431 converted a benign fall-through before into a fatal error.
Notably, golang/go#18974 indicates that the Go team doesn't consider it viable to include
ENOTDIR
in the handling foros.ErrNotExist
due to the number of ways that errno can be encountered.I can send a PR with a fix. (interestingly,
ENOTDIR
andENOENT
are the only two unix errnos defined for windows (and I'm pretty sure that means all platforms)cc: @codyoss
The text was updated successfully, but these errors were encountered: