Skip to content
Permalink
Browse files

runtime/internal: Avoid use of os/user to generate default blessing

names.

The user of os/user causes trouble with statically linked binaries
(see golang/go#13470 and
https://sourceware.org/bugzilla/show_bug.cgi?id=19341)

The default blessing name generated doesn't really need os/user so
remove it.

Change-Id: I7105a269f63c855483c0296ac2919a50dff1e7ac
  • Loading branch information
asimshankar committed Mar 25, 2016
1 parent 8ccb1d0 commit f84dc4349e93c2933c3bbb8f18efcd453ebf8a8f
Showing with 12 additions and 14 deletions.
  1. +12 −14 runtime/internal/rt/security.go
@@ -6,8 +6,9 @@ package rt

import (
"fmt"
"math/rand"
"os"
"os/user"
"time"

"v.io/v23/context"
"v.io/v23/security"
@@ -86,20 +87,17 @@ func ipcAgent() (agent.Principal, error) {
}

func defaultBlessingName() string {
var name string
if user, _ := user.Current(); user != nil && len(user.Username) > 0 {
name = user.Username
} else {
name = "anonymous"
options := []string{
"apple", "banana", "cherry", "dragonfruit", "elderberry", "fig", "grape", "honeydew",
}
name := fmt.Sprintf("anonymous-%s-%d",
options[rand.New(rand.NewSource(time.Now().Unix())).Intn(len(options))],
os.Getpid())
host, _ := os.Hostname()
if host == "(none)" {
// (none) is a common default hostname and contains parentheses,
// which are invalid blessings characters.
host = "anonymous"
}
if len(host) > 0 {
name = name + "@" + host
// (none) is a common default hostname and contains parentheses,
// which are invalid blessings characters.
if host == "(none)" || len(host) == 0 {
return name
}
return fmt.Sprintf("%s-%d", name, os.Getpid())
return name + "@" + host
}

0 comments on commit f84dc43

Please sign in to comment.
You can’t perform that action at this time.