Skip to content
Snippets Groups Projects
Commit e1fa345d authored by Alessandro Elias's avatar Alessandro Elias
Browse files

Merge branch 'issue/3465' into 'develop'

Update script that creates ecryptfs files

Create the folders and files needed to ecryptfs.

See merge request !7
parents 657610a1 523e3872
No related branches found
No related tags found
1 merge request!7Update script that creates ecryptfs files
#!/bin/bash #!/bin/bash
username=$1 username=$1
password=$2 password=$2
path="$3" path=$3
sigpath=$(printf "%s%s.sig" "$path" "$username") user_home="$path/$username"
ecryptfs_path="$path/.ecryptfs"
user_ecrypt_path="$ecryptfs_path/$username"
if [ ! -d "$ecryptfs_path" ]; then
mkdir $ecryptfs_path
fi
mkdir -p $user_ecrypt_path
mkdir -m 700 "$user_ecrypt_path/.ecryptfs"
mkdir -m 700 "$user_ecrypt_path/.Private"
touch "$user_ecrypt_path/.ecryptfs/auto-mount"
touch "$user_ecrypt_path/.ecryptfs/auto-umount"
echo "/home/$username" > "$user_ecrypt_path/.ecryptfs/Private.mnt"
sigpath="$user_ecrypt_path/.ecryptfs/Private.sig"
wrapped="$user_ecrypt_path/.ecryptfs/wrapped-passphrase"
mountpass=$(openssl rand -base64 32) mountpass=$(openssl rand -base64 32)
printf "%s\n%s" "$mountpass" "$password" | ecryptfs-wrap-passphrase "${path}${username}" printf "%s\n%s" "$mountpass" "$password" | ecryptfs-wrap-passphrase "$wrapped"
printf "%s" "$password" | ecryptfs-insert-wrapped-passphrase-into-keyring "${path}${username}" printf "%s" "$password" | ecryptfs-insert-wrapped-passphrase-into-keyring "$wrapped"
response=`printf "%s" "$mountpass" | ecryptfs-add-passphrase --fnek -` response=`printf "%s" "$mountpass" | ecryptfs-add-passphrase --fnek -`
sig=`echo "$response" | grep "Inserted auth tok" | sed "s/^.*\[//" | sed "s/\].*$//"` sig=`echo "$response" | grep "Inserted auth tok" | sed "s/^.*\[//" | sed "s/\].*$//"`
echo "$sig" > "$sigpath" echo "$sig" > "$sigpath"
chmod 600 "$user_ecrypt_path/.ecryptfs/Private.sig"
chmod 600 "$user_ecrypt_path/.ecryptfs/Private.mnt"
chmod 600 "$user_ecrypt_path/.ecryptfs/wrapped-passphrase"
chmod 644 "$user_ecrypt_path/.ecryptfs/auto-mount"
chmod 644 "$user_ecrypt_path/.ecryptfs/auto-umount"
keyctl clear @u keyctl clear @u
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment