Skip to content

Commit

Permalink
dir/server: allow complete Access file Lookup with AnyRight
Browse files Browse the repository at this point in the history
Closes a discrepancy Dave found when writing the DirCache:
It's possible to do a WhichAccess with only AnyRight and the blocks are
not removed (not marked incomplete), so it's possible to fetch the
blocks and Get the Access file. However, a Lookup would mark the blocks
as incomplete. This makes it so Access and Group files are readable by anyone with
AnyRights, since they're necessary for offline verification of rights.

Change-Id: I39d7cac3ddca37cb30fdcfc36a4c92a14ce10cdc
Reviewed-on: https://upspin-review.googlesource.com/10840
Reviewed-by: David Presotto <[email protected]>
Reviewed-by: Andrew Gerrand <[email protected]>
  • Loading branch information
edpin committed Jul 14, 2017
1 parent 26be9aa commit a674ac4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions dir/server/all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,25 @@ func TestPermissionDenied(t *testing.T) {
}
}

func TestAccessAndGroupFilesNotIncomplete(t *testing.T) {
const userAccess = userName + "/Access"
s, userCtx := newDirServerForTesting(t, userName)
// Access file permits List rights for otherUser.
_, err := putAccessOrGroupFile(t, s, userCtx, userAccess, "l:"+otherUser)
if err != nil {
t.Fatal(err)
}
sOther, _ := newDirServerForTesting(t, otherUser)

entry, err := sOther.Lookup(userAccess)
if err != nil {
t.Fatal(err)
}
if entry.IsIncomplete() {
t.Fatalf("Got incomplete entry, expected blocks")
}
}

func TestOverwriteFileWithWrongSequence(t *testing.T) {
s, userCtx := newDirServerForTesting(t, userName)
_, err := putAccessOrGroupFile(t, s, userCtx, userName+"/Access", "*:"+userName)
Expand Down
4 changes: 3 additions & 1 deletion dir/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ func (s *server) lookupWithPermissions(op string, name upspin.PathName, opts ...
if !canAny {
return nil, s.errPerm(op, p, opts...)
}
entry.MarkIncomplete()
if !access.IsAccessFile(name) && !access.IsGroupFile(name) {
entry.MarkIncomplete()
}
}
return entry, nil
}
Expand Down

0 comments on commit a674ac4

Please sign in to comment.