blob: 2267f37e7f25aac70d0ba770a2e8b18fed1129ca (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/bash
#
# Edit keys.
#
# Load functions
LIB="`dirname $0`/../functions"
source "$LIB" || exit 1
# Get file
keyringer_get_file "$2"
# Set recipients file
keyringer_set_recipients "$FILE"
# Get original file EXTENSION
FILENAME="$(basename "$FILE" .asc)"
FILENAME="$(basename "$FILENAME")"
EXTENSION="${FILENAME##*.}"
# Set a tmp file
keyringer_set_tmpfile $BASENAME.$EXTENSION
# Decrypt the information to the file
$GPG --yes -o "$TMPWORK" --use-agent -d "$KEYDIR/$FILE"
# Action check
if [ "$BASENAME" == "edit" ]; then
APP="$EDITOR"
elif [ "$BASENAME" == "open" ]; then
if which xdg-open &> /dev/null; then
APP="xdg-open"
else
echo "You should have xdg-open application to perform this action, aborting."
exit 1
fi
fi
# Prompt
echo "Press any key to open the decrypted data with $APP, Ctrl-C to abort"
echo "WARNING: please make sure that $APP doesn't leak data to external applications os files"
read key
$APP "$TMPWORK"
# Encrypt again
export KEYRINGER_ADD_EXTENSION=false
keyringer_exec encrypt "$BASEDIR" "$FILE" "$TMPWORK"
# Check exit status
errcrypt="$?"
# Remove temp file
keyringer_unset_tmpfile "$TMPWORK"
# Check exit status again
errwipe="$?"
# Error handling must be done after temp file removal
if [ "$errcrypt" != "0" ]; then
exit "$errcrypt"
elif [ "$errwipe" != "0" ]; then
exit $errwipe
fi
|