diff --git a/CHANGELOG.md b/CHANGELOG.md index 368e6e82..d806ef42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ FIX: Also update the Python SDK to include the permission mode and access grants fields on the `ShareRequest` (https://github.com/openziti/zrok/issues/432) +FIX: Add a way to find the username on Linux when /etc/passwd and stdlib can't resolve the UID (https://github.com/openziti/zrok/issues/454) + ## v0.4.26 FEATURE: New _permission modes_ available for shares. _Open permission mode_ retains the behavior of previous zrok releases and is the default setting. _Closed permission mode_ (`--closed`) only allows a share to be accessed (`zrok access`) by users who have been granted access with the `--access-grant` flag. See the documentation at (https://docs.zrok.io/docs/guides/permission-modes/) (https://github.com/openziti/zrok/issues/432) diff --git a/cmd/zrok/enable.go b/cmd/zrok/enable.go index fb49533f..ab24f0d2 100644 --- a/cmd/zrok/enable.go +++ b/cmd/zrok/enable.go @@ -56,13 +56,19 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) { if err != nil { panic(err) } + var username string user, err := user2.Current() if err != nil { - panic(err) + username := os.Getenv("USER") + if username == "" { + logrus.Panicf("unable to determine the current user: %v", err) + } + } else { + username = user.Username } - hostDetail = fmt.Sprintf("%v; %v", user.Username, hostDetail) + hostDetail = fmt.Sprintf("%v; %v", username, hostDetail) if cmd.description == "@" { - cmd.description = fmt.Sprintf("%v@%v", user.Username, hostName) + cmd.description = fmt.Sprintf("%v@%v", username, hostName) } zrok, err := env.Client() if err != nil {