From e5c1b21fd369fe694ccd649fb6de0fa87b38c0e2 Mon Sep 17 00:00:00 2001 From: "Theodor S. Midtlien" Date: Mon, 21 Sep 2026 15:56:06 +0200 Subject: [PATCH] Fix listing unowned profile and fallback --- client/cmd/profile.go | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/client/cmd/profile.go b/client/cmd/profile.go index 51b4d6a0f..409543a19 100644 --- a/client/cmd/profile.go +++ b/client/cmd/profile.go @@ -162,21 +162,25 @@ func printProfiles(tw *tabwriter.Writer, header []string, profiles []*proto.Prof row = append(row, profilemanager.ID(profile.Id).ShortID()) } row = append(row, profilemanager.StripCtrlChars(profile.Name), marker) - if profileListShowOwner { - // An unowned profile is reachable by a privileged caller alone, so - // say so rather than leaving the column blank. - owner := "unowned" - if len(profile.Owners) > 0 { - owner = profilemanager.StripCtrlChars(profile.Owners[0]) - if _, exists := ownerCache[owner]; !exists { - ownerUsername, err := resolveOwnerUsername(owner) - if err != nil { - return err - } - ownerCache[owner] = ownerUsername + if !profileListShowOwner { + fmt.Fprintln(tw, strings.Join(row, "\t")) + continue + } + + var owner string + if len(profile.Owners) > 0 { + owner = profilemanager.StripCtrlChars(profile.Owners[0]) + if _, exists := ownerCache[owner]; !exists { + ownerUsername, err := resolveOwnerUsername(owner) + if err != nil { + // Lookup fail and we fallback to principal: uid: or sid: + ownerUsername = owner } + ownerCache[owner] = ownerUsername } - row = append(row, ownerCache[owner]) + row = append(row, profilemanager.StripCtrlChars(ownerCache[owner])) + } else { + row = append(row, "unowned") } fmt.Fprintln(tw, strings.Join(row, "\t")) }