Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Remove "fuse" user group handling and checking #1472

Merged
merged 5 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions common/configure
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,17 @@ UNINSTALL_DIRS="$(mktemp)"

#set default options
PYTHON="--python3"
FUSE_GROUP="--no-fuse-group"

USR_BIN_FILES="backintime backintime-askpass"
FUSE_FILES="mount.py"

usage () {
echo "Usage:"
echo "$0 [--python | --python3], [--fuse-group | --no-fuse-group]"
echo "$0 [--python | --python3]"
echo ""
echo "--python"
echo "\tuse 'python' to start Python3"
echo "--python3"
echo "\tuse 'python3' to start Python3"
echo "--no-fuse-group"
echo "\tdo not check for 'fuse' group membership (if not necessary on destination platform)"
echo "--fuse-group"
echo "\tmake sure user is in the group 'fuse' to be able to use fuse-based file-systems"
}

addInstallFiles () {
Expand Down Expand Up @@ -120,7 +114,6 @@ unknown_args=""
for arg in $*; do
case $arg in
--python | --python3) PYTHON=$arg;;
--fuse-group | --no-fuse-group) FUSE_GROUP=$arg;;
--help | -h) usage; exit 0;;
*) unknown_args="$unknown_args $arg";;
esac
Expand All @@ -140,15 +133,6 @@ sed -e "s/^python3\? /python${PYVERSION} /g" \
-e "s/^ssh-agent python3\? /ssh-agent python${PYVERSION} /g" \
-i $USR_BIN_FILES

#patch check for 'fuse' group
#Some distributions require user to be in group 'fuse' to use sshfs and encfs
case $FUSE_GROUP in
--fuse-group) CHECKFUSE="True" ;;
--no-fuse-group) CHECKFUSE="False";;
esac
sed -e "s/CHECK_FUSE_GROUP = \(True\|False\)/CHECK_FUSE_GROUP = ${CHECKFUSE}/" \
-i $FUSE_FILES

#check languages
mos=""
langs=""
Expand Down
33 changes: 5 additions & 28 deletions common/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,6 @@ class MountControl(object):
mountpoints
"""

CHECK_FUSE_GROUP = False

def __init__(self,
cfg = None,
profile_id = None,
Expand Down Expand Up @@ -592,7 +590,7 @@ def _umount(self):
overwritten by backends which subclasses :py:class:`MountControl`.

Raises:
exceptions.MountException: if unmount failed
exceptions.MountException: If unmount failed.
"""
try:
subprocess.check_call(['fusermount', '-u', self.currentMountpoint])
Expand Down Expand Up @@ -675,42 +673,21 @@ def postUmountCheck(self):

def checkFuse(self):
"""
Check if command in self.mountproc is installed and user is part of
group ``fuse``.
Check if command in ``self.mountproc`` is installed.

Raises:
exceptions.MountException: if either command is not available or
user is not in group fuse
exceptions.MountException: If either command is not available.
"""
logger.debug('Check fuse', self)

if not tools.checkCommand(self.mountproc):
logger.debug('%s is missing' % self.mountproc, self)

raise MountException(
'{} not found. Please install e.g. {}'
'{} not found. Please install e.g. {}'
.format(self.mountproc,
"'apt-get install %s'" % self.mountproc)
)

if self.CHECK_FUSE_GROUP:
user = self.config.user()

try:
fuse_grp_members = grp.getgrnam('fuse')[3]

except KeyError:
#group fuse doesn't exist. So most likely it isn't used by this distribution
logger.debug("Group fuse doesn't exist. Skip test", self)
return

if not user in fuse_grp_members:
logger.debug('User %s is not in group fuse' % user, self)
raise MountException(
"{user} is not member of group 'fuse'. Run 'sudo adduser "
"{user} fuse'. To apply changes logout and login again."
"\nLook at 'man backintime' for further instructions."
.format(user=user))

def mounted(self):
"""
Check if the mountpoint is already mounted.
Expand Down
8 changes: 5 additions & 3 deletions common/sshtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,11 @@ def _mount(self):

err = proc.communicate()[1]

if proc.returncode:
raise MountException(
"Can't mount %s" % " ".join(sshfs) + "\n\n" + err)
if proc.returncode == 0:
return

raise MountException("Can't mount {}\n\n{}"
.format(" ".join(sshfs), err))

def preMountCheck(self, first_run=False):
"""
Expand Down
20 changes: 2 additions & 18 deletions qt/settingsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import os
import datetime
import copy
import grp
import re

from PyQt5.QtGui import QIcon, QFont, QPalette, QBrush, QColor
Expand Down Expand Up @@ -2106,32 +2105,17 @@ def __init__(self, parent):
snapshots.SID(datetime.datetime.now(), self.config).sid
)

# inform user to join group fuse if he hasn't already.
# If there is no group fuse than it is most likely not necessary.
addFuse = ''

try:
user = self.config.user()
fuse_grp_members = grp.getgrnam('fuse')[3]

if user not in fuse_grp_members:
addFuse = _(' and add your user to group \'fuse\'')

except KeyError:
pass

label = QLabel(_(
"Please navigate to the snapshot from which you want to restore "
"{appName}'s configuration. The path may look like:\n"
"{samplePath}\n\nIf your snapshots are on a remote drive or if "
"they are encrypted you need to manually mount them first. "
"If you use Mode SSH you also may need to set up public key "
"login to the remote host{addFuse}.\n"
"login to the remote host.\n"
"Take a look at 'man backintime'.")
.format(
appName=self.config.APP_NAME,
samplePath=samplePath,
addFuse=addFuse),
samplePath=samplePath),
self
)
label.setWordWrap(True)
Expand Down