From 6f2b58cbdc97c4d0ba554b5654e4d2555f1b2d02 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Wed, 14 Mar 2018 18:17:40 +0100 Subject: [PATCH] chore: esthetics + update changelog --- CHANGELOG.md | 1 + shell.go | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3562d70..f832991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Add TTY audit feature ([#23](https://github.com/moul/sshportal/issues/23)) by [@sabban](https://github.com/sabban) * Fix `--assign-*` commands when using MySQL driver ([#45](https://github.com/moul/sshportal/issues/45)) * Add *HOP* support, an efficient and integrated way of using a jump host transparently ([#47](https://github.com/moul/sshportal/issues/47)) by [@mathieui](https://github.com/mathieui) +* Fix panic on some `ls` commands ([#54](https://github.com/moul/sshportal/pull/54)) by [@jle64](https://github.com/jle64) ## v1.7.1 (2018-01-03) diff --git a/shell.go b/shell.go index 6d51cc7..699a6da 100644 --- a/shell.go +++ b/shell.go @@ -32,6 +32,10 @@ var banner = ` ` var startTime = time.Now() +const ( + naMessage = "n/a" +) + func shell(s ssh.Session) error { var ( sshCommand = s.Command() @@ -1862,11 +1866,9 @@ GLOBAL OPTIONS: table.SetBorder(false) table.SetCaption(true, fmt.Sprintf("Total: %d userkeys.", len(userKeys))) for _, userkey := range userKeys { - var email string + email := naMessage if userkey.User != nil { - email = userkey.User.Email - } else { - email = "n/a" + email = userkey.User.Email } table.Append([]string{ fmt.Sprintf("%d", userkey.ID), @@ -1967,17 +1969,13 @@ GLOBAL OPTIONS: duration = humanize.RelTime(session.CreatedAt, *session.StoppedAt, "", "") } duration = strings.Replace(duration, "now", "1 second", 1) - var hostname string + hostname := naMessage if session.Host != nil { - hostname = session.Host.Name - } else { - hostname = "n/a" + hostname = session.Host.Name } - var username string + username := naMessage if session.User != nil { - username = session.User.Name - } else { - username = "n/a" + username = session.User.Name } table.Append([]string{ fmt.Sprintf("%d", session.ID),