Is there a tool to map plaintext and encrypted filenames?
I am rsync'ing my encrypted home directory (to a backup storage). In this process I need to exclude several files and directories (using --exclude option in rsync).
So far I am MANUALLY finding the encrypted filename corresponding to the directory I want to exclude. This works but is time-consuming every time I need to change the list of excluded directories. Besides, it is hard to grasp which (plaintext) directories are being excluded by simply looking at the rsync command-line.
I have just crafted a bash script, ecryptfs-
Feel free to distribute/post on your website/provide comments or improvements to this script
Regards,
Sergio Mena
PS Here is the script:
<code>
#!/bin/sh
# Utility script to map plaintext and encrypted filenames
# in an eCryptfs directory
# Sergio Mena. 2011-06-18
#Default values
encryptedroot=
plaintextroot=
usage()
{
cat << EOF
usage: $0 [options] filename
This script prints the ecryptfs counterpart filename (including path) of the plaintext filename \
passed as argument. Note that the script does not use PWD/CWD to locate the filename. Filename \
is a path to the target file/directory, relative to the plaintext root. Likewise, the resulting \
filename includes the path relative to the encrypted root.
OPTIONS:
-h show this message
-e path path to encrypted root path (default: $encryptedroot)
-p path path to plaintext root path (default: $plaintextroot)
-s swap root paths. The command effectively takes the opposite effect (i.e., from \
encrypted filename to plaintext).
EOF
}
reverse=0
while getopts "he:p:s" OPTION; do
case $OPTION in
h)
usage
exit 0
;;
e)
;;
p)
;;
s)
;;
?)
usage >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
[ -z "$1" ] &&\
echo "$0: No filename provided" >&2 &&\
usage >&2 &&\
exit 2
[ $reverse -eq 1 ] &&\
aux=
encryptedro
plaintextro
currentencrypte
currentplaintex
rest="$1"
while true; do
nextplainte
rest=`echo ${rest} | sed 's/^[^\/]*\/*//'`
currentplai
[ ! -e "${plaintextroo
echo "$0: cannot access $1: No such file or directory" >&2 &&\
exit 1
inode=`ls -aid "${plaintextroo
nextencrypt
[ -z "$nextencrypteddir" ] &&\
echo "$0: Hmmm strange, no encrypted file/dir corresponds to plaintext file/dir" >&2 &&\
exit 2
currentencr
[ -z "$rest" ] &&\
( echo "${currentencry
exit 0
done
</code>
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- eCryptfs Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Sergio Mena for more information if necessary.