svn commit: samba r18013 - in branches/SAMBA_3_0/source: include libsmb

derrell at samba.org derrell at samba.org
Sun Sep 3 02:10:25 GMT 2006


Author: derrell
Date: 2006-09-03 02:10:24 +0000 (Sun, 03 Sep 2006)
New Revision: 18013

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18013

Log:
Fix for "bug" (enhancement) 3684.

Provide a new option to specify the share mode to be used when opening a
file.

Modified:
   branches/SAMBA_3_0/source/include/libsmb_internal.h
   branches/SAMBA_3_0/source/include/libsmbclient.h
   branches/SAMBA_3_0/source/libsmb/libsmbclient.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/libsmb_internal.h
===================================================================
--- branches/SAMBA_3_0/source/include/libsmb_internal.h	2006-09-03 01:37:26 UTC (rev 18012)
+++ branches/SAMBA_3_0/source/include/libsmb_internal.h	2006-09-03 02:10:24 UTC (rev 18013)
@@ -90,6 +90,12 @@
         BOOL _full_time_names;
 
         /*
+         * The share mode of a file being opened.  To match POSIX semantics
+         * (and maintain backward compatibility), DENY_NONE is the default.
+         */
+         smbc_share_mode _share_mode;
+
+        /*
          * Authentication function which includes the context.  This will be
          * used if set; otherwise context->callbacks.auth_fn() will be used.
          */

Modified: branches/SAMBA_3_0/source/include/libsmbclient.h
===================================================================
--- branches/SAMBA_3_0/source/include/libsmbclient.h	2006-09-03 01:37:26 UTC (rev 18012)
+++ branches/SAMBA_3_0/source/include/libsmbclient.h	2006-09-03 02:10:24 UTC (rev 18013)
@@ -141,7 +141,21 @@
 #define SMBC_DOS_MODE_DIRECTORY      0x10
 #define SMBC_DOS_MODE_ARCHIVE        0x20
 
+/*
+ * Valid values for the option "open_share_mode", when calling
+ * smbc_option_set()
+ */
+typedef enum smbc_share_mode
+{
+    SMBC_SHAREMODE_DENY_DOS     = 0,
+    SMBC_SHAREMODE_DENY_ALL     = 1,
+    SMBC_SHAREMODE_DENY_WRITE   = 2,
+    SMBC_SHAREMODE_DENY_READ    = 3,
+    SMBC_SHAREMODE_DENY_NONE    = 4,
+    SMBC_SHAREMODE_DENY_FCB     = 7
+} smbc_share_mode;
 
+
 #ifndef ENOATTR
 # define ENOATTR ENOENT        /* No such attribute */
 #endif

Modified: branches/SAMBA_3_0/source/libsmb/libsmbclient.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/libsmbclient.c	2006-09-03 01:37:26 UTC (rev 18012)
+++ branches/SAMBA_3_0/source/libsmb/libsmbclient.c	2006-09-03 02:10:24 UTC (rev 18013)
@@ -1120,7 +1120,8 @@
 			cli_dfs_make_full_path( targetpath, targetcli->desthost, targetcli->share, temppath);
 		}
 		
-		if ((fd = cli_open(targetcli, targetpath, flags, DENY_NONE)) < 0) {
+		if ((fd = cli_open(targetcli, targetpath, flags,
+                                   context->internal->_share_mode)) < 0) {
 
 			/* Handle the error ... */
 
@@ -6166,6 +6167,8 @@
 	context->options.browse_max_lmb_count      = 3;    /* # LMBs to query */
 	context->options.urlencode_readdir_entries = False;/* backward compat */
 	context->options.one_share_per_server      = False;/* backward compat */
+        context->internal->_share_mode             = SMBC_SHAREMODE_DENY_NONE;
+                                /* backward compat */
 
         context->open                              = smbc_open_ctx;
         context->creat                             = smbc_creat_ctx;
@@ -6301,6 +6304,7 @@
 {
         va_list ap;
         union {
+                int i;
                 BOOL b;
                 smbc_get_auth_data_with_context_fn auth_fn;
                 void *v;
@@ -6327,6 +6331,15 @@
                 option_value.b = (BOOL) va_arg(ap, int);
                 context->internal->_full_time_names = option_value.b;
 
+        } else if (strcmp(option_name, "open_share_mode") == 0) {
+                /*
+                 * The share mode to use for files opened with
+                 * smbc_open_ctx().  The default is SMBC_SHAREMODE_DENY_NONE.
+                 */
+                option_value.i = va_arg(ap, int);
+                context->internal->_share_mode =
+                        (smbc_share_mode) option_value.i;
+
         } else if (strcmp(option_name, "auth_function") == 0) {
                 /*
                  * Use the new-style authentication function which includes



More information about the samba-cvs mailing list