If this package is installed in a chroot environment, then we
should not be touching anything in /dev/ because it will belong
to the host os rather than the chroot.

chrooted() comes from mount.preinst in the util-linux package.

Fixes #813621
---
 debian/fuse.postinst | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/debian/fuse.postinst b/debian/fuse.postinst
index 1eb08b8..639fc62 100644
--- a/debian/fuse.postinst
+++ b/debian/fuse.postinst
@@ -2,9 +2,19 @@
 
 set -e
 
+chrooted() {
+       if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 
2>/dev/null)" ]; then
+               # the devicenumber/inode pair of / is the same as that of
+               # /sbin/init's root, so we're *not* in a chroot and hence
+               # return false.
+               return 1
+       fi
+       return 0
+}
+
 case "${1}" in
        configure)
-               if [ -c /dev/cuse ]
+               if [ -c /dev/cuse ] && ! chrooted
                then
                        chmod 0600 /dev/cuse > /dev/null 2>&1
                fi
-- 
2.7.4

Reply via email to