Gocryptfs: find encrypted name of dir entry?

Created on 13 Mar 2019  路  5Comments  路  Source: rfjakob/gocryptfs

Is any method available to resolve the name of a file on the underlying file system for a file or directory in a mounted gocrgyptfs system?

For example, in this case, can I resolve the encrypted name in crypt corresponding to foo?

~
$ gocryptfs crypt view
$ ls view/
foo
~

Having this ability assists some low-level maintenance tasks.

feature request

All 5 comments

Yes, two options: "ls -li" to see the inode number, then "find . -inum" (inode numbers are the same in encrypted and plain)

Option two is to mount with "-ctlsock my.socket", and use https://github.com/rfjakob/gocryptfs/blob/master/contrib/ctlsock-encrypt.bash

Ok, good. Very useful. I didn't know that inode was exposed as a passthrough.

The socket link is also useful. However, if you get bored with current development activities, you might consider a CLI mechanism that provides the same functionality without the manual effort and potential security pitfalls associated with designated a socket path at the time of mount.

For example,

~
$ gocryptfs crypt view
$ gocryptfs -iteminfo view/foo
crypt/gY5Biz
~

I found the solution suggested by @rfjakob useful.

As I needed to find multiple files in one go to restore a specific set of encrypted files from my backup, here is what I came up with:

#!/usr/bin/env bash

usage() {
cat <<EOF
Usage: $0 CLEARTEXTFILE+
EOF
exit 1
}

[ $# -ge 1 ]  || usage

GOCRYPTFSROOT="${GOCRYPTFSROOT:-${HOME}/Google Drive/gcfs}"

stat --printf="%i\0" "$@" | xargs -0 -n1 find "${GOCRYPTFSROOT}" -inum 

(replace the default GOCRYPTFSROOT with yours).

This functionality will be integrated into gocryptfs-xray, progress tracked at https://github.com/rfjakob/gocryptfs/issues/416

Was this page helpful?
0 / 5 - 0 ratings