Another try to change the user...

This commit is contained in:
Marcel Otte 2020-09-27 17:15:46 +02:00
parent d1dfb809e3
commit 734f182f8b
2 changed files with 10 additions and 3 deletions

View File

@ -44,10 +44,15 @@ class Backup:
stdout, stderr = await proc.communicate()
logging.debug("stdout: %s", stdout)
logging.debug("stderr: %s", stderr.decode())
user = self.config.get("user")
proc = await asyncio.create_subprocess_shell(
# "set -x; chown -R {} ${{BACKIVE_MOUNT}}/${{BACKIVE_TO}};".format(user) +
# "sudo -E -u {} sh -c '".format(user) +
self.config.get("script"),
# "'",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
shell=True,
env=backup_env
)
stdout, stderr = await proc.communicate()

View File

@ -31,16 +31,18 @@ class Device:
# TODO: use mkdir as indicator for correct access rights (when backive
# is run as user!)
proc = await asyncio.create_subprocess_shell(
"""mkdir -p {mountpoint}
sudo mount -v -o users {dev_path} {mountpoint}""".format(
"""set -x; mkdir -p {mountpoint}
mount -v -o users,noexec {dev_path} {mountpoint}""".format(
mountpoint=self._mount_dir,
dev_path=dev_path
dev_path=dev_path,
),
shell=True,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
logging.debug("stdout: %s", stdout)
logging.debug("stderr: %s", stderr)
# TODO: Also add a touch operation in the target mount if the correct
# access rights are given! (when backive is run as user)
return True # on success, False on failure