[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-test-1491-g7135d2a

Derrell Lipman derrell.lipman at unwireduniverse.com
Thu Jan 17 16:51:07 GMT 2008


The branch, v3-2-test has been updated
       via  7135d2aea5a68a79e2a77d4a02219436f5e154cc (commit)
       via  41ad5c7700c5ef3839c0629ee5eb42ec0fe61da6 (commit)
       via  67c415661f6466c21cd0eaafabe58cba049d2af3 (commit)
       via  f5f46de404dba2e4a03d205a62cd5cf7ea4e075a (commit)
      from  a3b36c3cb0fe5f3e78c200290afa59829934f496 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 7135d2aea5a68a79e2a77d4a02219436f5e154cc
Merge: 41ad5c7700c5ef3839c0629ee5eb42ec0fe61da6 a3b36c3cb0fe5f3e78c200290afa59829934f496
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date:   Thu Jan 17 11:50:41 2008 -0500

    Merge branch 'v3-2-test' of ssh://git.samba.org/data/git/samba into v3-2-test

commit 41ad5c7700c5ef3839c0629ee5eb42ec0fe61da6
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date:   Thu Jan 17 11:50:22 2008 -0500

    stop bothering me about example programs not checked in

commit 67c415661f6466c21cd0eaafabe58cba049d2af3
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date:   Thu Jan 17 11:49:17 2008 -0500

    Fix bug 5185: repeated calls to smbc_getxattr() lose sid-name mapping
    
    If we're going to cache connections to IPC$, we'd better also cache the policy
    handle and not use a stack-based handle that's invalid on subsequent calls.
    
    Derrell

commit f5f46de404dba2e4a03d205a62cd5cf7ea4e075a
Author: Derrell Lipman <derrell.lipman at unwireduniverse.com>
Date:   Thu Jan 17 11:46:41 2008 -0500

    Add a program to test repeated calls to smbc_getxattr().

-----------------------------------------------------------------------

Summary of changes:
 .gitignore                                       |   16 ++++
 examples/libsmbclient/Makefile                   |    5 ++
 examples/libsmbclient/{testread.c => testacl3.c} |   31 ++++-----
 source/include/libsmb_internal.h                 |    1 +
 source/libsmb/libsmbclient.c                     |   83 ++++++++++------------
 5 files changed, 72 insertions(+), 64 deletions(-)
 copy examples/libsmbclient/{testread.c => testacl3.c} (64%)


Changeset truncated at 500 lines:

diff --git a/.gitignore b/.gitignore
index f11de08..b445ccf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 *.o
 *.po
 *~
+source/TAGS
 source/client/client_proto.h
 source/libnet/libnet_proto.h
 source/include/build_env.h
@@ -45,3 +46,18 @@ examples/VFS/module_config.h.in
 examples/VFS/shadow_copy_test.so
 examples/VFS/skel_opaque.so
 examples/VFS/skel_transparent.so
+examples/libsmbclient/smbwrapper/smbsh
+examples/libsmbclient/smbwrapper/smbwrapper.so
+examples/libsmbclient/testacl
+examples/libsmbclient/testacl2
+examples/libsmbclient/testacl3
+examples/libsmbclient/testbrowse
+examples/libsmbclient/testbrowse2
+examples/libsmbclient/testchmod
+examples/libsmbclient/testread
+examples/libsmbclient/testsmbc
+examples/libsmbclient/teststat
+examples/libsmbclient/teststat2
+examples/libsmbclient/teststat3
+examples/libsmbclient/testutime
+examples/libsmbclient/testwrite
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index 9657957..6c70659 100644
--- a/examples/libsmbclient/Makefile
+++ b/examples/libsmbclient/Makefile
@@ -18,6 +18,7 @@ LIBSMBCLIENT = -lwbclient -lsmbclient -ldl -lresolv
 TESTS=	testsmbc \
 	testacl \
 	testacl2 \
+	testacl3 \
 	testbrowse \
 	testbrowse2 \
 	teststat \
@@ -48,6 +49,10 @@ testacl2: testacl2.o
 	@echo Linking testacl2
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
 
+testacl3: testacl3.o
+	@echo Linking testacl3
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
 testbrowse: testbrowse.o
 	@echo Linking testbrowse
 	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
diff --git a/examples/libsmbclient/testread.c b/examples/libsmbclient/testacl3.c
similarity index 64%
copy from examples/libsmbclient/testread.c
copy to examples/libsmbclient/testacl3.c
index 3f94884..9102405 100644
--- a/examples/libsmbclient/testread.c
+++ b/examples/libsmbclient/testacl3.c
@@ -16,15 +16,20 @@ int main(int argc, char * argv[])
     int             debug = 0;
     int             mode = 0666;
     int             savedErrno;
-    char            buffer[2048]; 
+    char            value[2048]; 
     char            path[2048];
+    char *          the_acl;
     char *          p;
     time_t          t0;
     time_t          t1;
     struct stat     st; 
+    SMBCCTX *       context;
     
     smbc_init(get_auth_data_fn, debug); 
     
+    context = smbc_set_context(NULL);
+    smbc_option_set(context, "full_time_names", 1);
+    
     for (;;)
     {
         fprintf(stdout, "Path: ");
@@ -41,26 +46,16 @@ int main(int argc, char * argv[])
             *p = '\0';
         }
     
-        if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
-        {
-            perror("smbc_open");
-            continue;
-        }
-
-        do
-        {
-            ret = smbc_read(fd, buffer, sizeof(buffer));
-            savedErrno = errno;
-            if (ret > 0) fwrite(buffer, 1, ret, stdout);
-        } while (ret > 0);
-
-        smbc_close(fd);
-
+        the_acl = strdup("system.nt_sec_desc.*+");
+        ret = smbc_getxattr(path, the_acl, value, sizeof(value));
         if (ret < 0)
         {
-            errno = savedErrno;
-            perror("read");
+            printf("Could not get attributes for [%s] %d: %s\n",
+                   path, errno, strerror(errno));
+            return 1;
         }
+    
+        printf("Attributes for [%s] are:\n%s\n", path, value);
     }
 
     return 0; 
diff --git a/source/include/libsmb_internal.h b/source/include/libsmb_internal.h
index dbc1154..6c7dc80 100644
--- a/source/include/libsmb_internal.h
+++ b/source/include/libsmb_internal.h
@@ -15,6 +15,7 @@ struct _SMBCSRV {
 	bool no_pathinfo;
 	bool no_pathinfo2;
         bool no_nt_session;
+        POLICY_HND pol;
 
 	SMBCSRV *next, *prev;
 	
diff --git a/source/libsmb/libsmbclient.c b/source/libsmb/libsmbclient.c
index 0779706..2fd8294 100644
--- a/source/libsmb/libsmbclient.c
+++ b/source/libsmb/libsmbclient.c
@@ -1037,8 +1037,7 @@ smbc_attr_server(TALLOC_CTX *ctx,
 		const char *share,
 		char **pp_workgroup,
 		char **pp_username,
-		char **pp_password,
-		POLICY_HND *pol)
+		char **pp_password)
 {
         int flags;
         struct sockaddr_storage ss;
@@ -1122,36 +1121,34 @@ smbc_attr_server(TALLOC_CTX *ctx,
                 ZERO_STRUCTP(ipc_srv);
                 ipc_srv->cli = ipc_cli;
 
-                if (pol) {
-                        pipe_hnd = cli_rpc_pipe_open_noauth(ipc_srv->cli,
-                                                            PI_LSARPC,
-                                                            &nt_status);
-                        if (!pipe_hnd) {
-                                DEBUG(1, ("cli_nt_session_open fail!\n"));
-                                errno = ENOTSUP;
-                                cli_shutdown(ipc_srv->cli);
-                                free(ipc_srv);
-                                return NULL;
-                        }
-
-                        /*
-                         * Some systems don't support
-                         * SEC_RIGHTS_MAXIMUM_ALLOWED, but NT sends 0x2000000
-                         * so we might as well do it too.
-                         */
+                pipe_hnd = cli_rpc_pipe_open_noauth(ipc_srv->cli,
+                                                    PI_LSARPC,
+                                                    &nt_status);
+                if (!pipe_hnd) {
+                    DEBUG(1, ("cli_nt_session_open fail!\n"));
+                    errno = ENOTSUP;
+                    cli_shutdown(ipc_srv->cli);
+                    free(ipc_srv);
+                    return NULL;
+                }
 
-                        nt_status = rpccli_lsa_open_policy(
-                                pipe_hnd,
-                                talloc_tos(),
-                                True,
-                                GENERIC_EXECUTE_ACCESS,
-                                pol);
+                /*
+                 * Some systems don't support
+                 * SEC_RIGHTS_MAXIMUM_ALLOWED, but NT sends 0x2000000
+                 * so we might as well do it too.
+                 */
 
-                        if (!NT_STATUS_IS_OK(nt_status)) {
-                                errno = smbc_errno(context, ipc_srv->cli);
-                                cli_shutdown(ipc_srv->cli);
-                                return NULL;
-                        }
+                nt_status = rpccli_lsa_open_policy(
+                    pipe_hnd,
+                    talloc_tos(),
+                    True,
+                    GENERIC_EXECUTE_ACCESS,
+                    &ipc_srv->pol);
+
+                if (!NT_STATUS_IS_OK(nt_status)) {
+                    errno = smbc_errno(context, ipc_srv->cli);
+                    cli_shutdown(ipc_srv->cli);
+                    return NULL;
                 }
 
                 /* now add it to the cache (internal or external) */
@@ -5728,7 +5725,6 @@ smbc_setxattr_ctx(SMBCCTX *context,
 	char *password = NULL;
 	char *workgroup = NULL;
 	char *path = NULL;
-        POLICY_HND pol;
         DOS_ATTR_DESC *dad = NULL;
         struct {
                 const char * create_time_attr;
@@ -5787,8 +5783,7 @@ smbc_setxattr_ctx(SMBCCTX *context,
 
         if (! srv->no_nt_session) {
                 ipc_srv = smbc_attr_server(frame, context, server, share,
-                                           &workgroup, &user, &password,
-                                           &pol);
+                                           &workgroup, &user, &password);
                 if (! ipc_srv) {
                         srv->no_nt_session = True;
                 }
@@ -5814,7 +5809,7 @@ smbc_setxattr_ctx(SMBCCTX *context,
 
                 if (ipc_srv) {
                         ret = cacl_set(talloc_tos(), srv->cli,
-                                       ipc_srv->cli, &pol, path,
+                                       ipc_srv->cli, &ipc_srv->pol, path,
                                        namevalue,
                                        (*namevalue == '*'
                                         ? SMBC_XATTR_MODE_SET
@@ -5878,7 +5873,7 @@ smbc_setxattr_ctx(SMBCCTX *context,
                         ret = -1;
                 } else {
                         ret = cacl_set(talloc_tos(), srv->cli,
-                                       ipc_srv->cli, &pol, path,
+                                       ipc_srv->cli, &ipc_srv->pol, path,
                                        namevalue,
                                        (*namevalue == '*'
                                         ? SMBC_XATTR_MODE_SET
@@ -5908,7 +5903,7 @@ smbc_setxattr_ctx(SMBCCTX *context,
                         ret = -1;
                 } else {
                         ret = cacl_set(talloc_tos(), srv->cli,
-                                       ipc_srv->cli, &pol, path,
+                                       ipc_srv->cli, &ipc_srv->pol, path,
                                        namevalue, SMBC_XATTR_MODE_CHOWN, 0);
                 }
 		TALLOC_FREE(frame);
@@ -5935,7 +5930,7 @@ smbc_setxattr_ctx(SMBCCTX *context,
                         ret = -1;
                 } else {
                         ret = cacl_set(talloc_tos(), srv->cli,
-                                       ipc_srv->cli, &pol, path,
+                                       ipc_srv->cli, &ipc_srv->pol, path,
                                        namevalue, SMBC_XATTR_MODE_CHOWN, 0);
                 }
 		TALLOC_FREE(frame);
@@ -6026,7 +6021,6 @@ smbc_getxattr_ctx(SMBCCTX *context,
 	char *password = NULL;
 	char *workgroup = NULL;
 	char *path = NULL;
-        POLICY_HND pol;
         struct {
                 const char * create_time_attr;
                 const char * access_time_attr;
@@ -6083,8 +6077,7 @@ smbc_getxattr_ctx(SMBCCTX *context,
 
         if (! srv->no_nt_session) {
                 ipc_srv = smbc_attr_server(frame, context, server, share,
-                                           &workgroup, &user, &password,
-                                           &pol);
+                                           &workgroup, &user, &password);
                 if (! ipc_srv) {
                         srv->no_nt_session = True;
                 }
@@ -6137,7 +6130,7 @@ smbc_getxattr_ctx(SMBCCTX *context,
                 /* Yup. */
                 ret = cacl_get(context, talloc_tos(), srv,
                                ipc_srv == NULL ? NULL : ipc_srv->cli, 
-                               &pol, path,
+                               &ipc_srv->pol, path,
                                CONST_DISCARD(char *, name),
                                CONST_DISCARD(char *, value), size);
                 if (ret < 0 && errno == 0) {
@@ -6168,7 +6161,6 @@ smbc_removexattr_ctx(SMBCCTX *context,
 	char *password = NULL;
 	char *workgroup = NULL;
 	char *path = NULL;
-        POLICY_HND pol;
 	TALLOC_CTX *frame = talloc_stackframe();
 
         if (!context || !context->internal ||
@@ -6219,8 +6211,7 @@ smbc_removexattr_ctx(SMBCCTX *context,
 
         if (! srv->no_nt_session) {
                 ipc_srv = smbc_attr_server(frame, context, server, share,
-                                           &workgroup, &user, &password,
-                                           &pol);
+                                           &workgroup, &user, &password);
                 if (! ipc_srv) {
                         srv->no_nt_session = True;
                 }
@@ -6239,7 +6230,7 @@ smbc_removexattr_ctx(SMBCCTX *context,
 
                 /* Yup. */
                 ret = cacl_set(talloc_tos(), srv->cli,
-                               ipc_srv->cli, &pol, path,
+                               ipc_srv->cli, &ipc_srv->pol, path,
                                NULL, SMBC_XATTR_MODE_REMOVE_ALL, 0);
 		TALLOC_FREE(frame);
                 return ret;
@@ -6259,7 +6250,7 @@ smbc_removexattr_ctx(SMBCCTX *context,
 
                 /* Yup. */
                 ret = cacl_set(talloc_tos(), srv->cli,
-                               ipc_srv->cli, &pol, path,
+                               ipc_srv->cli, &ipc_srv->pol, path,
                                name + 19, SMBC_XATTR_MODE_REMOVE, 0);
 		TALLOC_FREE(frame);
                 return ret;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list