Search code examples
bashhttp-redirectdebianfuse

Why does there appear text on my command line even though I've redirected both STDOUT and STDERR to /dev/null?


I'm trying to unmount a encfs-filesystem from a script, but no matter how I try I seem unable to prevent the fuse error below to appear on screen/in crontab emails.

# exec 3>&1 1>/dev/null 4>&2 2>/dev/null; setsid fusermount -u /data/encfs; exec 1>&3 2>&4 3>&- 4>&-
# fuse failed.  Common problems:
 - fuse kernel module not installed (modprobe fuse)
 - invalid options -- see usage message

The error itself I have to live with. The unmount is successfull and the error is false and due to a bug that is long gone in modern versions of fuse. I'm stuck with the older version since I'm on special hardware running a semi-ancient version of debian.

What annoys me is that I cannot tell the system to toss the nonsense message in /dev/null. How does the message even appear on my screen after me using both setsid and redirects in my best efforts to prevent it?

EDIT:

# exec 3>&1 1>/dev/null 4>&2 2>/dev/null; setsid fusermount -u /data/encfs > /dev/null 2>&1; EXIT=$?; exec 1>&3 2>&4 3>&- 4>&-; echo $EXIT
0
# fuse failed.  Common problems:
 - fuse kernel module not installed (modprobe fuse)
 - invalid options -- see usage message

I've even tried things like:

perl -e "`fusermount -u /data/encfs`"

But the error remain the same.

My /etc/syslog.conf:

auth,authpriv.*                     -/var/log/auth.log
*.*;auth,authpriv,cron.none         -/var/log/syslog
cron.*                              -/var/log/cron.log
daemon.*                            -/var/log/daemon.log
kern.*                              -/var/log/kern.log
lpr.*                               -/var/log/lpr.log
mail.*                              -/var/log/mail.log
user.*                              -/var/log/user.log

*.=debug;\
    auth,authpriv.none;\
    mail.none       -/var/log/debug
*.=info;*.=notice;*.=warn;\
    auth,authpriv.none;\
    cron,daemon.none;\
    mail.none       -/var/log/messages

EDIT2:

I don't think fusermount is the program actually generating the text. It pokes something else that does:

# strace -o ~/trash/strace.txt fusermount -u /data/encfs; EXIT=$?; echo $EXIT; grep write ~/trash/strace.txt                             
fuse failed.  Common problems:
 - fuse kernel module not installed (modprobe fuse)
 - invalid options -- see usage message
0
write(5, "/dev/hdc1 / ext3 rw,noatime 0 0\n", 32) = 32
write(5, "proc /proc proc rw 0 0\n", 23) = 23
write(5, "devpts /dev/pts devpts rw 0 0\n", 30) = 30
write(5, "sysfs /sys sysfs rw 0 0\n", 24) = 24
write(5, "tmpfs /ramfs ramfs rw 0 0\n", 26) = 26
write(5, "tmpfs /USB tmpfs rw,size=16k 0 0"..., 33) = 33
write(5, "/dev/c/c /c ext3 rw,noatime,acl,"..., 65) = 65
write(5, "nfsd /proc/fs/nfsd nfsd rw 0 0\n", 31) = 31
write(5, "usbfs /proc/bus/usb usbfs rw 0 0"..., 33) = 33
write(5, "//localhost/smb /root/folder"..., 55) = 55

If I let strace log to stdout I get the error message in the middle of the umount system call:

# strace fusermount -u /data/encfs
execve("/usr/bin/fusermount", ["fusermount", "-u", "/data/encfs"], [/* 16 vars */]) = 0
[... abbreviating ...]
close(5)                                = 0
munmap(0x20020000, 16384)               = 0
profil(0, 0, 0x2010c168, 0x4)           = 0
umount("/data/encfs", 0fuse failed.  Common problems:
 - fuse kernel module not installed (modprobe fuse)
 - invalid options -- see usage message
)    = 0
profil(0, 0, 0x1177c, 0x20179f98)       = 0
stat64("/etc/mtab", {st_mode=S_IFREG|0644, st_size=407, ...}) = 0
ftime(0x13840)                          = 0

Solution

  • Figured it out.

    The error message does not come from the fusermount, it comes from the mount command when fusermount runs.

    Doing it like this fixes the problem:

    # encfs --extpass=echo_key.sh /data/.encfs /data/encfs 2>/dev/null; sleep 3; fusermount -u /data/encfs
    #
    

    Feels so obvious now that I know...