diff mbox

[linux-cifs-client] perm error on mount point

Message ID 20090619084033.1e3d1c9a@tlielax.poochiereds.net (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton June 19, 2009, 12:40 p.m. UTC
On Fri, 19 Jun 2009 07:01:34 -0400
Jeff Layton <jlayton@redhat.com> wrote:

> On Fri, 19 Jun 2009 08:46:11 +0200
> <pouchat@peewiki.net> wrote:
> 
> > > On Thu, 18 Jun 2009 11:31:30 -0400, Jeff Layton <jlayton@redhat.com>
> > wrote:
> > > 
> > > No. Is there some reason you feel the need to pretend that the
> > > directory is writable when it isn't?
> > 
> > Yes, because it is writable : my share are ALL WRITABLE for user (username
> > and uid
> > option that i pass during the mount). So 2.6.24 have FOR ME the correct
> > behaviour (perms). During my search i've also found that force the
> > dir_mode to 0000 solve partially my problem : writable, but only for
> > root...
> > 
> > Finally, the problem (often) come from microsoft : they use the read only
> > attribut instead of the system attribut. As they discuss in this page
> > http://support.microsoft.com/kb/256614 on readonly bit : "some programs can
> > display errors while trying to write file in this - fake readonly - dir".
> > Maybe the case with cifs in kernel 2.6.26 or later. I've tried the regedit
> > they proprosed and after reload cifs all my shares were mounted with
> > corrects
> > perms : rwxr-xr-x instead of r-x-r-xr-x.
> > 
> > So for the moment it works, hope for a long time ;) and thanks for
> > spending time to answer and to help !
> 
> (cc'ing Steve)
> 
> Thanks for the pointer. This article actually has a little more info:
> 
> http://support.microsoft.com/kb/326549/
> 
> Here's a key phrase:
> 
> "Unlike the Read-only attribute for a file, the Read-only attribute for
> a folder is typically ignored by Windows, Windows components and
> accessories, and other programs."
> 
> ...perhaps we need to change this behavior so that the write bit isn't
> cleared on directories with ATTR_READONLY set? What's samba's behavior
> in this regard?
> 
> Steve, thoughts?
> 

Since it sounds like we should change this behavior, this untested
patch should should correct this behavior. It should apply cleanly on
top of the cifs_iget patchset.
diff mbox

Patch

>From 9307c6ca7ead856617a6758a394b1002008a75eb Mon Sep 17 00:00:00 2001
From: Jeff Layton <jlayton@redhat.com>
Date: Fri, 19 Jun 2009 08:37:49 -0400
Subject: [PATCH] cifs: when ATTR_READONLY is set, only clear write bits on non-directories

On windows servers, ATTR_READONLY apparently either has no meaning or
serves as some sort of queue to certain applications for unrelated
behavior. This MS kbase article has details:

http://support.microsoft.com/kb/326549/

Don't clear the write bits directory mode when ATTR_READONLY is set.

Reported-by: pouchat@peewiki.net
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/cifs/inode.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 9195caf..73d7d3d 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -419,11 +419,11 @@  cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
 	} else {
 		fattr->cf_mode = S_IFREG | cifs_sb->mnt_file_mode;
 		fattr->cf_dtype = DT_REG;
-	}
 
-	/* clear write bits if ATTR_READONLY is set */
-	if (fattr->cf_cifsattrs & ATTR_READONLY)
-		fattr->cf_mode &= ~(S_IWUGO);
+		/* clear write bits if ATTR_READONLY is set */
+		if (fattr->cf_cifsattrs & ATTR_READONLY)
+			fattr->cf_mode &= ~(S_IWUGO);
+	}
 
 	fattr->cf_nlink = le32_to_cpu(info->NumberOfLinks);
 
-- 
1.6.0.6