]> git.apps.os.sepia.ceph.com Git - fscrypt.git/log
fscrypt.git
3 years agocli-tests: fix broken test
Eric Biggers [Wed, 19 Jan 2022 19:07:00 +0000 (11:07 -0800)]
cli-tests: fix broken test

I'm not sure how this passed the GitHub checks.

3 years agoMerge pull request #337 from google/broken-links
Eric Biggers [Wed, 19 Jan 2022 05:11:01 +0000 (21:11 -0800)]
Merge pull request #337 from google/broken-links

filesystem: store mountpoint in link files as a fallback

3 years agoMerge pull request #338 from google/remove-protector-from-policy
Eric Biggers [Wed, 19 Jan 2022 05:03:51 +0000 (21:03 -0800)]
Merge pull request #338 from google/remove-protector-from-policy

cmd/fscrypt: don't load protector in remove-protector-from-policy

3 years agocmd/fscrypt: don't load protector in remove-protector-from-policy
Eric Biggers [Thu, 23 Dec 2021 17:39:08 +0000 (11:39 -0600)]
cmd/fscrypt: don't load protector in remove-protector-from-policy

Make remove-protector-from-policy work even if the protector cannot be
loaded (for example, due to having been deleted already).

Fixes https://github.com/google/fscrypt/issues/258
Fixes https://github.com/google/fscrypt/issues/272

3 years agocli-tests: add helper functions to get protector descriptors
Eric Biggers [Thu, 23 Dec 2021 17:39:08 +0000 (11:39 -0600)]
cli-tests: add helper functions to get protector descriptors

3 years agofilesystem: store mountpoint in link files as a fallback
Eric Biggers [Thu, 23 Dec 2021 04:46:16 +0000 (22:46 -0600)]
filesystem: store mountpoint in link files as a fallback

Currently, linked protectors use filesystem link files of the form
"UUID=<uuid>".  These links get broken if the filesystem's UUID changes,
e.g. due to the filesystem being re-created even if the ".fscrypt"
directory is backed up and restored.

To prevent links from being broken (in most cases), start storing the
mountpoint path in the link files too, in the form
"UUID=<uuid>\nPATH=<path>\n".  When following a link, try the UUID
first, and if it doesn't work try the PATH.  While it's possible that
the path changed too, for login protectors (the usual use case of linked
protectors) this won't be an issue as the path will always be "/".

An alternative solution would be to fall back to scanning all
filesystems for the needed protector descriptor.  I decided not to do
that, since relying on a global scan doesn't seem to be a good design.
It wouldn't scale to large numbers of filesystems, it could cross
security boundaries, and it would make it possible for adding a new
filesystem to break fscrypt on existing filesystems.  And if a global
scan was an acceptable way to find protectors during normal use, then
there would be no need for link files in the first place.

Note: this change is backwards compatible (i.e., fscrypt will continue
to recognize old link files) but not forwards-compatible (i.e., previous
versions of fscrypt won't recognize new link files).

Fixes https://github.com/google/fscrypt/issues/311

3 years agoMerge pull request #336 from google/test-fix
Eric Biggers [Thu, 23 Dec 2021 02:45:23 +0000 (20:45 -0600)]
Merge pull request #336 from google/test-fix

context_text: remove pre-existing test.conf

3 years agocontext_text: remove pre-existing test.conf
Eric Biggers [Thu, 23 Dec 2021 02:36:28 +0000 (20:36 -0600)]
context_text: remove pre-existing test.conf

This fixes a test failure in the case where test.conf gets left over.

3 years agoMerge pull request #335 from google/fix-typos
Eric Biggers [Wed, 22 Dec 2021 05:29:41 +0000 (23:29 -0600)]
Merge pull request #335 from google/fix-typos

Fix a few typos

3 years agoFix a few typos
Eric Biggers [Wed, 22 Dec 2021 04:59:58 +0000 (22:59 -0600)]
Fix a few typos

3 years agoMerge pull request #334 from ebiggers/warn-on-chauthtok-fail
Eric Biggers [Wed, 22 Dec 2021 03:59:01 +0000 (21:59 -0600)]
Merge pull request #334 from ebiggers/warn-on-chauthtok-fail

pam_fscrypt: warn user if OLDAUTHTOK not given in chauthtok

3 years agopam_fscrypt: warn user if OLDAUTHTOK not given in chauthtok
Eric Biggers [Wed, 22 Dec 2021 02:38:03 +0000 (20:38 -0600)]
pam_fscrypt: warn user if OLDAUTHTOK not given in chauthtok

If someone runs 'passwd USER' as root, the user is assigned a new login
passphrase without their fscrypt login protector being updated.  Detect
this case and show a warning message using pam_info().

Fixes https://github.com/google/fscrypt/issues/273

3 years agoMerge pull request #333 from ebiggers/doc-encryption-solutions
Eric Biggers [Wed, 22 Dec 2021 03:21:34 +0000 (21:21 -0600)]
Merge pull request #333 from ebiggers/doc-encryption-solutions

README: elaborate on alternatives and threat model

3 years agoREADME: elaborate on alternatives and threat model
Eric Biggers [Wed, 22 Dec 2021 00:03:08 +0000 (18:03 -0600)]
README: elaborate on alternatives and threat model

Fixes https://github.com/google/fscrypt/issues/318

3 years agoREADME: write "Linux native filesystem encryption"
Eric Biggers [Wed, 22 Dec 2021 00:03:08 +0000 (18:03 -0600)]
README: write "Linux native filesystem encryption"

"Linux filesystem encryption" sounds too vague.  Write "Linux native
filesystem encryption" instead.

3 years agoMerge pull request #332 from ebiggers/skip-irrelevant-filesystems
Eric Biggers [Mon, 20 Dec 2021 17:28:26 +0000 (11:28 -0600)]
Merge pull request #332 from ebiggers/skip-irrelevant-filesystems

filesystem: avoid accessing irrelevant filesystems

3 years agofilesystem: avoid accessing irrelevant filesystems
Eric Biggers [Mon, 20 Dec 2021 04:17:20 +0000 (22:17 -0600)]
filesystem: avoid accessing irrelevant filesystems

Forbid 'fscrypt setup' on filesystems that aren't expected to support
encryption (other than the root filesystem), and skip looking for
fscrypt metadata directories on such filesystems.  This has two
benefits.  First, it avoids the printing of annoying warnings like:

pam_fscrypt[75038]: stat /run/user/0/.fscrypt: permission denied
pam_fscrypt[75038]: stat /run/user/0/.fscrypt/policies: permission denied
pam_fscrypt[75038]: stat /run/user/0/.fscrypt/protectors: permission denied
pam_fscrypt[75038]: stat /sys/firmware/efi/efivars/.fscrypt: invalid argument
pam_fscrypt[75038]: stat /sys/firmware/efi/efivars/.fscrypt/policies: invalid argument
pam_fscrypt[75038]: stat /sys/firmware/efi/efivars/.fscrypt/protectors: invalid argument
pam_fscrypt[75038]: stat /sys/fs/pstore/.fscrypt: permission denied
pam_fscrypt[75038]: stat /sys/fs/pstore/.fscrypt/policies: permission denied
pam_fscrypt[75038]: stat /sys/fs/pstore/.fscrypt/protectors: permission denied

Second, it avoids long delays or side effects on some filesystems.

To do this, introduce an allowlist of filesystem types that fscrypt will
recognize.  I wanted to avoid doing this, since this list will need to
be updated in the future, but I don't see a better solution.

3 years agoMerge pull request #331 from ebiggers/login-protector-perms
Eric Biggers [Mon, 20 Dec 2021 15:54:40 +0000 (09:54 -0600)]
Merge pull request #331 from ebiggers/login-protector-perms

Set owner of login protectors to correct user

3 years agoMerge pull request #329 from ebiggers/doc-ssh-issue
Eric Biggers [Mon, 20 Dec 2021 15:41:55 +0000 (09:41 -0600)]
Merge pull request #329 from ebiggers/doc-ssh-issue

README: document issue with ssh ChallengeResponseAuthentication

3 years agoMerge pull request #330 from google/avoid-warning
Eric Biggers [Mon, 20 Dec 2021 15:40:35 +0000 (09:40 -0600)]
Merge pull request #330 from google/avoid-warning

pam: avoid compiler warning in copyIntoSecret()

3 years agoSet owner of login protectors to correct user
Eric Biggers [Mon, 20 Dec 2021 03:19:25 +0000 (21:19 -0600)]
Set owner of login protectors to correct user

When the root user creates a login protector for a non-root user, make
sure to chown() the protector file to make it owned by the user.
Without this, the protector cannot be updated by the user, which causes
it to get out of sync if the user changes their login passphrase.

Fixes https://github.com/google/fscrypt/issues/319

3 years agopam: avoid compiler warning in copyIntoSecret()
Eric Biggers [Mon, 20 Dec 2021 03:20:54 +0000 (21:20 -0600)]
pam: avoid compiler warning in copyIntoSecret()

gcc 11 enabled -Wmaybe-uninitialized by default.  It causes a
false-positive warning in copyIntoSecret() because gcc doesn't
understand that mlock() is special and doesn't read from the memory.

Just initialize the memory to avoid this warning.

3 years agoREADME: document issue with ssh ChallengeResponseAuthentication
Eric Biggers [Mon, 20 Dec 2021 02:39:26 +0000 (20:39 -0600)]
README: document issue with ssh ChallengeResponseAuthentication

Update https://github.com/google/fscrypt/issues/321
Update https://github.com/google/fscrypt/issues/324

3 years agoMerge pull request #326 from dimitry-ishenko/stdin
Eric Biggers [Tue, 30 Nov 2021 03:51:38 +0000 (19:51 -0800)]
Merge pull request #326 from dimitry-ishenko/stdin

cmd/fscrypt: read key from stdin in non-interactive shell

3 years agocmd/fscrypt: read key from stdin
Dimitry Ishenko [Tue, 30 Nov 2021 01:25:56 +0000 (20:25 -0500)]
cmd/fscrypt: read key from stdin

Fixes #123

3 years agoRelease version v0.3.1
Eric Biggers [Mon, 18 Oct 2021 18:19:17 +0000 (11:19 -0700)]
Release version v0.3.1

3 years agoAdjust recovery passphrase generation
Eric Biggers [Tue, 14 Sep 2021 21:12:39 +0000 (14:12 -0700)]
Adjust recovery passphrase generation

As per the feedback at https://github.com/google/fscrypt/issues/115
where users didn't understand that the recovery passphrase is important,
restore the original behavior where recovery passphrase generation
happens automatically without a prompt.  This applies to the case where
'fscrypt encrypt' is using a login protector on a non-root filesystem.

However, leave the --no-recovery option so that the recovery passphrase
can still be disabled if the user really wants to.  Also, clarify the
information provided about the recovery passphrase.

Update https://github.com/google/fscrypt/issues/115

4 years agoMerge pull request #317 from ebiggers/readme-symlink-bug
Joseph Richey [Wed, 22 Sep 2021 19:24:19 +0000 (12:24 -0700)]
Merge pull request #317 from ebiggers/readme-symlink-bug

README: mention LTS kernel versions with symlink bug fix

4 years agoREADME: mention LTS kernel versions with symlink bug fix
Eric Biggers [Wed, 22 Sep 2021 18:00:27 +0000 (11:00 -0700)]
README: mention LTS kernel versions with symlink bug fix

Resolves https://github.com/google/fscrypt/issues/305

4 years agocmd/fscrypt: recognize no-key names containing hyphen
Eric Biggers [Tue, 14 Sep 2021 21:37:46 +0000 (14:37 -0700)]
cmd/fscrypt: recognize no-key names containing hyphen

In Linux 5.15, the no-key name format is changing again; see
https://git.kernel.org/linus/ba47b515f5940603.  isPossibleNoKeyName()
sometimes doesn't recognize the new no-key names.  Update it accordingly
to recognize all possible no-key names.

Note: isPossibleNoKeyName() is only used as a heuristic to check whether
a v1-encrypted directory is incompletely locked or not.  Therefore, it's
not too important whether it works.  However, this change is needed for
cli-tests/t_v1_policy to pass.

4 years agocli-tests/common.sh: remove argument count checks
Eric Biggers [Tue, 14 Sep 2021 21:27:59 +0000 (14:27 -0700)]
cli-tests/common.sh: remove argument count checks

These confuse the latest version of shellcheck into thinking that
functions which take no arguments actually take arguments, which
triggers a bunch of warnings like "Use func "$@" if function's $1 should
mean script's $1", which causes 'make lint' to fail.  These checks
aren't too useful, so just remove them.

4 years agoREADME: clarify how restoring /.fscrypt directory works
Eric Biggers [Tue, 14 Sep 2021 18:07:42 +0000 (11:07 -0700)]
README: clarify how restoring /.fscrypt directory works

Update https://github.com/google/fscrypt/issues/115

4 years agoMerge pull request #310 from ebiggers/readme-updates
Joseph Richey [Tue, 14 Sep 2021 03:16:07 +0000 (20:16 -0700)]
Merge pull request #310 from ebiggers/readme-updates

Readme updates

4 years agoREADME: add section about encrypting existing files
Eric Biggers [Mon, 13 Sep 2021 23:23:50 +0000 (16:23 -0700)]
README: add section about encrypting existing files

4 years agoREADME: consistently format section titles
Eric Biggers [Mon, 13 Sep 2021 21:45:34 +0000 (14:45 -0700)]
README: consistently format section titles

Capitalize the first word only, and don't use periods.

4 years agoREADME: add section about backup, restore, and recovery
Eric Biggers [Mon, 13 Sep 2021 19:40:14 +0000 (12:40 -0700)]
README: add section about backup, restore, and recovery

Resolves https://github.com/google/fscrypt/issues/51
Resolves https://github.com/google/fscrypt/issues/115

4 years agoREADME: remove note about stability
Eric Biggers [Mon, 13 Sep 2021 19:40:14 +0000 (12:40 -0700)]
README: remove note about stability

A lot of people are already using fscrypt, so in practice we haven't
been breaking backwards compatibility and aren't going to.  Just remove
the scary-sounding "Note about stability".

4 years agoREADME: remove note about planned commands
Eric Biggers [Mon, 13 Sep 2021 19:40:14 +0000 (12:40 -0700)]
README: remove note about planned commands

These would still be nice to add.  However, the mention of them in the
README is misleading because people reading it might come away with the
impression that there is currently no way to back up fscrypt metadata or
to recover directories -- which isn't true.  (The fscrypt metadata is
just a directory which can be backed up like any other directory.  And
'fscrypt encrypt' already offers to generate a recovery passphrase when
the directory and protector are on different filesystems.)

Just remove this note; it doesn't really add any value.

4 years agoMerge pull request #309 from ebiggers/troubleshooting
Joseph Richey [Wed, 1 Sep 2021 02:14:08 +0000 (19:14 -0700)]
Merge pull request #309 from ebiggers/troubleshooting

Updates to the troubleshooting documentation

4 years agoREADME: document symlink size bug
Eric Biggers [Tue, 31 Aug 2021 23:47:00 +0000 (16:47 -0700)]
README: document symlink size bug

Update https://github.com/google/fscrypt/issues/305

4 years agoREADME: documentation tweaks
Eric Biggers [Thu, 26 Aug 2021 22:54:06 +0000 (15:54 -0700)]
README: documentation tweaks

Clarify some of the troubleshooting documentation.

4 years agocli-tests: fix failure with latest bash version
Eric Biggers [Fri, 16 Jul 2021 22:59:26 +0000 (17:59 -0500)]
cli-tests: fix failure with latest bash version

4 years agoREADME: add troubleshooting section for ENOPKG error
Eric Biggers [Fri, 16 Jul 2021 22:31:58 +0000 (17:31 -0500)]
README: add troubleshooting section for ENOPKG error

Inspired by https://reddit.com/r/linuxquestions/comments/n75dv4

4 years agoREADME: add troubleshooting section for keyring linkage issue
Eric Biggers [Sun, 27 Jun 2021 21:56:15 +0000 (14:56 -0700)]
README: add troubleshooting section for keyring linkage issue

Fixes https://github.com/google/fscrypt/issues/194
Update https://github.com/google/fscrypt/issues/100

4 years agocmd/fscrypt: fix detection of GRUB installation
Eric Biggers [Sun, 27 Jun 2021 20:13:10 +0000 (13:13 -0700)]
cmd/fscrypt: fix detection of GRUB installation

Fix the GRUB detection logic to take into account that
MOUNTPOINT/boot/grub might not be on the same filesystem as MOUNTPOINT,
due to MOUNTPOINT/boot being another mountpoint.  The warning is only
appropriate when GRUB is installed on the same filesystem that
encryption is going to be enabled on.

4 years agoREADME: improve troubleshooting tips for unlocked encrypted files
Eric Biggers [Thu, 10 Jun 2021 04:21:22 +0000 (21:21 -0700)]
README: improve troubleshooting tips for unlocked encrypted files

Rename the troubleshooting section "Can't log in with ssh even when
user's encrypted home directory is unlocked" to the more general "Some
processes can't access unlocked encrypted files", and rewrite it to
provide clearer directions for how to fix the problem by upgrading
encrypted directories to policy version 2.

Also add a related section "Users can access other users' unlocked
encrypted files" which covers the reverse "issue", i.e. people expecting
some processes to *not* be able to access unlocked encrypted files.

Fixes https://github.com/google/fscrypt/issues/248

4 years agoREADME: improve troubleshooting section for login protector not in sync
Eric Biggers [Tue, 8 Jun 2021 23:23:04 +0000 (16:23 -0700)]
README: improve troubleshooting section for login protector not in sync

Update https://github.com/google/fscrypt/issues/273

4 years agoMerge pull request #292 from josephlr/mem
Joseph Richey [Tue, 25 May 2021 05:18:42 +0000 (22:18 -0700)]
Merge pull request #292 from josephlr/mem

Only use 1/8 of the system RAM and run the Garbage Collector in the timing loop

4 years agoRun the Garbage Collector in the timing loop
Joe Richey [Mon, 24 May 2021 10:42:01 +0000 (03:42 -0700)]
Run the Garbage Collector in the timing loop

Running `crypto.PassphraseHash` in a loop allocates a lot of memory.
Golang is not always prudent about collecting the garbage from previous
runs, resulting in a OOM error on memory-pressured systems.

With a `maxMemoryBytes` of 128 MiB, this change reduces the maximum
resident memory for `fscrypt setup` to 141 MiB (was perviously 405 MiB)

Signed-off-by: Joe Richey <joerichey@google.com>
4 years agoOnly use 1/8 of the system RAM
Joe Richey [Mon, 24 May 2021 10:41:16 +0000 (03:41 -0700)]
Only use 1/8 of the system RAM

On systems with high memory pressure, using half of the entire RAM for
hashing can result in fscrypt getting OOM killed.

Signed-off-by: Joe Richey <joerichey@google.com>
4 years agofilesystem: skip TestHaveReadAccessTo() when running as root
Eric Biggers [Wed, 12 May 2021 20:28:30 +0000 (13:28 -0700)]
filesystem: skip TestHaveReadAccessTo() when running as root

Root can read all files, so this test fails when running as root.
Skip it instead.

Resolves https://github.com/google/fscrypt/issues/288

4 years agoSpecify -buildmode=c-shared after GO_FLAGS rather than before
Eric Biggers [Thu, 6 May 2021 05:09:26 +0000 (22:09 -0700)]
Specify -buildmode=c-shared after GO_FLAGS rather than before

When building pam_fscrypt.so, specify -buildmode=c-shared after
$(GO_FLAGS) so that it overrides any user-specified buildmode.

This is needed to allow -buildmode=pie to be specified in GO_FLAGS if
the packager wants to build fscrypt as a position-independent executable
(e.g. following https://wiki.archlinux.org/title/Go_package_guidelines).
Previously, trying to do this caused pam_fscrypt.so to be incorrectly
built as an executable rather than as a shared library.

4 years agocmd/fscrypt: fix word mismatch "protector" => "policy"
Gibeom Gwon [Tue, 27 Apr 2021 10:49:01 +0000 (19:49 +0900)]
cmd/fscrypt: fix word mismatch "protector" => "policy"

Fix word mismatch in usage and description of metadata create policy
command.

4 years agocmd/fscrypt: use golang.org/x/term
Tobias Klauser [Thu, 22 Apr 2021 11:53:56 +0000 (13:53 +0200)]
cmd/fscrypt: use golang.org/x/term

The golang.org/x/crypto/ssh/terminal package is deprecated and merely a
wrapper around golang.org/x/term. Thus, use the latter directly.

4 years agoMakefile: Optionally avoid installation of Ubuntu-specific PAM config
Florian Schmaus [Sat, 17 Apr 2021 16:19:59 +0000 (18:19 +0200)]
Makefile: Optionally avoid installation of Ubuntu-specific PAM config

This allows non Ubuntu distributions to opt out from the installation
of Ubuntu-specific PAM files.

4 years agoRelease version v0.3.0 (#282)
Eric Biggers [Wed, 31 Mar 2021 23:19:39 +0000 (16:19 -0700)]
Release version v0.3.0 (#282)

4 years agoMerge pull request #283 from google/coverage
Joseph Richey [Wed, 31 Mar 2021 23:08:48 +0000 (16:08 -0700)]
Merge pull request #283 from google/coverage

Stop generating and uploading coverage in CI

4 years agoOnly run CI on master branch and PRs to master
Joe Richey [Wed, 31 Mar 2021 23:00:16 +0000 (16:00 -0700)]
Only run CI on master branch and PRs to master

This avoids duplicate CI checks

Signed-off-by: Joe Richey <joerichey@google.com>
4 years agoStop generating and uploading coverage in CI
Joe Richey [Wed, 31 Mar 2021 22:46:18 +0000 (15:46 -0700)]
Stop generating and uploading coverage in CI

This is currently broken, and we don't really use the findings.

Signed-off-by: Joe Richey <joerichey@google.com>
4 years agoMerge pull request #281 from ebiggers/pam_fscrypt-updates
Joseph Richey [Tue, 9 Mar 2021 09:27:42 +0000 (01:27 -0800)]
Merge pull request #281 from ebiggers/pam_fscrypt-updates

pam_fscrypt: eliminate unnecessary options and improve documentation

4 years agoREADME: improve PAM configuration documentation (again)
Eric Biggers [Mon, 8 Mar 2021 23:20:08 +0000 (15:20 -0800)]
README: improve PAM configuration documentation (again)

Make some more corrections:

- pam-config-framework isn't actually Ubuntu-specific but actually
  applies to Debian and any Debian derivative.

- The pam-config-framework file is indeed installed by `make install`,
  just not into the correct location.

- On Debian (and Debian derivatives), the PAM configuration isn't
  actually part of the 'fscrypt' package but rather 'libpam-fscrypt'.

- Clarify where to add the pam_fscrypt.so session hook.

4 years agoREADME: make it clear that pam_fscrypt also handles locking
Eric Biggers [Mon, 8 Mar 2021 23:20:08 +0000 (15:20 -0800)]
README: make it clear that pam_fscrypt also handles locking

There are several mentions of pam_fscrypt handling unlocking
directories.  Make sure to mention locking alongside this.

4 years agopam_fscrypt: make "lock_policies" the default behavior
Eric Biggers [Mon, 8 Mar 2021 23:20:08 +0000 (15:20 -0800)]
pam_fscrypt: make "lock_policies" the default behavior

All pam_fscrypt configuration guides that I'm aware of say to use the
"lock_policies" option for the pam_fscrypt.so session hook.  The
Debian/Ubuntu pam-config-framework config file has it too.

Make locking the default behavior, since this is what everyone wants.

Existing configuration files that contain the "lock_policies" option
will continue to work, but that option won't do anything anymore.

(We could add an option "unlock_only" to restore the old default
behavior, but it's not clear that it would be useful.  So for
simplicity, leave it out for now.)

4 years agopam_fscrypt: decide cache dropping behavior automatically
Eric Biggers [Mon, 8 Mar 2021 23:20:08 +0000 (15:20 -0800)]
pam_fscrypt: decide cache dropping behavior automatically

Configuring whether pam_fscrypt drops caches or not isn't really
something the user should have to do, and it's also irrelevant for v2
encryption policies (the default on newer systems).  It's better to have
pam_fscrypt automatically decide whether it needs to drop caches or not.

Do this by making pam_fscrypt check whether any encryption policy keys
are being removed from a user keyring (rather than from a filesystem
keyring).  If so, it drops caches; otherwise it doesn't.  This
supersedes the "drop_caches" option, which won't do anything anymore.

4 years agopam_fscrypt/config: prioritise over other session modules
Robert McQueen [Wed, 3 Mar 2021 11:34:55 +0000 (11:34 +0000)]
pam_fscrypt/config: prioritise over other session modules

Services launched by systemd user sessions on Debian / Ubuntu systems
are often not able to access the home directory, because there is no
guarantee / requirement that pam_fscrypt is sequenced before
pam_systemd.

Although this pam-config mechanism is Debian-specific, the config file
is provided here upstream and unmodified in Debian. Raising the
priority here so that it's always ordered ahead of pam_systemd will
solve issues such as https://github.com/google/fscrypt/issues/270,
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=964951 and
https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1889416.

After a survey of pam-config files available in Debian bullseye, the
value of 100 was chosen as it appears after most other plugins that
could be involved in more explicit homedir configuration (eg pam_mount
at 128) but before those which seem unlikely to work without a home
directory (eg pam_ssh at 64).

4 years agoci.yml: always run apt-get update
Eric Biggers [Wed, 3 Feb 2021 00:14:30 +0000 (16:14 -0800)]
ci.yml: always run apt-get update

In GitHub Workflows, apparently running 'apt-get update' before 'apt-get
install' is sometimes needed, and it doesn't hurt to always do it.

4 years agoAvoid using the word "whitelist"
Eric Biggers [Mon, 25 Jan 2021 19:12:01 +0000 (11:12 -0800)]
Avoid using the word "whitelist"

4 years agocmd/fscrypt: fix missing protector error format
Alastair Hughes [Fri, 15 Jan 2021 10:08:54 +0000 (23:08 +1300)]
cmd/fscrypt: fix missing protector error format

Update #272

4 years agobash-completion: add completion script
Henry-Joseph Audéoud [Fri, 30 Oct 2020 10:41:52 +0000 (11:41 +0100)]
bash-completion: add completion script

4 years agoREADME: Fix badge image
Joe Richey [Thu, 26 Nov 2020 09:25:12 +0000 (01:25 -0800)]
README: Fix badge image

Workflow names are case-sensitive

Signed-off-by: Joe Richey <joerichey@google.com>
4 years agoSwitch from Travis CI to GitHub Actions
Eric Biggers [Sat, 21 Nov 2020 23:29:26 +0000 (15:29 -0800)]
Switch from Travis CI to GitHub Actions

travis-ci.org is being shut down, so switch to GitHub Actions.

It should be mostly equivalent, but I did drop functionality in a couple
cases:

- Publishing release binaries.  I don't think providing Linux binaries
  is useful, since people build their own anyway.  So I left this out.

- Build and testing on ppc64le.  GitHub Actions only natively supports
  x86.  I tried uraimo/run-on-arch-action, which uses Docker and QEMU
  user-mode emulation, but the fscrypt tests can't be run because
  QEMU user-mode emulation doesn't support all the needed system calls.

4 years agocli-tests: force processes spawned by 'expect' to have 80 column-output
Eric Biggers [Sat, 21 Nov 2020 23:29:26 +0000 (15:29 -0800)]
cli-tests: force processes spawned by 'expect' to have 80 column-output

Otherwise the cli tests fail when executed from GitHub Actions.

4 years agoREADME.md: add table of contents
Eric Biggers [Tue, 10 Nov 2020 04:43:48 +0000 (20:43 -0800)]
README.md: add table of contents

4 years agotravis.yml: upgrade to Ubuntu 20.04 and enable cli tests
Eric Biggers [Sun, 8 Nov 2020 04:30:51 +0000 (20:30 -0800)]
travis.yml: upgrade to Ubuntu 20.04 and enable cli tests

Now that Travis CI supports a version of Ubuntu that has a kernel that
supports v2 encryption policies, upgrade to it and enable the cli tests.

4 years agocmd/fscrypt: fix race condition in getPassphraseKey()
Eric Biggers [Sun, 8 Nov 2020 04:30:51 +0000 (20:30 -0800)]
cmd/fscrypt: fix race condition in getPassphraseKey()

Set the terminal to raw mode *before* printing the prompt.
Otherwise the user (or the automated test) might enter the
passphrase before the terminal gets put into raw mode.

This is needed for some of the CLI tests to pass reliably in Travis CI.

4 years agocli-tests/common.sh: fix _user_do()
Eric Biggers [Sun, 8 Nov 2020 04:30:51 +0000 (20:30 -0800)]
cli-tests/common.sh: fix _user_do()

Apparently, on some distros 'su' doesn't preserve $PATH.  So, manually
export it in the command.  Also, ensure that the shell stays as bash.

This is needed for some of the CLI tests to pass in Travis CI.

4 years agocmd/fscrypt: fix isDirUnlockedHeuristic() on latest kernels
Eric Biggers [Sat, 7 Nov 2020 22:20:45 +0000 (14:20 -0800)]
cmd/fscrypt: fix isDirUnlockedHeuristic() on latest kernels

On an "incompletely locked" directory, isDirUnlockedHeuristic() is
supposed to return true, but on Linux v5.10-rc1 and later it returns
false since now creating a subdirectory fails rather than succeeds.
This change was intentional, so make isDirUnlockedHeuristic() apply a
second heuristic too: also return true if any filenames in the directory
don't appear to be valid no-key names.

This fixes cli-tests/t_v1_encrypt on Linux v5.10-rc1 and later.

4 years agoTravis-ci: added support for ppc64le (#257)
sanjaymsh [Thu, 15 Oct 2020 12:27:25 +0000 (17:57 +0530)]
Travis-ci: added support for ppc64le (#257)

5 years agoFix nil error issue, Resolves https://github.com/google/fscrypt/issues/242
bitcodr [Fri, 7 Aug 2020 05:34:34 +0000 (10:04 +0430)]
Fix nil error issue, Resolves https://github.com/google/fscrypt/issues/242

5 years agoREADME.md: recommend 'sudo make install PREFIX=/usr' on Ubuntu (#244)
Eric Biggers [Fri, 7 Aug 2020 23:37:05 +0000 (16:37 -0700)]
README.md: recommend 'sudo make install PREFIX=/usr' on Ubuntu (#244)

Ubuntu's PAM configuration framework only recognizes files in /usr, not
/usr/local.  So for installs from source, unfortunately we have to
recommend installing to /usr, despite this not being conventional.

Resolves https://github.com/google/fscrypt/issues/240

5 years agoRelease version v0.2.9 (#238)
Eric Biggers [Sat, 13 Jun 2020 17:43:29 +0000 (10:43 -0700)]
Release version v0.2.9 (#238)

5 years agoMerge pull request #237 from ebiggers/t_v1_policy_fix
Eric Biggers [Sat, 13 Jun 2020 17:27:57 +0000 (10:27 -0700)]
Merge pull request #237 from ebiggers/t_v1_policy_fix

Adjust status message for v1 policies unlocked by another user and fix cli-tests/t_v1_policy

5 years agocmd/fscrypt: adjust status message for v1-encrypted dirs
Eric Biggers [Sat, 13 Jun 2020 17:06:15 +0000 (10:06 -0700)]
cmd/fscrypt: adjust status message for v1-encrypted dirs

When 'fscrypt status DIR' detects that a v1-encrypted directory is still
usable but its key seems to be absent, it shows the status as
"Unlocked: Partially (incompletely locked)".  But actually it can also
be the case that the directory is unlocked by another user.  Adjust the
status message accordingly.

This commit also fixes cli-tests/t_v1_policy.

5 years agocli-tests/t_v1_policy: clean up user keyrings at end of test
Eric Biggers [Sat, 13 Jun 2020 17:06:15 +0000 (10:06 -0700)]
cli-tests/t_v1_policy: clean up user keyrings at end of test

The test user's user keyring is still linked into root's user keyring at
the end of the test.  This is making the test flaky, as there is a
failure that only occurs the first time it is run.  Fix the test to
restore the initial state.  This makes it consistently fail (to be fixed
by the next commit).

5 years agoMerge pull request #235 from ebiggers/32bit-fix
Eric Biggers [Wed, 3 Jun 2020 01:02:08 +0000 (18:02 -0700)]
Merge pull request #235 from ebiggers/32bit-fix

* cmd/fscrypt: fix 32-bit build
* travis.yml: build 32-bit binary

5 years agocmd/fscrypt: fix 32-bit build
Eric Biggers [Wed, 3 Jun 2020 00:17:54 +0000 (17:17 -0700)]
cmd/fscrypt: fix 32-bit build

statfs.Bsize actually has platform-dependent type, despite the Go
documentation listing it as int64.  Fix the build for 32-bit platforms
by casting it to int64.

Resolves https://github.com/google/fscrypt/issues/233

5 years agotravis.yml: build 32-bit binary
Eric Biggers [Wed, 3 Jun 2020 00:09:21 +0000 (17:09 -0700)]
travis.yml: build 32-bit binary

Don't let people check in code that breaks 32-bit builds.

Update https://github.com/google/fscrypt/issues/233

5 years agoRelease version v0.2.8 (#230)
Eric Biggers [Wed, 20 May 2020 10:36:16 +0000 (03:36 -0700)]
Release version v0.2.8 (#230)

5 years agocmd/fscrypt: fix up path formatting in ErrDirNotEmpty suggestion (#229)
Eric Biggers [Fri, 15 May 2020 02:48:23 +0000 (19:48 -0700)]
cmd/fscrypt: fix up path formatting in ErrDirNotEmpty suggestion (#229)

Use %q, in case the paths contain whitespace.  Also clean the directory
path to remove trailing slashes before appending the ".new" suffix.

5 years agocmd/fscrypt: link to guide when interactively creating login protector (#225)
Eric Biggers [Thu, 14 May 2020 02:14:13 +0000 (19:14 -0700)]
cmd/fscrypt: link to guide when interactively creating login protector (#225)

Update https://github.com/google/fscrypt/issues/220

5 years agoREADME.md: try to disambiguate "fscrypt" (#226)
Eric Biggers [Thu, 14 May 2020 02:11:28 +0000 (19:11 -0700)]
README.md: try to disambiguate "fscrypt" (#226)

Explicitly mention that "fscrypt" here means the userspace tool, not the
kernel part.  Also write `fscrypt` in code font to emphasize this.

5 years agoREADME.md: further improve the "encryption not enabled" section (#227)
Eric Biggers [Thu, 14 May 2020 02:10:18 +0000 (19:10 -0700)]
README.md: further improve the "encryption not enabled" section (#227)

5 years agoREADME.md: fix typo "nrounds" => "rounds" (#228)
Eric Biggers [Thu, 14 May 2020 01:53:56 +0000 (18:53 -0700)]
README.md: fix typo "nrounds" => "rounds" (#228)

Update https://github.com/google/fscrypt/issues/220

5 years agoREADME.md: improve documentation for login protectors (#223)
Eric Biggers [Tue, 12 May 2020 16:45:42 +0000 (09:45 -0700)]
README.md: improve documentation for login protectors (#223)

Update https://github.com/google/fscrypt/issues/220

5 years agoDeclare instead of define variable in header file. (#224)
Shuai Wang [Sun, 10 May 2020 21:22:54 +0000 (14:22 -0700)]
Declare instead of define variable in header file. (#224)

This fixes link error with gcc 10 which defaults to -fno-common

5 years agoMerge pull request #219 from ebiggers/improve-errors
Eric Biggers [Sat, 9 May 2020 22:27:24 +0000 (15:27 -0700)]
Merge pull request #219 from ebiggers/improve-errors

Improve error messages and suggestions

5 years agocmd/fscrypt: improve errors
Eric Biggers [Sat, 9 May 2020 21:52:07 +0000 (14:52 -0700)]
cmd/fscrypt: improve errors

In checkEncryptable(), check whether the directory is already encrypted
before checking whether it's empty.

Also improve the error message for when a directory is nonempty.

Finally, translate keyring.ErrKeyAddedByOtherUsers and
keyring.ErrKeyFilesOpen into errors which include the directory.

5 years agocmd/fscrypt: remove ErrMaxPassphrase
Eric Biggers [Sat, 9 May 2020 21:52:07 +0000 (14:52 -0700)]
cmd/fscrypt: remove ErrMaxPassphrase

This isn't actually a valid error since crypto.NewKeyFromReader()
handles re-allocating the buffer to a larger size if it fills up.

5 years agofilesystem: improve errors
Eric Biggers [Sat, 9 May 2020 21:52:07 +0000 (14:52 -0700)]
filesystem: improve errors

Introduce filesystem.ErrEncryptionNotEnabled and
filesystem.ErrEncryptionNotSupported which include the Mount as context,
and translate the corresponding metadata/ errors into them.  Then make
these errors show much better suggestions.

Also replace lots of other filesystem/ errors with either custom types
or with unnamed one-off errors that include more context.  Fix backwards
wrapping in lots of cases.

Finally, don't include the mountpoint in places where it's not useful,
like OS-level errors that already include the path.

5 years agometadata: improve errors
Eric Biggers [Sat, 9 May 2020 21:52:07 +0000 (14:52 -0700)]
metadata: improve errors

ErrBadOwners:
Rename to ErrDirectoryNotOwned for clarity, move it from
cmd/fscrypt/ to metadata/ where it better belongs, and improve
the message.

ErrEncrypted:
Rename to ErrAlreadyEncrypted for clarity, and include the path.

ErrNotEncrypted:
Include the path.

ErrBadEncryptionOptions:
Include the path and bad options.

ErrEncryptionNotSupported:
ErrEncryptionNotEnabled:
Don't wrap with "get encryption policy %s", in preparation for
wrapping these with filesystem-level context instead.

Also avoid mixing together the error handling for the "get policy" and
"set policy" ioctls.  Make it very clear how we're handling the errors
from each ioctl.