[SCM] Samba Shared Repository - branch master updated - 0bfbae0f50df01ff058a23419173fd0553281fab

Günther Deschner gd at samba.org
Thu Oct 23 22:07:58 GMT 2008


The branch, master has been updated
       via  0bfbae0f50df01ff058a23419173fd0553281fab (commit)
       via  d27bc7377aaea09652d14d06ce70c98d8f618ca7 (commit)
       via  3971492301d84d41942c4986eccebf1aa6557b46 (commit)
       via  2b364550a91555031548603608251026c15369de (commit)
       via  78a85f9e96e4c1d5a99e328e8ca07b1f75a79467 (commit)
      from  25988f13696547e70b5e3155cb5bcea2f0786312 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 0bfbae0f50df01ff058a23419173fd0553281fab
Author: Günther Deschner <gd at samba.org>
Date:   Fri Oct 24 00:05:05 2008 +0200

    netapi: make sure to always cleanup after testing NetUser calls.
    
    Guenther

commit d27bc7377aaea09652d14d06ce70c98d8f618ca7
Author: Günther Deschner <gd at samba.org>
Date:   Thu Oct 23 23:13:09 2008 +0200

    netapi: add more group tests to netapitest.
    
    Guenther

commit 3971492301d84d41942c4986eccebf1aa6557b46
Author: Günther Deschner <gd at samba.org>
Date:   Thu Oct 23 23:11:50 2008 +0200

    s3-samr-server: return NT_STATUS_NOT_SUPPORTED for group rename.
    
    Guenther

commit 2b364550a91555031548603608251026c15369de
Author: Günther Deschner <gd at samba.org>
Date:   Thu Oct 23 22:26:21 2008 +0200

    s3-samr-server: remove unused historic code.
    
    Guenther

commit 78a85f9e96e4c1d5a99e328e8ca07b1f75a79467
Author: Günther Deschner <gd at samba.org>
Date:   Thu Oct 23 20:43:11 2008 +0200

    svcctl: move some non-rpc related bits out of rpc_svcctl.h.
    
    Guenther

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

Summary of changes:
 source3/include/includes.h          |    1 +
 source3/include/rpc_svcctl.h        |   23 ----
 source3/include/services.h          |   48 ++++++++
 source3/lib/netapi/tests/netgroup.c |  223 ++++++++++++++++++++++++++++++++++-
 source3/lib/netapi/tests/netuser.c  |    4 +
 source3/rpc_server/srv_samr_nt.c    |   63 +----------
 6 files changed, 276 insertions(+), 86 deletions(-)
 create mode 100644 source3/include/services.h


Changeset truncated at 500 lines:

diff --git a/source3/include/includes.h b/source3/include/includes.h
index 035d46f..24e33c1 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -659,6 +659,7 @@ struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
 #include "async_req.h"
 #include "async_smb.h"
 #include "async_sock.h"
+#include "services.h"
 
 #include "lib/smbconf/smbconf.h"
 
diff --git a/source3/include/rpc_svcctl.h b/source3/include/rpc_svcctl.h
index 0e31a53..2785840 100644
--- a/source3/include/rpc_svcctl.h
+++ b/source3/include/rpc_svcctl.h
@@ -117,9 +117,6 @@
 
 #define SVC_STATUS_PROCESS_INFO                 0x00000000
 
-/* where we assume the location of the service control scripts */
-#define SVCCTL_SCRIPT_DIR  "svcctl"
-
 /* utility structures for RPCs */
 
 /*
@@ -159,26 +156,6 @@ typedef struct {
         SC_ACTION *actions;
 } SERVICE_FAILURE_ACTIONS;
 
-/* 
- * dispatch table of functions to handle the =ServiceControl API
- */ 
- 
-typedef struct {
-	/* functions for enumerating subkeys and values */	
-	WERROR 	(*stop_service)( const char *service, SERVICE_STATUS *status );
-	WERROR 	(*start_service) ( const char *service );
-	WERROR 	(*service_status)( const char *service, SERVICE_STATUS *status );
-} SERVICE_CONTROL_OPS;
-
-/* structure to store the service handle information  */
-
-typedef struct _ServiceInfo {
-	uint8			type;
-	char			*name;
-	uint32			access_granted;
-	SERVICE_CONTROL_OPS	*ops;
-} SERVICE_INFO;
-
 
 /* rpc structures */
 
diff --git a/source3/include/services.h b/source3/include/services.h
new file mode 100644
index 0000000..8c2a0cc
--- /dev/null
+++ b/source3/include/services.h
@@ -0,0 +1,48 @@
+/*
+   Unix SMB/CIFS implementation.
+   SMB parameters and setup
+   Copyright (C) Andrew Tridgell              1992-1997,
+   Copyright (C) Gerald (Jerry) Carter        2005
+
+   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/>.
+*/
+
+#ifndef _SERVICES_H /* _SERVICES_H */
+#define _SERVICES_H
+
+/* where we assume the location of the service control scripts */
+#define SVCCTL_SCRIPT_DIR  "svcctl"
+
+/*
+ * dispatch table of functions to handle the =ServiceControl API
+ */
+
+typedef struct {
+	/* functions for enumerating subkeys and values */
+	WERROR 	(*stop_service)( const char *service, SERVICE_STATUS *status );
+	WERROR 	(*start_service) ( const char *service );
+	WERROR 	(*service_status)( const char *service, SERVICE_STATUS *status );
+} SERVICE_CONTROL_OPS;
+
+/* structure to store the service handle information  */
+
+typedef struct _ServiceInfo {
+	uint8			type;
+	char			*name;
+	uint32			access_granted;
+	SERVICE_CONTROL_OPS	*ops;
+} SERVICE_INFO;
+
+#endif /* _SERICES_H */
+
diff --git a/source3/lib/netapi/tests/netgroup.c b/source3/lib/netapi/tests/netgroup.c
index 51a21b3..e43520a 100644
--- a/source3/lib/netapi/tests/netgroup.c
+++ b/source3/lib/netapi/tests/netgroup.c
@@ -127,6 +127,152 @@ static NET_API_STATUS test_netgroupenum(const char *hostname,
 	return 0;
 }
 
+static NET_API_STATUS test_netgroupgetusers(const char *hostname,
+					    uint32_t level,
+					    const char *groupname,
+					    const char *username)
+{
+	NET_API_STATUS status;
+	uint32_t entries_read = 0;
+	uint32_t total_entries = 0;
+	uint32_t resume_handle = 0;
+	int found_user = 0;
+	const char *current_name = NULL;
+	uint8_t *buffer = NULL;
+	int i;
+
+	struct GROUP_USERS_INFO_0 *info0 = NULL;
+	struct GROUP_USERS_INFO_1 *info1 = NULL;
+
+	printf("testing NetGroupGetUsers level %d\n", level);
+
+	do {
+		status = NetGroupGetUsers(hostname,
+					  groupname,
+					  level,
+					  &buffer,
+					  (uint32_t)-1,
+					  &entries_read,
+					  &total_entries,
+					  &resume_handle);
+		if (status == 0 || status == ERROR_MORE_DATA) {
+
+			switch (level) {
+				case 0:
+					info0 = (struct GROUP_USERS_INFO_0 *)buffer;
+					break;
+				case 1:
+					info1 = (struct GROUP_USERS_INFO_1 *)buffer;
+					break;
+				default:
+					break;
+			}
+			for (i=0; i<entries_read; i++) {
+				switch (level) {
+					case 0:
+						current_name = info0->grui0_name;
+						break;
+					case 1:
+						current_name = info1->grui1_name;
+						break;
+					default:
+						break;
+				}
+
+				if (username && strcasecmp(current_name, username) == 0) {
+					found_user = 1;
+				}
+
+				switch (level) {
+					case 0:
+						info0++;
+						break;
+					case 1:
+						info1++;
+						break;
+				}
+			}
+			NetApiBufferFree(buffer);
+		}
+	} while (status == ERROR_MORE_DATA);
+
+	if (status) {
+		return status;
+	}
+
+	if (username && !found_user) {
+		printf("failed to get user\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+static NET_API_STATUS test_netgroupsetusers(const char *hostname,
+					    const char *groupname,
+					    uint32_t level,
+					    size_t num_entries,
+					    const char **names)
+{
+	NET_API_STATUS status;
+	uint8_t *buffer = NULL;
+	int i = 0;
+	size_t buf_size = 0;
+
+	struct GROUP_USERS_INFO_0 *g0 = NULL;
+	struct GROUP_USERS_INFO_1 *g1 = NULL;
+
+	printf("testing NetGroupSetUsers level %d\n", level);
+
+	switch (level) {
+		case 0:
+			buf_size = sizeof(struct GROUP_USERS_INFO_0) * num_entries;
+
+			status = NetApiBufferAllocate(buf_size, (void **)&g0);
+			if (status) {
+				goto out;
+			}
+
+			for (i=0; i<num_entries; i++) {
+				g0[i].grui0_name = names[i];
+			}
+
+			buffer = (uint8_t *)g0;
+			break;
+		case 1:
+			buf_size = sizeof(struct GROUP_USERS_INFO_1) * num_entries;
+
+			status = NetApiBufferAllocate(buf_size, (void **)&g1);
+			if (status) {
+				goto out;
+			}
+
+			for (i=0; i<num_entries; i++) {
+				g1[i].grui1_name = names[i];
+			}
+
+			buffer = (uint8_t *)g1;
+			break;
+		default:
+			break;
+	}
+
+	/* NetGroupSetUsers */
+
+	status = NetGroupSetUsers(hostname,
+				  groupname,
+				  level,
+				  buffer,
+				  num_entries);
+	if (status) {
+		goto out;
+	}
+
+ out:
+	NetApiBufferFree(buffer);
+	return status;
+}
+
 NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 				const char *hostname)
 {
@@ -137,6 +283,7 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 	uint32_t parm_err = 0;
 	uint32_t levels[] = { 0, 1, 2, 3};
 	uint32_t enum_levels[] = { 0, 1, 2, 3};
+	uint32_t getmem_levels[] = { 0, 1};
 	int i;
 
 	printf("NetGroup tests\n");
@@ -201,9 +348,16 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 	printf("testing NetGroupSetInfo level 0\n");
 
 	status = NetGroupSetInfo(hostname, groupname, 0, (uint8_t *)&g0, &parm_err);
-	if (status) {
-		NETAPI_STATUS(ctx, status, "NetGroupSetInfo");
-		goto out;
+	switch (status) {
+		case 0:
+			break;
+		case 50: /* not supported */
+		case 124: /* not implemented */
+			groupname2 = groupname;
+			goto skip_rename;
+		default:
+			NETAPI_STATUS(ctx, status, "NetGroupSetInfo");
+			goto out;
 	}
 
 	/* should not exist anymore */
@@ -214,6 +368,7 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 		goto out;
 	}
 
+ skip_rename:
 	/* query info */
 
 	for (i=0; i<ARRAY_SIZE(levels); i++) {
@@ -233,6 +388,17 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 		goto out;
 	}
 
+	/* should not be member */
+
+	for (i=0; i<ARRAY_SIZE(getmem_levels); i++) {
+
+		status = test_netgroupgetusers(hostname, getmem_levels[i], groupname2, NULL);
+		if (status) {
+			NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+			goto out;
+		}
+	}
+
 	printf("testing NetGroupAddUser\n");
 
 	status = NetGroupAddUser(hostname, groupname2, username);
@@ -241,6 +407,17 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 		goto out;
 	}
 
+	/* should be member */
+
+	for (i=0; i<ARRAY_SIZE(getmem_levels); i++) {
+
+		status = test_netgroupgetusers(hostname, getmem_levels[i], groupname2, username);
+		if (status) {
+			NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+			goto out;
+		}
+	}
+
 	printf("testing NetGroupDelUser\n");
 
 	status = NetGroupDelUser(hostname, groupname2, username);
@@ -249,6 +426,46 @@ NET_API_STATUS netapitest_group(struct libnetapi_ctx *ctx,
 		goto out;
 	}
 
+	/* should not be member */
+
+	status = test_netgroupgetusers(hostname, 0, groupname2, NULL);
+	if (status) {
+		NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+		goto out;
+	}
+
+	/* set it again via exlicit member set */
+
+	status = test_netgroupsetusers(hostname, groupname2, 0, 1, &username);
+	if (status) {
+		NETAPI_STATUS(ctx, status, "NetGroupSetUsers");
+		goto out;
+	}
+
+	/* should be member */
+
+	status = test_netgroupgetusers(hostname, 0, groupname2, username);
+	if (status) {
+		NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+		goto out;
+	}
+#if 0
+	/* wipe out member list */
+
+	status = test_netgroupsetusers(hostname, groupname2, 0, 0, NULL);
+	if (status) {
+		NETAPI_STATUS(ctx, status, "NetGroupSetUsers");
+		goto out;
+	}
+
+	/* should not be member */
+
+	status = test_netgroupgetusers(hostname, 0, groupname2, NULL);
+	if (status) {
+		NETAPI_STATUS(ctx, status, "NetGroupGetUsers");
+		goto out;
+	}
+#endif
 	status = NetUserDel(hostname, username);
 	if (status) {
 		NETAPI_STATUS(ctx, status, "NetUserDel");
diff --git a/source3/lib/netapi/tests/netuser.c b/source3/lib/netapi/tests/netuser.c
index 7bbc5ca..41f794b 100644
--- a/source3/lib/netapi/tests/netuser.c
+++ b/source3/lib/netapi/tests/netuser.c
@@ -449,6 +449,10 @@ NET_API_STATUS netapitest_user(struct libnetapi_ctx *ctx,
 
 	printf("NetUser tests succeeded\n");
  out:
+	/* cleanup */
+	NetUserDel(hostname, username);
+	NetUserDel(hostname, username2);
+
 	if (status != 0) {
 		printf("NetUser testsuite failed with: %s\n",
 			libnetapi_get_error_string(ctx, status));
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 0f82675..386e081 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -1774,66 +1774,6 @@ NTSTATUS _samr_QueryAliasInfo(pipes_struct *p,
 	return NT_STATUS_OK;
 }
 
-#if 0
-/*******************************************************************
- samr_reply_lookup_ids
- ********************************************************************/
-
- uint32 _samr_lookup_ids(pipes_struct *p, SAMR_Q_LOOKUP_IDS *q_u, SAMR_R_LOOKUP_IDS *r_u)
-{
-    uint32 rid[MAX_SAM_ENTRIES];
-    int num_rids = q_u->num_sids1;
-
-    r_u->status = NT_STATUS_OK;
-
-    DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__));
-
-    if (num_rids > MAX_SAM_ENTRIES) {
-        num_rids = MAX_SAM_ENTRIES;
-        DEBUG(5,("_samr_lookup_ids: truncating entries to %d\n", num_rids));
-    }
-
-#if 0
-    int i;
-    SMB_ASSERT_ARRAY(q_u->uni_user_name, num_rids);
-
-    for (i = 0; i < num_rids && status == 0; i++)
-    {
-        struct sam_passwd *sam_pass;
-        fstring user_name;
-
-
-        fstrcpy(user_name, unistrn2(q_u->uni_user_name[i].buffer,
-                                    q_u->uni_user_name[i].uni_str_len));
-
-        /* find the user account */
-        become_root();
-        sam_pass = get_smb21pwd_entry(user_name, 0);
-        unbecome_root();
-
-        if (sam_pass == NULL)
-        {
-            status = 0xC0000000 | NT_STATUS_NO_SUCH_USER;
-            rid[i] = 0;
-        }
-        else
-        {
-            rid[i] = sam_pass->user_rid;
-        }
-    }
-#endif
-
-    num_rids = 1;
-    rid[0] = BUILTIN_ALIAS_RID_USERS;
-
-    init_samr_r_lookup_ids(&r_u, num_rids, rid, NT_STATUS_OK);
-
-    DEBUG(5,("_samr_lookup_ids: %d\n", __LINE__));
-
-    return r_u->status;
-}
-#endif
-
 /*******************************************************************
  _samr_LookupNames
  ********************************************************************/
@@ -5339,6 +5279,9 @@ NTSTATUS _samr_SetGroupInfo(pipes_struct *p,
 		case 1:
 			fstrcpy(map.comment, r->in.info->all.description.string);
 			break;
+		case 2:
+			/* group rename is not supported yet */
+			return NT_STATUS_NOT_SUPPORTED;
 		case 4:
 			fstrcpy(map.comment, r->in.info->description.string);
 			break;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list