]> pere.pagekite.me Git - homepage.git/blobdiff - blog/archive/2010/08/08.rss
Generated.
[homepage.git] / blog / archive / 2010 / 08 / 08.rss
index 09643c380393546c6c22e67f861c79b864232b87..0ece95941a9ccddef051d30aebf2ae7ba5b65221 100644 (file)
@@ -598,5 +598,106 @@ elektronisk stemmegiving og unngĂ„ begrepet "evalg".</p>
 </description>
        </item>
        
+       <item>
+               <title>Broken umask handling with sshfs</title>
+               <link>http://people.skolelinux.org/pere/blog/Broken_umask_handling_with_sshfs.html</link>        
+               <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/Broken_umask_handling_with_sshfs.html</guid>
+                <pubDate>Thu, 26 Aug 2010 13:30:00 +0200</pubDate>
+               <description>
+&lt;p&gt;My file system sematics program
+&lt;a href=&quot;http://people.skolelinux.org/pere/blog/Testing_if_a_file_system_can_be_used_for_home_directories___.html&quot;&gt;presented
+a few days ago&lt;/a&gt; is very useful to verify that a file system can
+work as a unix home directory,and today I had to extend it a bit.  I&#39;m
+looking into alternatives for home directory access here at the
+University of Oslo, and one of the options is sshfs.  My friend
+Finn-Arne mentioned a while back that they had used sshfs with Debian
+Edu, but stopped because of problems.  I asked today what the problems
+where, and he mentioned that sshfs failed to handle umask properly.
+Trying to detect the problem I wrote this addition to my fs testing
+script:&lt;/p&gt;
+
+&lt;pre&gt;
+mode_t touch_get_mode(const char *name, mode_t mode) {
+  mode_t retval = 0;
+  int fd = open(name, O_RDWR|O_CREAT|O_LARGEFILE, mode);
+  if (-1 != fd) {
+    unlink(name);
+    struct stat statbuf;
+    if (-1 != fstat(fd, &amp;statbuf)) {
+      retval = statbuf.st_mode &amp; 0x1ff;
+    }
+    close(fd);
+  }
+  return retval;
+}
+
+/* Try to detect problem discovered using sshfs */
+int test_umask(void) {
+  printf(&quot;info: testing umask effect on file creation\n&quot;);
+
+  mode_t orig_umask = umask(000);
+  mode_t newmode;
+  if (0666 != (newmode = touch_get_mode(&quot;foobar&quot;, 0666))) {
+    printf(&quot;  error: Wrong file mode %o when creating using mode 666 and umask 000\n&quot;,
+           newmode);
+  }
+  umask(007);
+  if (0660 != (newmode = touch_get_mode(&quot;foobar&quot;, 0666))) {
+    printf(&quot;  error: Wrong file mode %o when creating using mode 666 and umask 007\n&quot;,
+           newmode);
+  }
+
+  umask (orig_umask);
+  return 0;
+}
+
+int main(int argc, char **argv) {
+  [...]
+  test_umask();
+  return 0;
+}
+&lt;/pre&gt;
+
+&lt;p&gt;Sure enough.  On NFS to a netapp, I get this result:&lt;/p&gt;
+
+&lt;pre&gt;
+Testing POSIX/Unix sematics on file system
+info: testing symlink creation
+info: testing subdirectory creation
+info: testing fcntl locking
+  Read-locking 1 byte from 1073741824
+  Read-locking 510 byte from 1073741826
+  Unlocking 1 byte from 1073741824
+  Write-locking 1 byte from 1073741824
+  Write-locking 510 byte from 1073741826
+  Unlocking 2 byte from 1073741824
+info: testing umask effect on file creation
+&lt;/pre&gt;
+
+&lt;p&gt;When mounting the same directory using sshfs, I get this
+result:&lt;/p&gt;
+
+&lt;pre&gt;
+Testing POSIX/Unix sematics on file system
+info: testing symlink creation
+info: testing subdirectory creation
+info: testing fcntl locking
+  Read-locking 1 byte from 1073741824
+  Read-locking 510 byte from 1073741826
+  Unlocking 1 byte from 1073741824
+  Write-locking 1 byte from 1073741824
+  Write-locking 510 byte from 1073741826
+  Unlocking 2 byte from 1073741824
+info: testing umask effect on file creation
+  error: Wrong file mode 644 when creating using mode 666 and umask 000
+  error: Wrong file mode 640 when creating using mode 666 and umask 007
+&lt;/pre&gt;
+
+&lt;p&gt;So, I can conclude that sshfs is better than smb to a Netapp or a
+Windows server, but not good enough to be used as a home
+directory.&lt;/p&gt;
+</description>
+       </item>
+       
         </channel>
 </rss>