/usr/share/vbackup/scripts/gpg is in vbackup 1.0.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | #!/bin/bash
#
# This file is part of vbackup.
#
# vbackup 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 3 of the License, or
# (at your option) any later version.
#
# vbackup 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 vbackup If not, see <http://www.gnu.org/licenses/>.
#
# $Id$
#
# GPG encryption module
#
#
# The name of the backup script
NAME="gpg"
# The version of the script
VERSION="$PACKAGE_VERSION"
# A short description of the script
DESC="Encrypt with GPG"
# The license of this module
LICENSE="$PACKAGE_LICENSE"
# A copyright statement
COPYRIGHT="$PACKAGE_COPYRIGHT"
# A contact email for bugreports etc
CONTACT="$PACKAGE_BUGREPORT"
# Display help
do_help()
{
cat << _END
This method encrypts a file or a directory using gpg, using a symmetric key.
It can be used in the final steps to create an encrypted archive which may be
stored locally or remotely.
If a directory is specified then it will be tar'ed first.
Configuration options:
SOURCE The local file or directory to encrypt. This is
relative to DESTDIR0. If this is empty or / then
the whole DESTDIR0 will be encrypted.
DESTFILE The destination file. This must include the
suffix (e.g. .tar.gpg) (required)
KEY The encryption key (passphrase) to suse (required)
Files may be descrypted using gpg:
gpg --output <outfile> --decrypt <encrypted>
Where <encrypted> is the file that's produced by this script (encrypted) and
<outfile> is the unencrypted file that will be produced.
_END
if [ -z "$GPG" ] ; then
cat << _END
!! This method is DISABLED because OPENSSL was not found
_END
fi
if [ -z "$GTAR" ] ; then
cat << _END
!! This method is DISABLED because GNU TAR was not found
_END
fi
}
# Check configuration
# return: 0: ok, 1: error
do_check_conf()
{
[ -z "$KEY" ] && h_error "Missing KEY" && return 1
[ -z "$DESTFILE" ] && h_error "Missing DESTFILE" && return 1
return 0
}
# Do backup
do_run()
{
if [ "x$ABORT" = "x1" ] ; then
return 0
fi
if [ -z "$GPG" ] ; then
h_error "GPG was not found"
return 1
fi
if [ -z "$GTAR" ] ; then
h_error "GNU TAR was not found"
return 1
fi
# Expand special chars
if [ "x${DESTFILE:0:0}" = "x/" ] ; then
h_transform "$DESTFILE"
else
h_transform "$DESTDIR0/$DESTFILE"
fi
DST="$R"
if [ "x${SOURCE:0:0}" = "x/" ] ; then
h_transform "$SOURCE"
else
h_transform "$DESTDIR0/$SRC"
fi
SRC="$R"
if [ -d "$SRC" ] ; then
ISDIR=1
DIRMSG=" (directory)"
else
ISDIR=0
DIRMSG=""
fi
if ! test -e "$SRC" ; then
h_msg2 "No such file: $SRC"
return 1
fi
h_msg 6 "Encrypting $SRC$DIRMSG as $DST using gpg"
(
if [ "$ISDIR" = 1 ] ; then
$GTAR -c -C "$SRC" -f - .
else
cat "$SRC"
fi
) | (
rm -f $DST
$GPG --no-use-agent \
--output $DST \
--passphrase-file <(echo $KEY) \
--batch \
--symmetric \
-
)
if [[ "$?" = 0 ]] ; then
h_msg 6 "gpg succeeded"
R=0
else
h_msg 2 "gpg failed"
R=1
fi
return $R
}
|