summaryrefslogtreecommitdiff
path: root/contrib/pam_mount/gocryptfs_pam_mount.bash
blob: 3c7e48d21927c874d24b7c5c2bfe07c40612d88c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#
# Simple bash script to transform the command-line arguments that
# pam_mount passes to gocryptfs into something that gocryptfs
# understands.
#
# Currently understood: nonempty,allow_other,quiet.
# Unknown options are ignored.

exec >&2
set -eu

if [[ $# != 4 ]]; then
	MYNAME=$(basename $0)
	echo "$MYNAME: expected 4 arguments, got $#"
	echo "Example: $MYNAME /home/user.crypt /home/user.plain -o allow_other"
	echo "Example: $MYNAME /home/user.crypt /home/user.plain -o defaults"
	exit 1
fi

SRC=$1
DST=$2
GOPTS=""
for OPT in nonempty allow_other quiet; do
	if [[ $4 == *$OPT* ]]; then
		GOPTS="$GOPTS -$OPT"
	fi
done

cd "$(dirname "$0")"
exec ./gocryptfs $GOPTS $SRC $DST