Bug 2246 - [patch] 'dos mask readonly'
Summary: [patch] 'dos mask readonly'
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.10
Hardware: All All
: P3 enhancement
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
URL: http://groups.google.de/groups?q=%2B%...
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-15 07:48 UTC by Markus Greger
Modified: 2006-04-14 14:56 UTC (History)
0 users

See Also:


Attachments
Patch implementing the option 'dos mask readonly' (5.88 KB, patch)
2005-01-15 07:56 UTC, Markus Greger
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Greger 2005-01-15 07:48:28 UTC
The need to suppress translation of missing UNIX write access to DOS read-only
mode on a global or per share base arose at our site (Samba on Solaris 8). Thus
we created the enclosed patch.

The patch introduces the option "dos mask readonly". Similiarly to the options
"map archive", "map system", or "map hidden" it controls mapping of UNIX write
permission to DOS style permissions.
If set to "dos mask readonly=yes" lack of UNIX write permissions translates to
DOS style "Read-Only" attribute as is the case without patch.
If set to "no" lack of write permissions does not translate to a DOS style
"Read-Only" attribute while actual access behaviour remains unchanged.

It is specifically designed for systems without support for extended attributes
(particularly existing file systems like IBM mvfs).

Application for the enhancement include accessing read-only media or file
systems without showing read-only DOS mode, i.e. data on a CD-ROM shared via SAMBA.

In our situation deployment accesses data via SAMBA from an underlying
versioning system providing its own filesystem. The versioning system provides
files and directories without write permissions and the samba share will be read
only. DOS mode however has to be without Read-Only attribute to not propagate
that attribute into deployment process.

The patch for the enhancement for Samba 3.0.10 is about 6kb and enclosed. It
modifies the following files
> source/param/loadparam.c
> source/smbd/dosmode.c
> docs/manpage/smb.conf.5
> docs/htmldoc/smb.conf.5.html


Regards,

Markus Greger

--- patch starts below that line --
diff -Nru samba-3.0.10.orig/docs/htmldocs/smb.conf.5.html
samba-3.0.10.dmro/docs/htmldocs/smb.conf.5.html
--- samba-3.0.10.orig/docs/htmldocs/smb.conf.5.html	2004-12-15
17:22:07.000000000 +0100
+++ samba-3.0.10.dmro/docs/htmldocs/smb.conf.5.html	2005-01-03
12:34:11.224399000 +0100
@@ -1067,6 +1067,10 @@
 	yes</tt> allows DOS semantics and <a href="smbd.8.html"><span
class="citerefentry"><span class="refentrytitle">smbd</span>(8)</span></a> will
change the file 
 timestamp as DOS requires.</p><p>Default: <span class="emphasis"><em><i
class="parameter"><tt>dos filetimes</tt></i> = no
 </em></span>
+</p></dd><dt><span class="term"><a name="DOSMASKREADONLY"></a>dos mask readonly
(S)</span></dt><dd><p>
+    Mask the dos readonly attribute. Write protected files on UNIX or on
readonly shares are shown under DOS and Windows with readonly attribute not set.
+    </p><p>Default: <span class="emphasis"><em><i class="parameter"><tt>dos
mask readonly</tt></i> = no
+</em></span>
 </p></dd><dt><span class="term"><a name="EASUPPORT"></a>ea support
(S)</span></dt><dd><p>This boolean parameter controls whether <a
href="smbd.8.html"><span class="citerefentry"><span
class="refentrytitle">smbd</span>(8)</span></a> will allow clients to attempt to
store OS/2 style Extended
     attributes on a share. In order to enable this parameter the underlying
filesystem exported by
     the share must support extended attributes (such as provided on XFS and
EXT3 on Linux, with the
diff -Nru samba-3.0.10.orig/docs/manpages/smb.conf.5
samba-3.0.10.dmro/docs/manpages/smb.conf.5
--- samba-3.0.10.orig/docs/manpages/smb.conf.5	2004-12-15 17:20:36.000000000 +0100
+++ samba-3.0.10.dmro/docs/manpages/smb.conf.5	2005-01-03 12:29:32.582943000 +0100
@@ -1161,6 +1161,12 @@
 Default: \fB\fIdos filetimes\fR = no \fR 
 
 .TP
+dos mask readonly (S)
+Mask the dos readonly attribute. Write protected files on UNIX or on readonly
shares are shown under DOS and Windows with readonly attribute not set.
+
+Default: \fB\fIdos mask readonly\fR = no \fR
+
+.TP
 ea support (S)
 This boolean parameter controls whether \fBsmbd\fR(8) will allow clients to
attempt to store OS/2 style Extended attributes on a share\&. In order to enable
this parameter the underlying filesystem exported by the share must support
extended attributes (such as provided on XFS and EXT3 on Linux, with the correct
kernel patches)\&. On Linux the filesystem must have been mounted with the mount
option user_xattr in order for extended attributes to work, also extended
attributes must be compiled into the Linux kernel\&.
 
diff -Nru samba-3.0.10.orig/source/param/loadparm.c
samba-3.0.10.dmro/source/param/loadparm.c
--- samba-3.0.10.orig/source/param/loadparm.c	2004-12-15 15:33:14.000000000 +0100
+++ samba-3.0.10.dmro/source/param/loadparm.c	2005-01-03 12:10:39.241413000 +0100
@@ -9,6 +9,10 @@
    Copyright (C) Alexander Bokovoy 2002
    Copyright (C) Stefan (metze) Metzmacher 2002
    Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
+
+   07/14/2004 added "dos mask readonly" support
+              Markus Greger  <Markus.Greger@izb-soft.de>
+              Thomas Maier   <Thomas.Maier@izb-soft.de>
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -422,6 +426,7 @@
 	BOOL bAfs_Share;
 	BOOL bEASupport;
 	param_opt_struct *param_opt;
+	BOOL bDosMaskReadonly; /* "dos mask readonly" patch by Markus Greger, Thomas
Maier  IZB SOFT 07/14/2004 */
 
 	char dummy[3];		/* for alignment */
 }
@@ -549,6 +554,9 @@
 	
 	NULL,			/* Parametric options */
 
+/* "dos mask readonly" patch by Markus Greger, Thomas Maier  IZB SOFT 07/14/2004 */
+	False,          /* Dos Mask Readonly */
+
 	""			/* dummy */
 };
 
@@ -1152,6 +1160,8 @@
 	{"dos filemode", P_BOOL, P_LOCAL, &sDefault.bDosFilemode, NULL, NULL,
FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
 	{"dos filetimes", P_BOOL, P_LOCAL, &sDefault.bDosFiletimes, NULL, NULL,
FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
 	{"dos filetime resolution", P_BOOL, P_LOCAL, &sDefault.bDosFiletimeResolution,
NULL, NULL, FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL}, 
+/* "dos mask readonly" patch by Markus Greger, Thomas Maier  IZB SOFT 07/14/2004 */
+	{"dos mask readonly", P_BOOL, P_LOCAL, &sDefault.bDosMaskReadonly, NULL, NULL,
FLAG_ADVANCED | FLAG_SHARE | FLAG_GLOBAL},
 
 	{"fake directory create times", P_BOOL, P_LOCAL,
&sDefault.bFakeDirCreateTimes, NULL, NULL, FLAG_ADVANCED | FLAG_SHARE |
FLAG_GLOBAL}, 
 	{"panic action", P_STRING, P_GLOBAL, &Globals.szPanicAction, NULL, NULL,
FLAG_ADVANCED}, 
@@ -1919,6 +1929,8 @@
 FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
 FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
 FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
+/* "dos mask readonly" patch by Markus Greger, Thomas Maier  IZB SOFT 07/14/2004 */
+FN_LOCAL_BOOL(lp_dos_mask_ro, bDosMaskReadonly)
 
 /* local prototypes */
 
diff -Nru samba-3.0.10.orig/source/smbd/dosmode.c
samba-3.0.10.dmro/source/smbd/dosmode.c
--- samba-3.0.10.orig/source/smbd/dosmode.c	2004-12-15 15:12:15.000000000 +0100
+++ samba-3.0.10.dmro/source/smbd/dosmode.c	2005-01-03 12:13:03.313858000 +0100
@@ -3,6 +3,10 @@
    dos mode handling functions
    Copyright (C) Andrew Tridgell 1992-1998
    
+   07/14/2004 added "dos mask readonly" support
+              Markus Greger      <Markus.Greger@izb-soft.de>
+              Thomas Maier       <Thomas.Maier@izb-soft.de>
+    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
@@ -148,6 +152,10 @@
 #endif
 #endif
 
+	/* "dos mask readonly" patch by Markus Greger, Thomas Maier  IZB SOFT
07/14/2004 */
+	if ( (result & aRONLY) && lp_dos_mask_ro(SNUM(conn)) )
+		result &= ~(aRONLY);
+
 	DEBUG(8,("dos_mode_from_sbuf returning "));
 
 	if (result & aHIDDEN) DEBUG(8, ("h"));
Comment 1 Markus Greger 2005-01-15 07:56:52 UTC
Created attachment 891 [details]
Patch implementing the option 'dos mask readonly'
Comment 2 Gerald (Jerry) Carter (dead mail address) 2006-04-14 14:56:06 UTC
See 'map readonly' in the current code.  Should have 
a siumilar effect.  Thanks for the patch though.