[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-179-g2ce76ce

Günther Deschner gd at samba.org
Mon Mar 10 04:20:07 GMT 2008


The branch, v3-2-test has been updated
       via  2ce76ce2bccefb4a072bed039a4837ae334dea55 (commit)
       via  0cf761f604975930f38213233e4bbf48d7ae7283 (commit)
       via  6aad05f3f12fd6b3276486f60c10f5b3fd3fa17c (commit)
       via  8216310e9f0d7dcccfe761a184a014b7b2ce03c5 (commit)
      from  1121633652ffb77dce8df9cc91b7dfc2d55fd348 (commit)

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


- Log -----------------------------------------------------------------
commit 2ce76ce2bccefb4a072bed039a4837ae334dea55
Author: Günther Deschner <gd at samba.org>
Date:   Mon Mar 10 05:17:09 2008 +0100

    Use rpccli_srvsvc_NetShareGetInfo in 2 places in "net".
    
    Guenther

commit 0cf761f604975930f38213233e4bbf48d7ae7283
Author: Günther Deschner <gd at samba.org>
Date:   Mon Mar 10 05:05:37 2008 +0100

    Use rpccli_srvsvc_NetShareEnumAll in smbtree.
    
    Guenther

commit 6aad05f3f12fd6b3276486f60c10f5b3fd3fa17c
Author: Günther Deschner <gd at samba.org>
Date:   Mon Mar 10 04:58:43 2008 +0100

    Use rpccli_srvsvc_NetShareEnumAll in libsmbclient.
    
    Guenther

commit 8216310e9f0d7dcccfe761a184a014b7b2ce03c5
Author: Günther Deschner <gd at samba.org>
Date:   Fri Mar 7 17:37:07 2008 +0100

    Remove insane amount of whitespace.
    
    Guenther

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

Summary of changes:
 source/libsmb/libsmb_dir.c |  776 ++++++++++++++++++++++----------------------
 source/utils/net_rpc.c     |   47 ++--
 source/utils/smbtree.c     |   36 ++-
 3 files changed, 435 insertions(+), 424 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libsmb/libsmb_dir.c b/source/libsmb/libsmb_dir.c
index 1486097..f836989 100644
--- a/source/libsmb/libsmb_dir.c
+++ b/source/libsmb/libsmb_dir.c
@@ -1,23 +1,23 @@
-/* 
+/*
    Unix SMB/Netbios implementation.
    SMB client library implementation
    Copyright (C) Andrew Tridgell 1998
    Copyright (C) Richard Sharpe 2000, 2002
    Copyright (C) John Terpstra 2000
-   Copyright (C) Tom Jansen (Ninja ISD) 2002 
+   Copyright (C) Tom Jansen (Ninja ISD) 2002
    Copyright (C) Derrell Lipman 2003-2008
    Copyright (C) Jeremy Allison 2007, 2008
-   
+
    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 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -36,19 +36,19 @@ static void
 remove_dir(SMBCFILE *dir)
 {
 	struct smbc_dir_list *d,*f;
-        
+
 	d = dir->dir_list;
 	while (d) {
-                
+
 		f = d; d = d->next;
-                
+
 		SAFE_FREE(f->dirent);
 		SAFE_FREE(f);
-                
+
 	}
-        
+
 	dir->dir_list = dir->dir_end = dir->dir_next = NULL;
-        
+
 }
 
 static int
@@ -61,63 +61,63 @@ add_dirent(SMBCFILE *dir,
 	int size;
         int name_length = (name == NULL ? 0 : strlen(name));
         int comment_len = (comment == NULL ? 0 : strlen(comment));
-        
+
 	/*
-	 * Allocate space for the dirent, which must be increased by the 
+	 * Allocate space for the dirent, which must be increased by the
 	 * size of the name and the comment and 1 each for the null terminator.
 	 */
-        
+
 	size = sizeof(struct smbc_dirent) + name_length + comment_len + 2;
-        
+
 	dirent = (struct smbc_dirent *)SMB_MALLOC(size);
-        
+
 	if (!dirent) {
-                
+
 		dir->dir_error = ENOMEM;
 		return -1;
-                
+
 	}
-        
+
 	ZERO_STRUCTP(dirent);
-        
+
 	if (dir->dir_list == NULL) {
-                
+
 		dir->dir_list = SMB_MALLOC_P(struct smbc_dir_list);
 		if (!dir->dir_list) {
-                        
+
 			SAFE_FREE(dirent);
 			dir->dir_error = ENOMEM;
 			return -1;
-                        
+
 		}
 		ZERO_STRUCTP(dir->dir_list);
-                
+
 		dir->dir_end = dir->dir_next = dir->dir_list;
 	}
 	else {
-                
+
 		dir->dir_end->next = SMB_MALLOC_P(struct smbc_dir_list);
-                
+
 		if (!dir->dir_end->next) {
-                        
+
 			SAFE_FREE(dirent);
 			dir->dir_error = ENOMEM;
 			return -1;
-                        
+
 		}
 		ZERO_STRUCTP(dir->dir_end->next);
-                
+
 		dir->dir_end = dir->dir_end->next;
 	}
-        
+
 	dir->dir_end->next = NULL;
 	dir->dir_end->dirent = dirent;
-        
+
 	dirent->smbc_type = type;
 	dirent->namelen = name_length;
 	dirent->commentlen = comment_len;
 	dirent->dirlen = size;
-        
+
         /*
          * dirent->namelen + 1 includes the null (no null termination needed)
          * Ditto for dirent->commentlen.
@@ -126,9 +126,9 @@ add_dirent(SMBCFILE *dir,
 	strncpy(dirent->name, (name?name:""), dirent->namelen + 1);
 	dirent->comment = (char *)(&dirent->name + dirent->namelen + 1);
 	strncpy(dirent->comment, (comment?comment:""), dirent->commentlen + 1);
-        
+
 	return 0;
-        
+
 }
 
 static void
@@ -142,18 +142,18 @@ list_unique_wg_fn(const char *name,
         struct smbc_dirent *dirent;
 	int dirent_type;
         int do_remove = 0;
-        
+
 	dirent_type = dir->dir_type;
-        
+
 	if (add_dirent(dir, name, comment, dirent_type) < 0) {
-                
+
 		/* An error occurred, what do we do? */
 		/* FIXME: Add some code here */
 	}
-        
+
         /* Point to the one just added */
         dirent = dir->dir_end->dirent;
-        
+
         /* See if this was a duplicate */
         for (dir_list = dir->dir_list;
              dir_list != dir->dir_end;
@@ -163,7 +163,7 @@ list_unique_wg_fn(const char *name,
                         /* Duplicate.  End end of list need to be removed. */
                         do_remove = 1;
                 }
-                
+
                 if (do_remove && dir_list->next == dir->dir_end) {
                         /* Found the end of the list.  Remove it. */
                         dir->dir_end = dir_list;
@@ -183,7 +183,7 @@ list_fn(const char *name,
 {
 	SMBCFILE *dir = (SMBCFILE *)state;
 	int dirent_type;
-        
+
 	/*
          * We need to process the type a little ...
          *
@@ -195,27 +195,27 @@ list_fn(const char *name,
          * administrative shares:
          * ADMIN$, IPC$, C$, D$, E$ ...  are type |= 0x80000000
          */
-        
+
 	if (dir->dir_type == SMBC_FILE_SHARE) {
 		switch (type) {
                 case 0 | 0x80000000:
 		case 0:
 			dirent_type = SMBC_FILE_SHARE;
 			break;
-                        
+
 		case 1:
 			dirent_type = SMBC_PRINTER_SHARE;
 			break;
-                        
+
 		case 2:
 			dirent_type = SMBC_COMMS_SHARE;
 			break;
-                        
+
                 case 3 | 0x80000000:
 		case 3:
 			dirent_type = SMBC_IPC_SHARE;
 			break;
-                        
+
 		default:
 			dirent_type = SMBC_FILE_SHARE; /* FIXME, error? */
 			break;
@@ -224,12 +224,12 @@ list_fn(const char *name,
 	else {
                 dirent_type = dir->dir_type;
         }
-        
+
 	if (add_dirent(dir, name, comment, dirent_type) < 0) {
-                
+
 		/* An error occurred, what do we do? */
 		/* FIXME: Add some code here */
-                
+
 	}
 }
 
@@ -239,16 +239,16 @@ dir_list_fn(const char *mnt,
             const char *mask,
             void *state)
 {
-        
-	if (add_dirent((SMBCFILE *)state, finfo->name, "", 
+
+	if (add_dirent((SMBCFILE *)state, finfo->name, "",
 		       (finfo->mode&aDIR?SMBC_DIR:SMBC_FILE)) < 0) {
-                
+
 		/* Handle an error ... */
-                
+
 		/* FIXME: Add some code ... */
-                
-	} 
-        
+
+	}
+
 }
 
 static int
@@ -261,60 +261,66 @@ net_share_enum_rpc(struct cli_state *cli,
 {
         int i;
 	WERROR result;
-	ENUM_HND enum_hnd;
-        uint32 info_level = 1;
 	uint32 preferred_len = 0xffffffff;
         uint32 type;
-	SRV_SHARE_INFO_CTR ctr;
+	struct srvsvc_NetShareInfoCtr info_ctr;
+	struct srvsvc_NetShareCtr1 ctr1;
 	fstring name = "";
         fstring comment = "";
 	struct rpc_pipe_client *pipe_hnd;
         NTSTATUS nt_status;
-        
+	uint32_t resume_handle = 0;
+	uint32_t total_entries = 0;
+
         /* Open the server service pipe */
         pipe_hnd = cli_rpc_pipe_open_noauth(cli, PI_SRVSVC, &nt_status);
         if (!pipe_hnd) {
                 DEBUG(1, ("net_share_enum_rpc pipe open fail!\n"));
                 return -1;
         }
-        
+
+	ZERO_STRUCT(info_ctr);
+	ZERO_STRUCT(ctr1);
+
+	info_ctr.level = 1;
+	info_ctr.ctr.ctr1 = &ctr1;
+
         /* Issue the NetShareEnum RPC call and retrieve the response */
-	init_enum_hnd(&enum_hnd, 0);
-	result = rpccli_srvsvc_net_share_enum(pipe_hnd,
-                                              talloc_tos(),
-                                              info_level,
-                                              &ctr,
-                                              preferred_len,
-                                              &enum_hnd);
-        
+	nt_status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, talloc_tos(),
+						  pipe_hnd->cli->desthost,
+						  &info_ctr,
+						  preferred_len,
+						  &total_entries,
+						  &resume_handle,
+						  &result);
+
         /* Was it successful? */
-	if (!W_ERROR_IS_OK(result) || ctr.num_entries == 0) {
+	if (!NT_STATUS_IS_OK(nt_status) || !W_ERROR_IS_OK(result) ||
+	    total_entries == 0) {
                 /*  Nope.  Go clean up. */
 		goto done;
         }
-        
+
         /* For each returned entry... */
-        for (i = 0; i < ctr.num_entries; i++) {
-                
+        for (i = 0; i < total_entries; i++) {
+
                 /* pull out the share name */
-                rpcstr_pull_unistr2_fstring(
-                        name, &ctr.share.info1[i].info_1_str.uni_netname);
-                
+		fstrcpy(name, info_ctr.ctr.ctr1->array[i].name);
+
                 /* pull out the share's comment */
-                rpcstr_pull_unistr2_fstring(
-                        comment, &ctr.share.info1[i].info_1_str.uni_remark);
-                
+		fstrcpy(comment, info_ctr.ctr.ctr1->array[i].comment);
+
                 /* Get the type value */
-                type = ctr.share.info1[i].info_1.type;
-                
+                type = info_ctr.ctr.ctr1->array[i].type;
+
                 /* Add this share to the list */
                 (*fn)(name, type, comment, state);
         }
-        
+
 done:
         /* Close the server service pipe */
         cli_rpc_pipe_close(pipe_hnd);
-        
+
         /* Tell 'em if it worked */
         return W_ERROR_IS_OK(result) ? 0 : -1;
 }
@@ -332,10 +338,10 @@ SMBC_check_options(char *server,
         DEBUG(4, ("SMBC_check_options(): server='%s' share='%s' "
                   "path='%s' options='%s'\n",
                   server, share, path, options));
-        
+
         /* No options at all is always ok */
         if (! *options) return 0;
-        
+
         /* Currently, we don't support any options. */
         return -1;
 }
@@ -359,22 +365,22 @@ SMBC_opendir_ctx(SMBCCTX *context,
 	SMBCFILE *dir = NULL;
 	struct sockaddr_storage rem_ss;
 	TALLOC_CTX *frame = talloc_stackframe();
-        
+
 	if (!context || !context->internal->initialized) {
 	        DEBUG(4, ("no valid context\n"));
 		errno = EINVAL + 8192;
 		TALLOC_FREE(frame);
 		return NULL;
-                
+
 	}
-        
+
 	if (!fname) {
 		DEBUG(4, ("no valid fname\n"));
 		errno = EINVAL + 8193;
 		TALLOC_FREE(frame);
 		return NULL;
 	}
-        
+
 	if (SMBC_parse_path(frame,
                             context,
                             fname,
@@ -390,11 +396,11 @@ SMBC_opendir_ctx(SMBCCTX *context,
 		TALLOC_FREE(frame);
 		return NULL;
 	}
-        
+
 	DEBUG(4, ("parsed path: fname='%s' server='%s' share='%s' "
                   "path='%s' options='%s'\n",
                   fname, server, share, path, options));
-        
+
         /* Ensure the options are valid */
         if (SMBC_check_options(server, share, path, options)) {
                 DEBUG(4, ("unacceptable options (%s)\n", options));
@@ -402,7 +408,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
 		TALLOC_FREE(frame);
                 return NULL;
         }
-        
+
 	if (!user || user[0] == (char)0) {
 		user = talloc_strdup(frame, smbc_getUser(context));
 		if (!user) {
@@ -411,35 +417,35 @@ SMBC_opendir_ctx(SMBCCTX *context,
 			return NULL;
 		}
 	}
-        
+
 	dir = SMB_MALLOC_P(SMBCFILE);
-        
+
 	if (!dir) {
 		errno = ENOMEM;
 		TALLOC_FREE(frame);
 		return NULL;
 	}
-        
+
 	ZERO_STRUCTP(dir);
-        
+
 	dir->cli_fd   = 0;
 	dir->fname    = SMB_STRDUP(fname);
 	dir->srv      = NULL;
 	dir->offset   = 0;
 	dir->file     = False;
 	dir->dir_list = dir->dir_next = dir->dir_end = NULL;
-        
+
 	if (server[0] == (char)0) {
-                
+
                 int i;
                 int count;
                 int max_lmb_count;
                 struct ip_service *ip_list;
                 struct ip_service server_addr;
                 struct user_auth_info u_info;
-                
+
 		if (share[0] != (char)0 || path[0] != (char)0) {
-                        
+
 			errno = EINVAL + 8196;
 			if (dir) {
 				SAFE_FREE(dir->fname);
@@ -448,12 +454,12 @@ SMBC_opendir_ctx(SMBCCTX *context,
 			TALLOC_FREE(frame);
 			return NULL;
 		}
-                
+
                 /* Determine how many local master browsers to query */
                 max_lmb_count = (smbc_getOptionBrowseMaxLmbCount(context) == 0
                                  ? INT_MAX
                                  : smbc_getOptionBrowseMaxLmbCount(context));
-                
+
 		memset(&u_info, '\0', sizeof(u_info));
 		u_info.username = talloc_strdup(frame,user);
 		u_info.password = talloc_strdup(frame,password);
@@ -465,7 +471,7 @@ SMBC_opendir_ctx(SMBCCTX *context,
 			TALLOC_FREE(frame);
 			return NULL;
 		}
-                
+
 		/*
                  * We have server and share and path empty but options
                  * requesting that we scan all master browsers for their list
@@ -474,16 +480,16 @@ SMBC_opendir_ctx(SMBCCTX *context,
                  * doesn't work, then try our other methods which return only
                  * a single master browser.
                  */


-- 
Samba Shared Repository


More information about the samba-cvs mailing list