"core": Get rid of "/..."-BlessingPatterns.
This is Part 3 of the plan described in
https://vanadium-review.googlesource.com/#/c/1757/
MultiPart: 1/3
Change-Id: I75dbf8c1b1f6d8953f09370bcb1af8795947a901
diff --git a/lib/modules/shell.go b/lib/modules/shell.go
index 85f8194..687ccb8 100644
--- a/lib/modules/shell.go
+++ b/lib/modules/shell.go
@@ -124,7 +124,7 @@
return nil, err
}
sh.blessing = blessing
- if _, err := p.BlessingStore().Set(blessing, security.BlessingPattern(blessingName+"/"+childBlessingExtension+"/...")); err != nil {
+ if _, err := p.BlessingStore().Set(blessing, security.BlessingPattern(blessingName+security.ChainSeparator+childBlessingExtension)); err != nil {
return nil, err
}
if err := p.AddToRoots(blessing); err != nil {
diff --git a/lib/testutil/security/util_test.go b/lib/testutil/security/util_test.go
index 440533a..a1e2927 100644
--- a/lib/testutil/security/util_test.go
+++ b/lib/testutil/security/util_test.go
@@ -66,7 +66,7 @@
func TestSaveACLToFile(t *testing.T) {
acl := access.TaggedACLMap{
"Admin": access.ACL{
- In: []security.BlessingPattern{"comics/..."},
+ In: []security.BlessingPattern{"comics"},
NotIn: []string{"comics/villain"},
},
}
diff --git a/runtimes/google/ipc/full_test.go b/runtimes/google/ipc/full_test.go
index da0d385..e40ece3 100644
--- a/runtimes/google/ipc/full_test.go
+++ b/runtimes/google/ipc/full_test.go
@@ -172,9 +172,8 @@
case "nilAuth":
authorizer = nil
case "aclAuth":
- // Only authorize clients matching patterns "client" or "server/...".
authorizer = &access.ACL{
- In: []security.BlessingPattern{"client", "server/..."},
+ In: []security.BlessingPattern{"client", "server"},
}
default:
authorizer = testServerAuthorizer{}
@@ -481,7 +480,8 @@
// Client does not talk to a server that presents
// expired blessings (because the blessing store is
- // configured to only talk to root/...).
+ // configured to only talk to peers with blessings matching
+ // the pattern "root").
{bServerExpired, "mountpoint/server", nil, verror.NotTrusted, vcErr},
// Client does not talk to a server that fails to
@@ -490,10 +490,10 @@
{bServerTPExpired, "mountpoint/server", nil, verror.NotTrusted, vcErr},
// Testing the AllowedServersPolicy option.
- {bServer, "mountpoint/server", options.AllowedServersPolicy{"otherroot/..."}, verror.NotTrusted, allowedErr},
- {bServer, "[root/server]mountpoint/server", options.AllowedServersPolicy{"otherroot/..."}, verror.NotTrusted, allowedErr},
+ {bServer, "mountpoint/server", options.AllowedServersPolicy{"otherroot"}, verror.NotTrusted, allowedErr},
+ {bServer, "[root/server]mountpoint/server", options.AllowedServersPolicy{"otherroot"}, verror.NotTrusted, allowedErr},
{bServer, "[otherroot/server]mountpoint/server", options.AllowedServersPolicy{"root/server"}, verror.NotTrusted, nameErr},
- {bServer, "[root/server]mountpoint/server", options.AllowedServersPolicy{"root/..."}, noErrID, ""},
+ {bServer, "[root/server]mountpoint/server", options.AllowedServersPolicy{"root"}, noErrID, ""},
// Server presents two blessings: One that satisfies
// the pattern provided to StartCall and one that
// satisfies the AllowedServersPolicy, so the server is
@@ -515,14 +515,14 @@
pserver.AddToRoots(pprovider.BlessingStore().Default())
// Set a blessing that the client is willing to share with servers with
// blessings from pprovider.
- pclient.BlessingStore().Set(bless(pprovider, pclient, "client"), "root/...")
+ pclient.BlessingStore().Set(bless(pprovider, pclient, "client"), "root")
for i, test := range tests {
name := fmt.Sprintf("(Name:%q, Server:%q, Allowed:%v)", test.name, test.server, test.allowed)
if err := pserver.BlessingStore().SetDefault(test.server); err != nil {
t.Fatalf("SetDefault failed on server's BlessingStore: %v", err)
}
- if _, err := pserver.BlessingStore().Set(test.server, "root/..."); err != nil {
+ if _, err := pserver.BlessingStore().Set(test.server, "root"); err != nil {
t.Fatalf("Set failed on server's BlessingStore: %v", err)
}
// Recreate client in each test (so as to not re-use VCs to the server).
@@ -547,9 +547,9 @@
// Currently all tests are configured so that the only
// blessings presented by the server that are
// recognized by the client match the pattern
- // "root/..."
- if len(blessings) < 1 || !security.BlessingPattern("root/...").MatchedBy(blessings...) {
- t.Errorf("%s: Client sees server as %v, expected a single blessing matching root/...", name, blessings)
+ // "root"
+ if len(blessings) < 1 || !security.BlessingPattern("root").MatchedBy(blessings...) {
+ t.Errorf("%s: Client sees server as %v, expected a single blessing matching root", name, blessings)
}
}
cancel()
@@ -963,7 +963,7 @@
// There are three different authorization policies (security.Authorizer implementations)
// used by the server, depending on the suffix (see testServerDisp.Lookup):
// - nilAuth suffix: the default authorization policy (only delegates of or delegators of the server can call RPCs)
- // - aclAuth suffix: the ACL only allows "server/..." or "client"
+ // - aclAuth suffix: the ACL only allows blessings matching the patterns "server" or "client"
// - other suffixes: testServerAuthorizer allows any principal to call any method except "Unauthorized"
// Expired blessings should fail nilAuth and aclAuth (which care about names), but should succeed on
@@ -1022,7 +1022,7 @@
_, dischargeServer := startServer(t, pdischarger, mgr, ns, dischargeServerName, testutil.LeafDispatcher(&dischargeServer{}, &acceptAllAuthorizer{}))
defer stopServer(t, dischargeServer, ns, dischargeServerName)
- // The server should recognize the client principal as an authority on "client/..." and "random/..." blessings.
+ // The server should recognize the client principal as an authority on "client" and "random" blessings.
pserver.AddToRoots(bClient)
pserver.AddToRoots(bRandom)
// And the client needs to recognize the server's and discharger's blessings to decide which of its
diff --git a/runtimes/google/naming/namespace/glob_test.go b/runtimes/google/naming/namespace/glob_test.go
index b85188e..c160ccf 100644
--- a/runtimes/google/naming/namespace/glob_test.go
+++ b/runtimes/google/naming/namespace/glob_test.go
@@ -31,7 +31,7 @@
input, mt, server, name string
}{
{"[foo/bar]", "", "foo/bar", ""},
- {"[x/y/...]/", "x/y/...", "", "/"},
+ {"[x/y]/", "x/y", "", "/"},
{"[foo]a", "", "foo", "a"},
{"[foo]/a", "foo", "", "/a"},
{"[foo]/a/[bar]", "foo", "bar", "/a"},
diff --git a/runtimes/google/rt/ipc_test.go b/runtimes/google/rt/ipc_test.go
index 95a95c1..fb9febf 100644
--- a/runtimes/google/rt/ipc_test.go
+++ b/runtimes/google/rt/ipc_test.go
@@ -121,7 +121,7 @@
)
// Setup the client's blessing store
pclient.BlessingStore().Set(alphaClient, "alpha/server")
- pclient.BlessingStore().Set(betaClient, "beta/...")
+ pclient.BlessingStore().Set(betaClient, "beta")
pclient.BlessingStore().Set(unrecognizedClient, security.AllPrincipals)
tests := []struct {
diff --git a/security/agent/test_principal/main.go b/security/agent/test_principal/main.go
index 036f30a..d7fa60e 100644
--- a/security/agent/test_principal/main.go
+++ b/security/agent/test_principal/main.go
@@ -105,7 +105,7 @@
if forpeer := p.BlessingStore().ForPeer("superman/friend"); forpeer != nil {
errorf("BlessingStore().ForPeer unexpectedly returned %v", forpeer)
}
- if old, err := p.BlessingStore().Set(b, "superman/..."); old != nil || err != nil {
+ if old, err := p.BlessingStore().Set(b, "superman"); old != nil || err != nil {
errorf("BlessingStore().Set returned (%v, %v)", old, err)
}
if forpeer := p.BlessingStore().ForPeer("superman/friend"); !reflect.DeepEqual(forpeer, b) {
diff --git a/security/blessingroots_test.go b/security/blessingroots_test.go
index 9e06948..a3bae58 100644
--- a/security/blessingroots_test.go
+++ b/security/blessingroots_test.go
@@ -27,8 +27,8 @@
root security.PublicKey
pattern security.BlessingPattern
}{
- {t[0], "veyron/..."},
- {t[1], "google/foo/..."},
+ {t[0], "veyron"},
+ {t[1], "google/foo"},
{t[0], "google/$"},
}
for _, d := range testdata {
diff --git a/security/blessingstore_test.go b/security/blessingstore_test.go
index a9b2906..a9c5581 100644
--- a/security/blessingstore_test.go
+++ b/security/blessingstore_test.go
@@ -21,11 +21,11 @@
pattern security.BlessingPattern
wantErr string
}{
- {t.forAll, "...", ""},
+ {t.forAll, security.AllPrincipals, ""},
{t.forAll, "$", ""},
- {t.forFoo, "foo/...", ""},
+ {t.forFoo, "foo", ""},
{t.forBar, "bar/$", ""},
- {t.other, "...", "public key does not match"},
+ {t.other, security.AllPrincipals, "public key does not match"},
{t.forAll, "", "invalid BlessingPattern"},
{t.forAll, "foo/$/bar", "invalid BlessingPattern"},
}
@@ -189,13 +189,11 @@
bob = blessSelf(p, "bob")
s = p.BlessingStore()
)
- // Set(alice, "alice")
- // Set(bob, "alice/...")
- // So, {alice, bob} is shared with "alice", whilst {bob} is shared with "alice/tv"
+ // {alice, bob} is shared with "alice", whilst {bob} is shared with "alice/tv"
if _, err := s.Set(alice, "alice/$"); err != nil {
t.Fatal(err)
}
- if _, err := s.Set(bob, "alice/..."); err != nil {
+ if _, err := s.Set(bob, "alice"); err != nil {
t.Fatal(err)
}
if got, want := s.ForPeer("alice"), unionOfBlessings(alice, bob); !reflect.DeepEqual(got, want) {
@@ -229,7 +227,7 @@
}
// Clear everything
- if _, err := s.Set(nil, "alice/..."); err != nil {
+ if _, err := s.Set(nil, "alice"); err != nil {
t.Fatal(err)
}
if got := s.ForPeer("alice"); got != nil {
@@ -251,16 +249,16 @@
s = p.BlessingStore()
)
- if old, err := s.Set(alice, "..."); old != nil || err != nil {
+ if old, err := s.Set(alice, security.AllPrincipals); old != nil || err != nil {
t.Errorf("Got (%v, %v)", old, err)
}
- if old, err := s.Set(alice, "..."); !reflect.DeepEqual(old, alice) || err != nil {
+ if old, err := s.Set(alice, security.AllPrincipals); !reflect.DeepEqual(old, alice) || err != nil {
t.Errorf("Got (%v, %v) want (%v, nil)", old, err, alice)
}
- if old, err := s.Set(bob, "..."); !reflect.DeepEqual(old, alice) || err != nil {
+ if old, err := s.Set(bob, security.AllPrincipals); !reflect.DeepEqual(old, alice) || err != nil {
t.Errorf("Got (%v, %v) want (%v, nil)", old, err, alice)
}
- if old, err := s.Set(nil, "..."); !reflect.DeepEqual(old, bob) || err != nil {
+ if old, err := s.Set(nil, security.AllPrincipals); !reflect.DeepEqual(old, bob) || err != nil {
t.Errorf("Got (%v, %v) want (%v, nil)", old, err, bob)
}
}
diff --git a/security/principal_test.go b/security/principal_test.go
index 3b3100c..99e512f 100644
--- a/security/principal_test.go
+++ b/security/principal_test.go
@@ -158,7 +158,7 @@
}{
{
matched: []security.Blessings{aliceworkfriend, aliceworkboss},
- pattern: "alice/work/...",
+ pattern: "alice/work",
},
{
matched: []security.Blessings{aliceworkfriend},
@@ -170,15 +170,15 @@
},
{
matched: []security.Blessings{aliceworkfriend, alicegymfriend, aliceworkboss},
- pattern: "alice/...",
+ pattern: "alice",
},
{
matched: []security.Blessings{aliceworkfriend, alicegymfriend, aliceworkboss},
- pattern: "...",
+ pattern: security.AllPrincipals,
},
{
matched: nil,
- pattern: "alice/school/...",
+ pattern: "alice/school",
},
}
diff --git a/services/mounttable/lib/mounttable_test.go b/services/mounttable/lib/mounttable_test.go
index 7ac6586..4919632 100644
--- a/services/mounttable/lib/mounttable_test.go
+++ b/services/mounttable/lib/mounttable_test.go
@@ -575,7 +575,7 @@
// Set up a mount, then set the ACL.
doMount(t, rootCtx, estr, "one/bright/day", fakeServer, nil, true)
checkMatch(t, []string{"one", "one/bright", "one/bright/day"}, doGlob(t, rootCtx, estr, "", "*/..."))
- acl := access.TaggedACLMap{"Read": access.ACL{In: []security.BlessingPattern{security.BlessingPattern("...")}}}
+ acl := access.TaggedACLMap{"Read": access.ACL{In: []security.BlessingPattern{security.AllPrincipals}}}
doSetACL(t, rootCtx, estr, "one/bright", acl, "", true)
// After the unmount we should still have everything above the ACL.
diff --git a/services/mounttable/lib/testdata/test.acl b/services/mounttable/lib/testdata/test.acl
index edfb36f..3a4d9eb 100644
--- a/services/mounttable/lib/testdata/test.acl
+++ b/services/mounttable/lib/testdata/test.acl
@@ -16,6 +16,6 @@
"Create": { "In": ["..."] }
},
"users/%%": {
- "Admin": { "In": ["%%/..."] }
+ "Admin": { "In": ["%%"] }
}
}
diff --git a/tools/mgmt/device/impl/acl_test.go b/tools/mgmt/device/impl/acl_test.go
index d195afa..27f4954 100644
--- a/tools/mgmt/device/impl/acl_test.go
+++ b/tools/mgmt/device/impl/acl_test.go
@@ -42,11 +42,11 @@
tape.SetResponses([]interface{}{GetACLResponse{
acl: access.TaggedACLMap{
"Admin": access.ACL{
- In: []security.BlessingPattern{"self/..."},
+ In: []security.BlessingPattern{"self"},
NotIn: []string{"self/bad"},
},
"Read": access.ACL{
- In: []security.BlessingPattern{"other", "self/..."},
+ In: []security.BlessingPattern{"other", "self"},
},
},
etag: "anEtagForToday",
@@ -58,7 +58,7 @@
}
if expected, got := strings.TrimSpace(`
other Read
-self/... Admin,Read
+self Admin,Read
self/bad !Admin
`), strings.TrimSpace(stdout.String()); got != expected {
t.Errorf("Unexpected output from get. Got %q, expected %q", got, expected)
@@ -128,10 +128,10 @@
tape.SetResponses([]interface{}{GetACLResponse{
acl: access.TaggedACLMap{
"Admin": access.ACL{
- In: []security.BlessingPattern{"self/..."},
+ In: []security.BlessingPattern{"self"},
},
"Read": access.ACL{
- In: []security.BlessingPattern{"other/...", "self/..."},
+ In: []security.BlessingPattern{"other", "self"},
NotIn: []string{"other/bob"},
},
},
@@ -142,10 +142,10 @@
GetACLResponse{
acl: access.TaggedACLMap{
"Admin": access.ACL{
- In: []security.BlessingPattern{"self/..."},
+ In: []security.BlessingPattern{"self"},
},
"Read": access.ACL{
- In: []security.BlessingPattern{"other/...", "self/..."},
+ In: []security.BlessingPattern{"other", "self"},
NotIn: []string{"other/bob/baddevice"},
},
},
@@ -156,17 +156,17 @@
})
// set command that:
- // - Adds entry for "friends/..." to "Write" & "Admin"
+ // - Adds entry for "friends" to "Write" & "Admin"
// - Adds a blacklist entry for "friend/alice" for "Admin"
- // - Edits existing entry for "self/..." (adding "Write" access)
+ // - Edits existing entry for "self" (adding "Write" access)
// - Removes entry for "other/bob/baddevice"
if err := cmd.Execute([]string{
"acl",
"set",
deviceName,
- "friends/...", "Admin,Write",
+ "friends", "Admin,Write",
"friends/alice", "!Admin,Write",
- "self/...", "Admin,Write,Read",
+ "self", "Admin,Write,Read",
"other/bob/baddevice", "^",
}); err != nil {
t.Fatalf("SetACL failed: %v", err)
@@ -184,15 +184,15 @@
fun: "SetACL",
acl: access.TaggedACLMap{
"Admin": access.ACL{
- In: []security.BlessingPattern{"friends/...", "self/..."},
+ In: []security.BlessingPattern{"friends", "self"},
NotIn: []string{"friends/alice"},
},
"Read": access.ACL{
- In: []security.BlessingPattern{"other/...", "self/..."},
+ In: []security.BlessingPattern{"other", "self"},
NotIn: []string{"other/bob"},
},
"Write": access.ACL{
- In: []security.BlessingPattern{"friends/...", "friends/alice", "self/..."},
+ In: []security.BlessingPattern{"friends", "friends/alice", "self"},
NotIn: []string(nil),
},
},
@@ -203,15 +203,15 @@
fun: "SetACL",
acl: access.TaggedACLMap{
"Admin": access.ACL{
- In: []security.BlessingPattern{"friends/...", "self/..."},
+ In: []security.BlessingPattern{"friends", "self"},
NotIn: []string{"friends/alice"},
},
"Read": access.ACL{
- In: []security.BlessingPattern{"other/...", "self/..."},
+ In: []security.BlessingPattern{"other", "self"},
NotIn: []string(nil),
},
"Write": access.ACL{
- In: []security.BlessingPattern{"friends/...", "friends/alice", "self/..."},
+ In: []security.BlessingPattern{"friends", "friends/alice", "self"},
NotIn: []string(nil),
},
},
@@ -258,7 +258,7 @@
tape.SetResponses([]interface{}{GetACLResponse{
acl: access.TaggedACLMap{
"Read": access.ACL{
- In: []security.BlessingPattern{"other", "self/..."},
+ In: []security.BlessingPattern{"other", "self"},
},
},
etag: "anEtagForToday",
@@ -283,7 +283,7 @@
fun: "SetACL",
acl: access.TaggedACLMap{
"Read": access.ACL{
- In: []security.BlessingPattern{"friend", "other", "self/..."},
+ In: []security.BlessingPattern{"friend", "other", "self"},
NotIn: []string(nil),
},
},
diff --git a/tools/principal/test.sh b/tools/principal/test.sh
index 73d7363..18a40d6 100755
--- a/tools/principal/test.sh
+++ b/tools/principal/test.sh
@@ -51,7 +51,7 @@
# This time use the --veyron.credentials flag to set the principal.
"${PRINCIPAL_BIN}" --veyron.credentials=./bob store setdefault alice.bless || shell_test::fail "line ${LINENO}: store setdefault failed"
"${PRINCIPAL_BIN}" --veyron.credentials=./bob store default >bob.store.default || shell_test::fail "line ${LINENO}: store default failed"
- "${PRINCIPAL_BIN}" --veyron.credentials=./bob store set alice.bless alice/... || shell_test::fail "line ${LINENO}: store set failed"
+ "${PRINCIPAL_BIN}" --veyron.credentials=./bob store set alice.bless alice || shell_test::fail "line ${LINENO}: store set failed"
"${PRINCIPAL_BIN}" --veyron.credentials=./bob store forpeer alice/server >bob.store.forpeer || shell_test::fail "line ${LINENO}: store forpeer failed"
# Run recvblessings on carol, and have alice send blessings over
@@ -64,8 +64,8 @@
$(${SEND_BLESSINGS_CMD}) || shell_test::fail "line ${LINENO}: ${SEND_BLESSINGS_CMD} failed"
grep "Received blessings: alice/friend/carol" carol.recvblessings >/dev/null || shell_test::fail "line ${LINENO}: recvblessings did not log any blessings received $(cat carol.recvblessings)"
# Run recvblessings on carol, and have alice send blessings over
- # (blessings received must be set as shareable with peers matching 'alice/...'.)
- "${PRINCIPAL_BIN}" --veyron.credentials=./carol --veyron.tcp.address=127.0.0.1:0 recvblessings --for_peer=alice/... --set_default=false >carol.recvblessings&
+ # (blessings received must be set as shareable with peers matching 'alice'.)
+ "${PRINCIPAL_BIN}" --veyron.credentials=./carol --veyron.tcp.address=127.0.0.1:0 recvblessings --for_peer=alice --set_default=false >carol.recvblessings&
shell::timed_wait_for "${shell_test_DEFAULT_MESSAGE_TIMEOUT}" carol.recvblessings "bless --remote_key" || shell_test::fail "line ${LINENO}: recvblessings did not print command for sender"
SEND_BLESSINGS_CMD=$(grep "bless --remote_key" carol.recvblessings | sed -e 's|extension[0-9]*|friend/carol/foralice|')
SEND_BLESSINGS_CMD="${PRINCIPAL_BIN_DIR}/${SEND_BLESSINGS_CMD}"
@@ -112,7 +112,7 @@
... : alice
---------------- BlessingRoots ----------------
Public key : Pattern
-XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice/...]
+XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice]
EOF
if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
@@ -167,11 +167,11 @@
Default blessings: alice/friend/carol
Peer pattern : Blessings
... : alice/friend/carol
-alice/... : alice/friend/carol/foralice
+alice : alice/friend/carol/foralice
---------------- BlessingRoots ----------------
Public key : Pattern
-XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice/...]
-XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [carol/...]
+XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice]
+XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [carol]
EOF
if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
@@ -186,7 +186,7 @@
... : alice/phone
---------------- BlessingRoots ----------------
Public key : Pattern
-XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice/...]
+XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice]
EOF
if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"
@@ -201,7 +201,7 @@
... : alice/phone/calendar
---------------- BlessingRoots ----------------
Public key : Pattern
-XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice/...]
+XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX : [alice]
EOF
if ! diff -C 5 got want; then
shell_test::fail "line ${LINENO}"