changeset 9035:cba817a83719

6800703 smbfs default permissions may lead to surprises 6803511 smbfs client should do something on fsync
author Gordon Ross <Gordon.Ross@Sun.COM>
date Fri, 13 Mar 2009 17:12:59 -0400
parents 00e1de19228d
children 49811247ffb0
files usr/src/cmd/fs.d/smbclnt/mount/mount.c usr/src/uts/common/fs/smbclnt/smbfs/smbfs_vnops.c
diffstat 2 files changed, 21 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/fs.d/smbclnt/mount/mount.c	Fri Mar 13 11:39:23 2009 -0700
+++ b/usr/src/cmd/fs.d/smbclnt/mount/mount.c	Fri Mar 13 17:12:59 2009 -0400
@@ -33,7 +33,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -307,25 +307,14 @@
 	}
 
 	/*
-	 * Darwin takes defaults from the
-	 * mounted-on directory.
-	 * We want the real uid/gid.
-	 * XXX: Is this correct?
+	 * Fill in mdata defaults.
 	 */
-#ifdef __sun
 	if (mdata.uid == (uid_t)-1)
 		mdata.uid = getuid();
 	if (mdata.gid == (gid_t)-1)
 		mdata.gid = getgid();
-#else
-	if (mdata.uid == (uid_t)-1)
-		mdata.uid = st.st_uid;
-	if (mdata.gid == (gid_t)-1)
-		mdata.gid = st.st_gid;
-#endif
-
 	if (mdata.file_mode == 0)
-		mdata.file_mode = st.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
+		mdata.file_mode = S_IRWXU;
 	if (mdata.dir_mode == 0) {
 		mdata.dir_mode = mdata.file_mode;
 		if (mdata.dir_mode & S_IRUSR)
--- a/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_vnops.c	Fri Mar 13 11:39:23 2009 -0700
+++ b/usr/src/uts/common/fs/smbclnt/smbfs/smbfs_vnops.c	Fri Mar 13 17:12:59 2009 -0400
@@ -33,7 +33,7 @@
  */
 
 /*
- * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -1237,8 +1237,6 @@
  * If FNODSYNC is specified, then there is nothing to do because
  * metadata changes are not cached on the client before being
  * sent to the server.
- *
- * Currently, this is a no-op since we don't cache data, either.
  */
 /* ARGSUSED */
 static int
@@ -1246,7 +1244,10 @@
 {
 	int		error = 0;
 	smbmntinfo_t	*smi;
-
+	smbnode_t 	*np;
+	struct smb_cred scred;
+
+	np = VTOSMB(vp);
 	smi = VTOSMI(vp);
 
 	if (curproc->p_zone != smi->smi_zone)
@@ -1258,6 +1259,19 @@
 	if ((syncflag & FNODSYNC) || IS_SWAPVP(vp))
 		return (0);
 
+	if ((syncflag & (FSYNC|FDSYNC)) == 0)
+		return (0);
+
+	/* Shared lock for n_fid use in _flush */
+	if (smbfs_rw_enter_sig(&np->r_lkserlock, RW_READER, SMBINTR(vp)))
+		return (EINTR);
+	smb_credinit(&scred, curproc, cr);
+
+	error = smbfs_smb_flush(np, &scred);
+
+	smb_credrele(&scred);
+	smbfs_rw_exit(&np->r_lkserlock);
+
 	return (error);
 }