This file is indexed.

/usr/bin/rsbackup-mount is in rsbackup 3.0-2.

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
160
161
162
163
164
165
166
167
168
169
170
#! /bin/sh
#
# Copyright © 2011, 2012, 2014 Richard Kettlewell.
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
set -e

action=mount
act=""
keyfile=""

while [ $# -gt 0 ]; do
  case "$1" in
  --unmount | -u )
    shift
    action=unmount
    ;;
  --check | -c )
    shift
    action=check
    ;;
  --dry-run | -n )
    shift
    act="echo"
    ;;
  --key-file | -k )
    shift
    keyfile="$1"
    shift
    ;;
  --help | -h )
    cat <<EOF
Usage:
  rsbackup-mount [OPTIONS] [--] [DEVICES]

Options:
  --unmount, -u        Unmount instead of mount
  --check, -c          Check for devices that are attached but not mounted
  --dry-run, -n        Display commands but do nothing
  --key-file, -k PATH  Path to encryption key
  --help, -h           Display usage message
  --version, -V        Display version string
EOF
    exit 0
    ;;
  -V | --version )
    echo "rsbackup-mount 3.0"
    exit 0
    ;;
  -- )
    shift
    break
    ;;
  -* )
    echo "ERROR: unknown option '$1'" >&2
    exit 1
    ;;
  * )
    break
    ;;
  esac
done

. /etc/rsbackup/devices

if [ $# = 0 ]; then
  set $devices
  auto=true
else
  auto=false
fi

# Set the parameters for the device as follows:
#
#   uuid=<uuid of physical device>
#   encrypted=<true|false>
#   luks_device=<path to encrypted container>    (if encrypted=true)
#   luks_device_attached=<true|false>
#   luks_device_open=<true|false>
device_parameters() {
  dev="$1"
  uuid=$(eval echo \$${dev}_uuid)
  plain=$(eval echo \$${dev}_plain)
  if [ -z "$plain" ]; then
    encrypted=true
    luks_device=/dev/disk/by-uuid/$uuid
    if [ -e ${luks_device} ]; then
      luks_device_attached=true
      if [ -e /dev/mapper/$device ]; then
        luks_device_open=true
      else
        luks_device_open=false
      fi
    else
      luks_device_attached=false
    fi
  else
    encrypted=false
  fi
}

case $action in
mount )
  for device; do
    device_parameters $device
    if $encrypted && ! $luks_device_attached && $auto; then
      echo >&2 "WARNING: $device not attached, skipping"
      continue
    fi
    if $encrypted && ! $luks_device_open; then
      if $luks_device_attached; then
        echo "Decrypting $device:"
        if [ -n "$keyfile" ]; then
          $act cryptsetup luksOpen --key-file "$keyfile" "${luks_device}" $device
        else
          $act cryptsetup luksOpen "${luks_device}" $device
        fi
      else
        echo >&2 "ERROR: $device not attached"
        exit 1
      fi
    fi
    if [ -r /$device ] && [ -x /$device ]; then
      if [ ! -e /$device/device-id ]; then
        $act mount /$device
      else
        if ! $auto; then
          echo >&2 "WARNING: /$device/device-id already exists"
        fi
      fi
    else
      echo >&2 "ERROR: /$device is not accessible"
      exit 1
    fi
  done
  ;;
unmount )
  for device; do
    if [ -e /$device/device-id ]; then
      $act umount /$device
    fi
    if [ -e /dev/mapper/$device ]; then
      $act cryptsetup luksClose $device
    fi
  done
  ;;
check )
  for device; do
    device_parameters $device
    if $encrypted && $luks_device_attached; then
      if ! $luks_device_open; then
        echo "$device is attached but not decrypted"
      elif [ ! -e /$device/device-id ]; then
        echo "$device is attached and open, but does not seem to be mounted"
      fi
    fi
  done
  ;;
esac