plaintext -> crypted file name mapping tool
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
eCryptfs |
Fix Released
|
Wishlist
|
Dustin Kirkland |
Bug Description
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>
Related branches
Changed in ecryptfs: | |
status: | Triaged → Fix Committed |
This is good stuff, Sergio!
Could you do two things, such that I can include this in ecryptfs-utils properly...
1) Could you please attach the file to this bug report
2) Could you please add a GPLv2 copyright header to the top of your script as comments?
You can find it in /usr/share/ common- licenses/ GPL-2:
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Thanks!