svn commit: samba r22914 - in branches/SAMBA_3_0: examples/libsmbclient source/libsmb

derrell at samba.org derrell at samba.org
Tue May 15 19:10:30 GMT 2007


Author: derrell
Date: 2007-05-15 19:10:29 +0000 (Tue, 15 May 2007)
New Revision: 22914

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

Log:

- Fixes bug 4599.  A missing <code>if</code> statement forced subseqeuent
  attempts to set attributes to fail.

- I also noticed that missing attributes were setting an invalid return string
  by getxattr(), e.g. if there was not group, the return string had "GROUP:;"
  instead of excluding the GROUP attribute entirely as it should.  The big
  problem with the way it was, is that the string could not then be passed to
  setxattr() and parsed.

Added:
   branches/SAMBA_3_0/examples/libsmbclient/testacl2.c
Modified:
   branches/SAMBA_3_0/examples/libsmbclient/Makefile
   branches/SAMBA_3_0/source/libsmb/libsmbclient.c


Changeset:
Modified: branches/SAMBA_3_0/examples/libsmbclient/Makefile
===================================================================
--- branches/SAMBA_3_0/examples/libsmbclient/Makefile	2007-05-15 18:23:58 UTC (rev 22913)
+++ branches/SAMBA_3_0/examples/libsmbclient/Makefile	2007-05-15 19:10:29 UTC (rev 22914)
@@ -17,6 +17,7 @@
 TESTS=	testsmbc \
 	tree \
 	testacl \
+	testacl2 \
 	testbrowse \
 	testbrowse2 \
 	teststat \
@@ -39,6 +40,10 @@
 	@echo Linking testacl
 	$(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt
 
+testacl2: testacl2.o
+	@echo Linking testacl2
+	$(CC) `gtk-config --cflags` $(CFLAGS) $(LDFLAGS) -o $@ $< `gtk-config --libs` $(LIBSMBCLIENT) -lpopt
+
 testbrowse: testbrowse.o
 	@echo Linking testbrowse
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt

Added: branches/SAMBA_3_0/examples/libsmbclient/testacl2.c
===================================================================
--- branches/SAMBA_3_0/examples/libsmbclient/testacl2.c	2007-05-15 18:23:58 UTC (rev 22913)
+++ branches/SAMBA_3_0/examples/libsmbclient/testacl2.c	2007-05-15 19:10:29 UTC (rev 22914)
@@ -0,0 +1,78 @@
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <popt.h>
+#include "libsmbclient.h"
+#include "get_auth_data_fn.h"
+
+enum acl_mode
+{
+    SMB_ACL_GET,
+    SMB_ACL_SET,
+    SMB_ACL_DELETE,
+    SMB_ACL_MODIFY,
+    SMB_ACL_ADD,
+    SMB_ACL_CHOWN,
+    SMB_ACL_CHGRP
+};
+
+
+int main(int argc, const char *argv[])
+{
+    int i;
+    int opt;
+    int flags;
+    int debug = 0;
+    int numeric = 0;
+    int full_time_names = 0;
+    enum acl_mode mode = SMB_ACL_GET;
+    static char *the_acl = NULL;
+    int ret;
+    char *p;
+    char *debugstr;
+    char value[1024];
+
+    if (smbc_init(get_auth_data_fn, debug) != 0)
+    {
+        printf("Could not initialize smbc_ library\n");
+        return 1;
+    }
+
+    SMBCCTX *context = smbc_set_context(NULL);
+    smbc_option_set(context, "full_time_names", 1);
+    
+    the_acl = strdup("system.nt_sec_desc.*");
+    ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value));
+    if (ret < 0)
+    {
+        printf("Could not get attributes for [%s] %d: %s\n",
+               argv[1], errno, strerror(errno));
+        return 1;
+    }
+    
+    printf("Attributes for [%s] are:\n%s\n", argv[1], value);
+
+    flags = 0;
+    debugstr = "set attributes (1st time)";
+        
+    ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
+    if (ret < 0)
+    {
+        printf("Could not %s for [%s] %d: %s\n",
+               debugstr, argv[1], errno, strerror(errno));
+        return 1;
+    }
+    
+    flags = 0;
+    debugstr = "set attributes (2nd time)";
+        
+    ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
+    if (ret < 0)
+    {
+        printf("Could not %s for [%s] %d: %s\n",
+               debugstr, argv[1], errno, strerror(errno));
+        return 1;
+    }
+    
+    return 0;
+}

Modified: branches/SAMBA_3_0/source/libsmb/libsmbclient.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/libsmbclient.c	2007-05-15 18:23:58 UTC (rev 22913)
+++ branches/SAMBA_3_0/source/libsmb/libsmbclient.c	2007-05-15 19:10:29 UTC (rev 22914)
@@ -4546,7 +4546,7 @@
                                                 return -1;
                                         }
                                         n = strlen(p);
-                                } else {
+                                } else if (sidstr[0] != '\0') {
                                         n = snprintf(buf, bufsize,
                                                      ",OWNER:%s", sidstr);
                                 }
@@ -4591,7 +4591,7 @@
                                                 return -1;
                                         }
                                         n = strlen(p);
-                                } else {
+                                } else if (sidstr[0] != '\0') {
                                         n = snprintf(buf, bufsize,
                                                      ",GROUP:%s", sidstr);
                                 }
@@ -5317,7 +5317,9 @@
                 ipc_srv = smbc_attr_server(context, server, share,
                                            workgroup, user, password,
                                            &pol);
-                srv->no_nt_session = True;
+                if (! ipc_srv) {
+                        srv->no_nt_session = True;
+                }
         } else {
                 ipc_srv = NULL;
         }
@@ -5742,7 +5744,9 @@
                 ipc_srv = smbc_attr_server(context, server, share,
                                            workgroup, user, password,
                                            &pol);
-                srv->no_nt_session = True;
+                if (! ipc_srv) {
+                        srv->no_nt_session = True;
+                }
         } else {
                 ipc_srv = NULL;
         }



More information about the samba-cvs mailing list