From 93415b198a3ef427c02893b8fdf036aa75ffe50f Mon Sep 17 00:00:00 2001 From: "Joe Richey joerichey@google.com" Date: Wed, 21 Jun 2017 10:03:44 -0700 Subject: actions: error handling and API changed This commit changes the error handling for the actions package to use the error handling library github.com/pkg/errors. This means replacing "errors" with "github.com/pkg/errors", reworking some of the error values, and wrapping some errors with additional context. This commit also changes the Protector/Policy API, moving most of the package functionality into Protector or Policy methods. These types are now "locked" when they are queried from the filesystem, and Unlock() must be used to get their corresponding keys. Note that only certain operations will require unlocking the keys. Certain unnecessary functions and methods are also removed. This CL also fixes two bugs reported by Tyler Hicks in CreateConfigFile. CPU time is used instead of wall time, and kiB is used instead of kB. Change-Id: I88f45659e9fe4938d148843e3289e7b6d5b698d8 --- actions/callback.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actions/callback.go') diff --git a/actions/callback.go b/actions/callback.go index 18be670..2415d8c 100644 --- a/actions/callback.go +++ b/actions/callback.go @@ -21,10 +21,13 @@ package actions import ( + "log" + + "github.com/pkg/errors" + "fscrypt/crypto" "fscrypt/filesystem" "fscrypt/metadata" - "log" ) // ProtectorInfo is the information a caller will receive about a Protector @@ -91,7 +94,8 @@ func unwrapProtectorKey(info ProtectorInfo, keyFn KeyFunc) (*crypto.Key, error) protectorKey, err := crypto.Unwrap(wrappingKey, info.data.WrappedKey) wrappingKey.Wipe() - switch err { + + switch errors.Cause(err) { case nil: log.Printf("valid wrapping key for protector %s", info.Descriptor()) return protectorKey, nil -- cgit v1.2.3