diff --git a/README.md b/README.md index 94a686b..f46d4a7 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,18 @@ | | | [1Cw9nZu9ygknussPofMWCzmSMveusTbQvN](bitcoin:1Cw9nZu9ygknussPofMWCzmSMveusTbQvN) | +## Experimental version of zfs-tools: + +In this experimential version of zfs-tools the "zfs-shell" was removed. +ZFS permissions should be used instead: + +* sender side: zfs allow -u send,snapshot,destroy,mount,hold + +* receiver side: zfs allow -u create,mount,receive + + +## The following documentation needs to be updated: + The ZFS backup tools will help you graft an entire ZFS pool as a filesystem into a backup machine, without having to screw around snapshot names or complicated shell commands or crontabs. diff --git a/bin/zbackup b/bin/zbackup index b7c4d9c..59f96ed 100755 --- a/bin/zbackup +++ b/bin/zbackup @@ -55,7 +55,7 @@ def zbackup_properties(tier): def get_zpools(): """Return list of zpools.""" zpools = [] - zpool_list = subprocess.Popen(["zpool", "list", "-H"], stdout = subprocess.PIPE) + zpool_list = subprocess.Popen(["/sbin/zpool", "list", "-H"], stdout = subprocess.PIPE) for line in zpool_list.stdout: zpools.append(line.split()[0]) return zpools diff --git a/bin/zfs-shell b/bin/zfs-shell deleted file mode 100755 index 924bcc4..0000000 --- a/bin/zfs-shell +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -e - -if [ "$1" == "-c" -o "$1" == "zfs" ] ; then - shift - exec "$0" $@ -fi - -export PATH=/sbin:/usr/sbin:/usr/local/sbin:"$PATH" - -cmd="$1" - -if [ "$cmd" == "snapshot" -o "$cmd" == "list" -o "$cmd" == "recv" -o "$cmd" == "receive" -o "$cmd" == "send" -o "$cmd" == "destroy" -o "$cmd" == "get" ] ; then - # FIXME: verify that the name of the snapshot contains an @ - sudo zfs "$@" - exit $? -fi - -echo "usage: zfs-shell [ list | snapshot | send | recv | receive | destroy | get ] " >&2 -exit 64 diff --git a/debian/changelog b/debian/changelog index 79cafaf..b1b7f1e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +zfs-tools (0.6.2) wily; urgency=low + + * remove zfs-shell, zfs user and sudoers rules; use zfs permissions instead + + -- Michael Hierweck Thu, 3 Dec 2020 10:14:26 +0000 + zfs-tools (0.6.1) wily; urgency=low * depend on zfsutils-linux diff --git a/debian/postinst b/debian/postinst deleted file mode 100644 index 590eaed..0000000 --- a/debian/postinst +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# postinst script for zfs-tools -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - id zfs > /dev/null 2>&1 || { - useradd -b /var/lib -c 'ZFS backup user' -m -U -r -s /usr/bin/zfs-shell zfs - } - test -d /var/lib/zfs.ssh || { - mkdir -p /var/lib/zfs/.ssh - chmod 700 /var/lib/zfs /var/lib/zfs/.ssh - chown -R zfs.zfs /var/lib/zfs - } - grep -q /usr/bin/zfs-shell /etc/shells || { - echo /usr/bin/zfs-shell >> /etc/shells - } - chmod 440 /etc/sudoers.d/zfs - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/postrm b/debian/postrm deleted file mode 100644 index 88e8901..0000000 --- a/debian/postrm +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -# postrm script for zfs-tools -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `remove' -# * `purge' -# * `upgrade' -# * `failed-upgrade' -# * `abort-install' -# * `abort-install' -# * `abort-upgrade' -# * `disappear' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - purge|remove) - grep -q /usr/bin/zfs-shell /etc/shells && { - newshells=`grep -v /usr/bin/zfs-shell /etc/shells` - echo "$newshells" > /etc/shells - } - ;; - - upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - ;; - - *) - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/setup.py b/setup.py index 331c92e..6c22270 100755 --- a/setup.py +++ b/setup.py @@ -45,7 +45,7 @@ ]), classifiers = classifiers, packages=["zfstools"], - scripts=["bin/zreplicate", 'bin/zfs-shell', 'bin/zsnap', 'bin/zbackup', 'bin/zflock'], + scripts=["bin/zreplicate", 'bin/zsnap', 'bin/zbackup', 'bin/zflock'], keywords="ZFS filesystems backup synchronization snapshot", zip_safe=False, ) diff --git a/src/zfstools/connection.py b/src/zfstools/connection.py index 266301a..4f03ccc 100644 --- a/src/zfstools/connection.py +++ b/src/zfstools/connection.py @@ -59,25 +59,25 @@ def __init__(self,host="localhost", trust=False, sshcipher=None, properties=None def _get_poolset(self): if self._dirty: properties = [ 'creation' ] + self._properties - stdout2 = subprocess.check_output(self.command + ["zfs", "list", "-Hpr", "-o", ",".join( ['name'] + properties ), "-t", "all"]) + stdout2 = subprocess.check_output(self.command + ["/sbin/zfs", "list", "-Hpr", "-o", ",".join( ['name'] + properties ), "-t", "all"]) self._poolset.parse_zfs_r_output(stdout2,properties) self._dirty = False return self._poolset pools = property(_get_poolset) def create_dataset(self,name): - subprocess.check_call(self.command + ["zfs", "create", name]) + subprocess.check_call(self.command + ["/sbin/zfs", "create", name]) self._dirty = True return self.pools.lookup(name) def destroy_dataset(self, name): - subprocess.check_call(self.command + ["zfs", "destroy", name]) + subprocess.check_call(self.command + ["/sbin/zfs", "destroy", name]) self._dirty = True def destroy_recursively(self, name, returnok=False): """If returnok, then simply return success as a boolean.""" ok = True - cmd = self.command + ["zfs", "destroy", '-r', name] + cmd = self.command + ["/sbin/zfs", "destroy", '-r', name] if returnok: ok = subprocess.call(cmd) == 0 else: @@ -87,7 +87,7 @@ def destroy_recursively(self, name, returnok=False): def snapshot_recursively(self,name,snapshotname,properties={}): plist = sum( map( lambda x: ['-o', '%s=%s' % x ], properties.items() ), [] ) - subprocess.check_call(self.command + ["zfs", "snapshot", "-r" ] + plist + [ "%s@%s" % (name, snapshotname)]) + subprocess.check_call(self.command + ["/sbin/zfs", "snapshot", "-r" ] + plist + [ "%s@%s" % (name, snapshotname)]) self._dirty = True def send(self,name,opts=None,bufsize=-1,compression=False,lockdataset=None): @@ -99,8 +99,8 @@ def send(self,name,opts=None,bufsize=-1,compression=False,lockdataset=None): if self.verbose: cmd += ["-v"] cmd += [lockdataset, "--"] - cmd += ["zfs", "send"] + opts + [name] - p = SpecialPopen(cmd,stdin=file(os.devnull),stdout=subprocess.PIPE,bufsize=bufsize) + cmd += ["/sbin/zfs", "send"] + opts + [name] + p = SpecialPopen(cmd,stdin=open(os.devnull),stdout=subprocess.PIPE,bufsize=bufsize) return p def receive(self,name,pipe,opts=None,bufsize=-1,compression=False,lockdataset=None): @@ -112,7 +112,7 @@ def receive(self,name,pipe,opts=None,bufsize=-1,compression=False,lockdataset=No if self.verbose: cmd += ["-v"] cmd += [lockdataset, "--"] - cmd = cmd + ["zfs", "receive"] + opts + [name] + cmd = cmd + ["/sbin/zfs", "receive"] + opts + [name] p = SpecialPopen(cmd,stdin=pipe,bufsize=bufsize) return p