-
Notifications
You must be signed in to change notification settings - Fork 286
feat: add -takeout, -list commands #939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dzianisv
wants to merge
4
commits into
rfjakob:master
Choose a base branch
from
dzianisv:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+420
−6
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit introduces two new commands: - : Decrypts a specific file or directory from the encrypted filesystem and moves it to a destination, deleting the original encrypted file. - : Lists the decrypted file and directory names in a tree-like structure. These commands enhance the utility of gocryptfs v2.5.1; go-fuse [vendored]; 2025-01-23 go1.23.6 darwin/arm64 Usage: gocryptfs -init|-passwd|-info [OPTIONS] CIPHERDIR or gocryptfs [OPTIONS] CIPHERDIR MOUNTPOINT Common Options (use -hh to show all): -aessiv Use AES-SIV encryption (with -init) -allow_other Allow other users to access the mount -i, -idle Unmount automatically after specified idle duration -config Custom path to config file -ctlsock Create control socket at location -extpass Call external program to prompt for the password -fg Stay in the foreground -fsck Check filesystem integrity -fusedebug Debug FUSE calls -h, -help This short help text -hh Long help text with all options -init Initialize encrypted directory -info Display information about encrypted directory -masterkey Mount with explicit master key instead of password -nonempty Allow mounting over non-empty directory -nosyslog Do not redirect log messages to syslog -passfile Read password from plain text file(s) -passwd Change password -plaintextnames Do not encrypt file names (with -init) -q, -quiet Silence informational messages -reverse Enable reverse mode -ro Mount read-only -speed Run crypto speed test -version Print version information -- Stop option parsing by providing more granular control over file decryption and better visibility into the encrypted filesystem's contents without requiring FUSE.
The command previously failed when provided with a plaintext path, as it attempted to directly access the encrypted equivalent. This commit refactors the command to: - Walk the entire encrypted . - Decrypt each file's relative path on the fly. - Compare the decrypted path with the user-provided plaintext . - Only process files and directories that match or are children of the specified . - Add a helper function to encapsulate the path decryption logic. - Skip files starting with to avoid decryption errors with macOS metadata files.
The command previously failed when encountering longnames (hashed filenames) and special files (like macOS metadata files starting with ). This commit addresses these issues by: - Adding and functions to to correctly identify and read the original plaintext names of longname files. - Modifying to use these new functions, ensuring that longnames are properly decrypted. - Expanding the special file skipping logic in to include files starting with , preventing decryption errors with macOS metadata. - Gracefully handling decryption errors for non-gocryptfs files by logging them at a debug level instead of warnings.
This commit adds a logging message to the `takeout` command, printing "Took out $src -> $dst" after a file has been successfully decrypted, moved, and the original encrypted file has been removed.
Owner
|
Hi, uh, first, is this AI generated? Please declare this in the PR already. These are big features and will need to go big in tests. I don't see a single one right now. |
rfjakob
requested changes
Jul 18, 2025
Owner
rfjakob
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a complete review. But tests are completely missing. Will continue the review when there's some tests.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit introduces two new commands:
gocryptfs -takeout CIPHERDIR PATH DESTDIR: Decrypts a specific file or directory from the encrypted filesystem and moves it to a destination, deleting the original encrypted file.gocryptfs -list CIPHERDIR: Lists the decrypted file and directory names in a tree-like structure.These commands enhance the utility of
gocryptfsby providing more granular control over file decryption and better visibility into the encrypted filesystem's contents without requiring FUSE.fix:
listcommand outputs full decrypted file pathsThe previous implementation of the
listcommand outputted a tree-like structure and failed to decrypt special files. This commit modifies thelistcommand to:git ls-files.gocryptfs.dirivandgocryptfs.conf.fix:
takeoutcommand handles plaintext paths correctlyThe
takeoutcommand previously failed when provided with a plaintext path, as it attempted to directly access the encrypted equivalent. This commit refactors thetakeoutcommand to:CIPHERDIR.PATH.PATH.decryptRelativePathto encapsulate the path decryption logic.._to avoid decryption errors with macOS metadata files.fix:
takeoutcommand handles longnames and special filesThe
takeoutcommand previously failed when encountering longnames (hashed filenames) and special files (like macOS metadata files starting with._). This commit addresses these issues by:IsLongNameandReadLongNamefunctions tointernal/nametransform/names.goto correctly identify and read the original plaintext names of longname files.take_out.goto use these new functions, ensuring that longnames are properly decrypted.take_out.goto include files starting with._, preventing decryption errors with macOS metadata.fix:
takeoutandlistcommands handle non-gocryptfs filenamesThe
takeoutandlistcommands previously failed when encountering filenames that were not validgocryptfsencrypted names (e.g., non-encrypted files, macOS metadata, or files copied withoutgocryptfs's knowledge). This commit addresses these issues by:IsValidBase64function tointernal/nametransform/names.goto check if a string is a valid base64 encoding.decryptRelativePathintake_out.goandlist.goto useIsValidBase64. If a filename component is not a valid base64 string, it is now treated as a literal plaintext name and passed through without decryption. This prevents "bad message" and "padding too long" errors.