Handle hostname "(none)", a common default, in defaultBlessingName.
Change-Id: Iec2acd6f1eb01ac6113f7977c72272135559d8dc
diff --git a/runtime/internal/rt/security.go b/runtime/internal/rt/security.go
index 35d9427..c637ee1 100644
--- a/runtime/internal/rt/security.go
+++ b/runtime/internal/rt/security.go
@@ -80,7 +80,13 @@
} else {
name = "anonymous"
}
- if host, _ := os.Hostname(); len(host) > 0 {
+ 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
}
return fmt.Sprintf("%s-%d", name, os.Getpid())