aboutsummaryrefslogtreecommitdiff
path: root/actions
AgeCommit message (Collapse)Author
2020-01-05pam_fscrypt: update to handle filesystem keyringEric Biggers
FS_IOC_ADD_ENCRYPTION_KEY and FS_IOC_REMOVE_ENCRYPTION_KEY require root for v1 policy keys, so update the PAM module to re-acquire root privileges while provisioning/deprovisioning policies that need this. Also, only set up the user keyring if it will actually be used.
2020-01-05cmd/fscrypt: add 'fscrypt lock' commandEric Biggers
Add support for 'fscrypt lock'. This command "locks" a directory, undoing 'fscrypt unlock'. When the filesystem keyring is used, 'fscrypt lock' also detects when a directory wasn't fully locked due to some files still being in-use. It can then be run again later to try to finish locking the files.
2020-01-05keyring: support filesystem keyring with v1 encryption policiesEric Biggers
Linux v5.4 and later allows fscrypt keys to be added/removed directly to/from the filesystem via the new ioctls FS_IOC_ADD_ENCRYPTION_KEY and FS_IOC_REMOVE_ENCRYPTION_KEY. Among other benefits, these fix the key visibility problems that many users have been running into, where system services and containers can't access encrypted files. Allow the user to opt-in to using these new ioctls for their existing encrypted directories by setting in their /etc/fscrypt.conf: "use_fs_keyring_for_v1_policies": true Note that it can't really be on by default, since for v1 policies the ioctls require root, whereas user keyrings don't. I.e., setting this to true means that users will need to use 'sudo fscrypt unlock', not 'fscrypt unlock'. v2 policies won't have this restriction.
2020-01-05Add keyring packageEric Biggers
In preparation for introducing support for the new filesystem-level keyrings, move the existing user keyring management code from security/keyring.go and crypto/crypto.go into a new package, 'keyring'. This package provides functions AddEncryptionKey, RemoveEncryptionKey, and GetEncryptionKeyStatus which delegate to either the filesystem keyring (added by a later patch) or to the user keyring. This provides a common interface to both types of keyrings, to the extent possible.
2019-11-27Rename some variables from 'target' to 'targetUser'Eric Biggers
Refer to the target User as 'targetUser' rather than simply 'target'. This will help avoid confusion when we add support for the filesystem keyring, since then the Mount will also be a "target".
2019-11-27Use latest fscrypt declarations from sys/unixEric Biggers
Use the new name for fscrypt constants and structures which have been given a new name. Also use the named constant for the DIRECT_KEY fscrypt policy flag. No change in behavior. This is just preparing for future work.
2019-10-29filesystem: rename Mount.Filesystem to Mount.FilesystemTypeEric Biggers
Make it clear that this refers to a type of filesystem such as "ext4", rather than to a specific filesystem instance.
2019-10-23actions/config: ensure config file is created with mode 0644 (#152)ebiggers
If the user has set a restrictive umask, e.g. 0077, then /etc/fscrypt.conf would be created without the world-readable bit set. Fix it by overriding the umask when creating the file. Resolves https://github.com/google/fscrypt/issues/151
2019-09-09cmd/fscrypt: show encryption options with 'fscrypt status DIR' (#145)ebiggers
Show the encryption options when running 'fscrypt status' on a directory. E.g.: Policy: 490515286453d3f7 Options: padding:32 contents:Adiantum filenames:Adiantum Unlocked: Yes
2019-09-08Fix various typos and grammatical errors (#141)ebiggers
These were found by a combination of manual review and a custom script that checks for common errors. Also removed an outdated sentence from the comment for setupBefore().
2018-08-30Use proto.Equal instead of reflect.DeepEqualsJoe Richey joerichey@google.com
2018-02-11vet: eliminate unnecessary shadowingJoseph Richey
Running "go vet -shadow ./..." finds all places where a variable might be incorrectly or unnecessarily shadowed. This fixes some of them.
2018-02-09dep: Run dep ensureJoseph Richey
2018-01-10Format files correctlyJoe Richey joerichey@google.com
2018-01-10Limit the amount of RAM that will be usedJoe Richey joerichey@google.com
Fixes #73. Adds maxMemoryBytes as 128MiB and cleans up the helper functions/variables to make it more clear which values are a number of bytes, and which values are a number of KiB.
2017-09-01security: Change user keyring lookup algorithmJoseph Richey
Now instead of spawning a seperate thread we alternate between changing the euid and ruid to both find the keyring and link it to the process keyring. Note that we also ensure that the user keyring is linked into the root keyring whenever possible.
2017-08-30actions: context now hold a target user.UserJoe Richey
This user is used with policies to interface with the keryings and with protectors to indicate which user's login passphrase should be used to protectors of type pam_passphrase.
2017-08-22Various small nits a helper functions for PAMJoe Richey joerichey@google.com
2017-08-17cmd/fscrypt: purge command now clears cacheJoe Richey joerichey@google.com
2017-08-15crypto: Switch from session to user keyringJoe Richey joerichey@google.com
2017-08-07actions: calculate password hash difficulty correctlyEric Biggers
'fscrypt setup' is supposed to calibrate the Argon2 password hashing difficulty to 1s by default, but actually it was setting it to only 1s / num_cpus because the hashing is done with all CPUs and it is timed using the CLOCK_PROCESS_CPUTIME_ID clock, which measures the time spent by all threads in the process. Fix this by dividing the elapsed time by HashingCosts.Parallelism, which is used as the number of threads.
2017-07-18tests: Unit tests and Integration tests workJoe Richey joerichey@google.com
Now the testing functions will skip the integration tests if a testing filesystem is not specified.
2017-07-17actions: Fixed flaky hashing testJoe Richey joerichey@google.com
2017-07-17Small fixes so "make lint" doesn't complain.Joe Richey joerichey@google.com
2017-07-17actions: Add tests for policy unlockingJoe Richey joerichey@google.com
2017-07-17actions: Protectors can directly unlock PoliciesJoe Richey joerichey@google.com
In addition to using callbacks, unlocked Protectors can now directly unlock a policy. The error codes are updated to make more sense.
2017-07-14actions: Policies now have Description methodJoe Richey joerichey@google.com
2017-06-28Finalize import paths and documentationv0.1.00.1.0Joe Richey joerichey@google.com
This commit changes all the internal import paths from `fscrypt/foo` to `github.com/google/fscrypt/foo` so that it can be built once we release externaly. The documentation in README.md is updated accordingly. Also, the README has a note noting that we do not make any guarantees about project stability before 1.0 (when it ships with Ubuntu). Change-Id: I6ba86e442c74057c8a06ba32a42e17f94833e280
2017-06-28actions: error handling and API changedJoe Richey joerichey@google.com
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
2017-06-26actions: Simplify the callback mechanismJoe Richey joerichey@google.com
This commit makes the callbacks for getting keys easier to understand. Functions which need keys now take a KeyFunc callback. This callback contains a ProtectorInfo parameter (basically a read-only version of metadata.ProtectorData) and a boolean which indicates if the call is being retried. The documentation is also updated to say which functions will retry the KeyFunc. For selecting a protector, there is now an OptionFunc callback which takes a slice of ProtectorOptions. A ProtectorOption is a ProtectorInfo along with additional information about a linked filesystem (if applicable). This commit also adds in methods for getting the protector options for a specific filesystem or policy. It also adds a function for getting the policy descriptor for a specific path. Change-Id: I41e0d94ffd44e7166b0c5cf1b5d18437960bdf90
2017-05-31actions: creating and unlocking policiesJoe Richey joerichey@google.com
This commit adds in the Policy structure. This structure represents an unlocked policy key and its associated data. Policies can add or remove Protectors, apply encryption policies to filesystem directories, and provision a key into the kernel keyring. Change-Id: I089710223221e0ea60188d523703469e5d67ad0e
2017-05-31actions: creating and unlocking protectorsJoe Richey joerichey@google.com
This commit adds in the Protector struct to the actions package. This struct represents an unlocked Protector. They can be created from a context or they can be unlocked using some provided data. In either case, the data is provided via a callback mechanism. Change-Id: I066e965b8e8e0feeba61d9c0e4472dd08965cafb
2017-05-31actions: generate a config file for fscryptJoe Richey joerichey@google.com
This commit adds in the actions package. This package will be the highest-level interface to the fscrypt packages. The public functions in this package will be called directly from cmd/fscrypt. The actions added in this commit pertain to creating and reading the fscrypt global config file "fscrypt.conf". The challenging part about creating this file is finding the correct hashing parameters for the desired time target. The getHashingCosts() function finds the desired costs by doubling the costs and running the passphrase hash until the target is exceeded. Then, a cost estimate is obtained using a linear interpolation between the last two costs (and their time results). Change-Id: I4a0eaf4856ec4ff49eb4360da3267f7caa9d07b2