mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-26 22:39:07 +01:00
Fix listing unowned profile and fallback
This commit is contained in:
+17
-13
@@ -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.ID(profile.Id).ShortID())
|
||||||
}
|
}
|
||||||
row = append(row, profilemanager.StripCtrlChars(profile.Name), marker)
|
row = append(row, profilemanager.StripCtrlChars(profile.Name), marker)
|
||||||
if profileListShowOwner {
|
if !profileListShowOwner {
|
||||||
// An unowned profile is reachable by a privileged caller alone, so
|
fmt.Fprintln(tw, strings.Join(row, "\t"))
|
||||||
// say so rather than leaving the column blank.
|
continue
|
||||||
owner := "unowned"
|
}
|
||||||
if len(profile.Owners) > 0 {
|
|
||||||
owner = profilemanager.StripCtrlChars(profile.Owners[0])
|
var owner string
|
||||||
if _, exists := ownerCache[owner]; !exists {
|
if len(profile.Owners) > 0 {
|
||||||
ownerUsername, err := resolveOwnerUsername(owner)
|
owner = profilemanager.StripCtrlChars(profile.Owners[0])
|
||||||
if err != nil {
|
if _, exists := ownerCache[owner]; !exists {
|
||||||
return err
|
ownerUsername, err := resolveOwnerUsername(owner)
|
||||||
}
|
if err != nil {
|
||||||
ownerCache[owner] = ownerUsername
|
// Lookup fail and we fallback to principal: uid:<uid> or sid:<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"))
|
fmt.Fprintln(tw, strings.Join(row, "\t"))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user