[bug] fscrypt incorrectly assumes its configuration and metadata paths are ordinary files and directories
- Dominant language
- Go
- Stars
- 1k
- Forks
- 111
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 3
Description
I first noticed this with `/etc/fscrypt.conf`. It looks like fscrypt tries to update this file by creating a temporary file, removing the old file, and then replacing it with the new one, but this causes issues when `/etc/fscrypt.conf` is a bind mount (since removing the path fails¹), or a symlink (since replacing the symlink means the new file is no longer written to the intended location).
A similar issue exists with `/.fscrypt`. Some systems use automated mechanisms to recreate paths that are stored elsewhere² (for example, through the aforementioned bind mounts or similar approaches). These mechanisms may create the directory before fscrypt has initialized it, resulting in an empty `/.fscrypt`. fscrypt then fails to write to it's directory³ even though no fscrypt metadata is present.
If I understood correctly, this issue seems related to https://github.com/google/fscrypt/pull/327
¹ - with output `[ERROR] fscrypt setup: remove /etc/fscrypt.conf: device or resource busy`.
² - such as NixOS with [impermanence/preservation setups](https://wiki.nixos.org/wiki/Impermanence).
³ - with output similar to `[ERROR] fscrypt setup: rename /.tmp2978932384/.fscrypt /.fscrypt: file exists`.
Contributor guide
Research direction
Start by tracing the setup handling for /etc/fscrypt.conf and /.fscrypt, then reproduce the reported bind-mount, symlink, and pre-created-directory failures. Done means configuration and metadata updates work when these paths are mounted, linked, or already present without fscrypt metadata, while preserving the reported error cases as tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, linux
- Domain
- operating-systems, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100