1 Title: Broken umask handling with sshfs
2 Tags: english, nuug, debian edu
5 <p>My file system sematics program
6 <a href="http://people.skolelinux.org/pere/blog/Testing_if_a_file_system_can_be_used_for_home_directories___.html">presented
7 a few days ago</a> is very useful to verify that a file system can
8 work as a unix home directory,and today I had to extend it a bit. I'm
9 looking into alternatives for home directory access here at the
10 University of Oslo, and one of the options is sshfs. My friend
11 Finn-Arne mentioned a while back that they had used sshfs with Debian
12 Edu, but stopped because of problems. I asked today what the problems
13 where, and he mentioned that sshfs failed to handle umask properly.
14 Trying to detect the problem I wrote this addition to my fs testing
18 mode_t touch_get_mode(const char *name, mode_t mode) {
20 int fd = open(name, O_RDWR|O_CREAT|O_LARGEFILE, mode);
24 if (-1 != fstat(fd, &statbuf)) {
25 retval = statbuf.st_mode & 0x1ff;
32 /* Try to detect problem discovered using sshfs */
33 int test_umask(void) {
34 printf("info: testing umask effect on file creation\n");
36 mode_t orig_umask = umask(000);
38 if (0666 != (newmode = touch_get_mode("foobar", 0666))) {
39 printf(" error: Wrong file mode %o when creating using mode 666 and umask 000\n",
43 if (0660 != (newmode = touch_get_mode("foobar", 0666))) {
44 printf(" error: Wrong file mode %o when creating using mode 666 and umask 007\n",
52 int main(int argc, char **argv) {
59 <p>Sure enough. On NFS to a netapp, I get this result:</p>
62 Testing POSIX/Unix sematics on file system
63 info: testing symlink creation
64 info: testing subdirectory creation
65 info: testing fcntl locking
66 Read-locking 1 byte from 1073741824
67 Read-locking 510 byte from 1073741826
68 Unlocking 1 byte from 1073741824
69 Write-locking 1 byte from 1073741824
70 Write-locking 510 byte from 1073741826
71 Unlocking 2 byte from 1073741824
72 info: testing umask effect on file creation
75 <p>When mounting the same directory using sshfs, I get this
79 Testing POSIX/Unix sematics on file system
80 info: testing symlink creation
81 info: testing subdirectory creation
82 info: testing fcntl locking
83 Read-locking 1 byte from 1073741824
84 Read-locking 510 byte from 1073741826
85 Unlocking 1 byte from 1073741824
86 Write-locking 1 byte from 1073741824
87 Write-locking 510 byte from 1073741826
88 Unlocking 2 byte from 1073741824
89 info: testing umask effect on file creation
90 error: Wrong file mode 644 when creating using mode 666 and umask 000
91 error: Wrong file mode 640 when creating using mode 666 and umask 007
94 <p>So, I can conclude that sshfs is better than smb to a Netapp or a
95 Windows server, but not good enough to be used as a home
98 <p>Update 2010-08-26: Reported the issue in
99 <a href="http://bugs.debian.org/594498">BTS report #594498</a></p>
101 <p>Update 2010-08-27: Michael Gebetsroither report that he found the
102 script so useful that he created a GIT repository and stored it in
103 <a href="http://github.com/gebi/fs-test">http://github.com/gebi/fs-test</a>.</p>