[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Mon Jul 5 08:36:23 MDT 2010


The branch, master has been updated
       via  3323e88... s3-winbind: Rename lookup_groupmem to msrpc_lookup_groupmem.
       via  973ef39... s3-winbind: Use rpc_trusted_domains in msrpc.
       via  b4160af... s3-winbind: Use rpc_trusted_domains in samr.
       via  9c372a1... s3-winbind: Added a common rpc_trusted_domains function.
       via  b8a0b95... s3-winbind: Rename common_password_policy to sam_password_policy.
       via  3f2c2c7... s3-winbind: Rename common_lockout_policy to sam_lockout_policy.
       via  49dc713... s3-winbind: Use rpc_sequence_number in msrpc.
       via  eba6ff0... s3-winbind: Use rpc_sequence_number in samr.
       via  c4a5fc7... s3-winbind: Added a common rpc_sequence_number function.
       via  6203801... s3-winbind: Use rpc_lookup_groupmem in samr.
       via  3c06d42... s3-winbind: Added a common rpc_lookup_groupmem function.
       via  1f2fe8d... s3-winbind: Use rpc_lookup_useraliases in msrpc.
       via  aa83137... s3-winbind: Use rpc_lookup_useraliases in samr.
       via  73b2f60... s3-winbind: Added a common rpc_lookup_useraliases function.
       via  ad8c912... s3-winbind: Use rpc_lookup_usergroups in msrpc.
       via  c1a6a24... s3-winbind: Use rpc_lookup_usergroups in samr.
       via  473d1f1... s3-winbind: Added a common rpc_lookup_usergroups function.
       via  a3f8bbf... s3-winbind: Use rpc_query_user in samr.
       via  64f1052... s3-winbind: Use rpc_query_user in msrpc.
       via  7d304d7... s3-winbind: Added a common rpc_query_user function.
       via  c48d850... s3-winbind: Use rpc_rids_to_names in samr.
       via  fd79bc9... s3-winbind: Added a common rpc_rids_to_names function.
       via  aa745be... s3-winbind: Use rpc_sid_to_name in samr.
       via  506dc89... s3-winbind: Added a common rpc_sid_to_name function.
       via  22c9ced... s3-winbind: Use rpc_name_to_sid in samr.
       via  37dbfae... s3-winbind: Added a common rpc_name_to_sid function.
       via  01730e4... s3-winbind: Use rpc_enum_local_groups in samr.
       via  44c6432... s3-winbind: Use rpc_enum_local_groups in msrpc.
       via  89c8ef9... s3-winbind: Added a common rpc_enum_local_groups function.
       via  8159b12... s3-winbind: Use rpc_query_user_list in samr.
       via  e44d7e1... s3-winbind: Use rpc_query_user_list in msrpc.
       via  c83e8cb... s3-winbind: Added a common rpc_query_user_list function.
       via  b3f4e18... s3-winbind: Use rpc_enum_dom_groups in samr.
       via  11610a4... s3-winbind: Use rpc_enum_dom_groups in msrpc.
       via  bec1840... s3-winbind: Added a common rpc_enum_dom_groups function.
       via  692cc06... s3-winbind: Rename winbindd_rpc.c to winbindd_msrpc.c.
       via  e1c4b5b... s3-winbind: Replace the passdb backend with a samr/lsa based backend.
       via  488badb... s3-winbind: Implemented samr backend function common_sequence_number.
       via  645ce68... s3-winbind: Implemented samr backend function common_lookup_useraliases.
       via  d92cb43... s3-winbind: Implemented samr backend function common_lookup_usergroups.
       via  c60a9e8... s3-winbind: Implemented samr backend function common_password_policy.
       via  54e8f8b... s3-winbind: Implemented samr backend function common_lockout_policy.
       via  de7990b... s3-winbind: Implemented samr backend function common_rids_to_names.
       via  79700e6... s3-winbind: Implemented samr backend function common_sid_to_name.
       via  f11648b... s3-winbind: Implemented samr backend function common_name_to_sid.
       via  483d452... s3-winbind: Implemented samr backend function common_enum_local_groups.
       via  4744780... s3-winbind: Implemented samr backend function sam_lookup_groupmem.
       via  41939ce... s3-winbind: Implemented samr backend function sam_trusted_domains.
       via  4814755... s3-winbind: Implemented samr backend function sam_query_user.
       via  7ee0ebe... s3-winbind: Implemented samr backend function sam_enum_dom_groups.
       via  9d0d6ed... s3-winbind: Implemented samr backend function sam_query_user_list.
       via  cc3d9dd... s3-winbind: Added a skeleton for samr based functions.
       via  9fa7239... s3-winbind: Initialize the server_info on winbindd start.
       via  30d2521... s3-rpc_client: Use the right memory context for array elements.
       via  7d013f4... s3-winbind: Free some memory which isn't needed anymore.
      from  b37db75... s3-build: add idl_full to Makefile.

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


- Log -----------------------------------------------------------------
commit 3323e88f74ecdfb94026fc23b870c10bba375d34
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 11:15:18 2010 +0200

    s3-winbind: Rename lookup_groupmem to msrpc_lookup_groupmem.

commit 973ef399e3b7853e68bf8d3d54700fd2c89a9611
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 11:14:12 2010 +0200

    s3-winbind: Use rpc_trusted_domains in msrpc.

commit b4160af73646f48073778b610938c9f67a5f6e39
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 11:13:50 2010 +0200

    s3-winbind: Use rpc_trusted_domains in samr.

commit 9c372a145dacfabd14dd86b6dbc458f20ce73fe9
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 11:13:25 2010 +0200

    s3-winbind: Added a common rpc_trusted_domains function.

commit b8a0b95e74bf4e57d5ee5e15a91c7b27f7edd3c6
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 10:54:53 2010 +0200

    s3-winbind: Rename common_password_policy to sam_password_policy.

commit 3f2c2c7c70c0cfbcc84c28526d9108e9ee8ed7d5
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 10:53:15 2010 +0200

    s3-winbind: Rename common_lockout_policy to sam_lockout_policy.

commit 49dc713957593bc7b2b6a1704f2fcd0f8595a4fd
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 10:48:15 2010 +0200

    s3-winbind: Use rpc_sequence_number in msrpc.

commit eba6ff0c1a506601c5447706678171926ba4cd93
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 10:47:54 2010 +0200

    s3-winbind: Use rpc_sequence_number in samr.

commit c4a5fc72c732e40c53b6206280ed9c22cc8f0fb1
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 10:47:22 2010 +0200

    s3-winbind: Added a common rpc_sequence_number function.

commit 62038010e0cb74a0de8fe68c7566a6db153ea58b
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 10:28:47 2010 +0200

    s3-winbind: Use rpc_lookup_groupmem in samr.

commit 3c06d42bec49f3fd0ab0d03fe3cbc7205f6d2e2d
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 21 10:28:21 2010 +0200

    s3-winbind: Added a common rpc_lookup_groupmem function.

commit 1f2fe8dee9df1228974ab713b77e470185552916
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 19:08:41 2010 +0200

    s3-winbind: Use rpc_lookup_useraliases in msrpc.

commit aa831374b8484846702622562c28138363fda2f7
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 19:08:28 2010 +0200

    s3-winbind: Use rpc_lookup_useraliases in samr.

commit 73b2f60f6d7f11702d24b8e90209ad6406d79a90
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 19:07:43 2010 +0200

    s3-winbind: Added a common rpc_lookup_useraliases function.

commit ad8c9125632798ca762d7de5d13b91bfa9e3ea28
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 18:20:12 2010 +0200

    s3-winbind: Use rpc_lookup_usergroups in msrpc.

commit c1a6a24a76bacec4d678537716675e0c7f4fb5b4
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 18:19:50 2010 +0200

    s3-winbind: Use rpc_lookup_usergroups in samr.

commit 473d1f10868e8fd33641657daa5b4f07e39770ad
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 18:19:16 2010 +0200

    s3-winbind: Added a common rpc_lookup_usergroups function.

commit a3f8bbf3daf916878d0b1374f7fae4b65540be28
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 17:48:17 2010 +0200

    s3-winbind: Use rpc_query_user in samr.

commit 64f1052c7fc0aa5eca4c9fd0b437a5b35f07c9fe
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 17:47:47 2010 +0200

    s3-winbind: Use rpc_query_user in msrpc.

commit 7d304d7e998fef942386d931e8e4ea3ed8b53f4d
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 18 17:47:16 2010 +0200

    s3-winbind: Added a common rpc_query_user function.

commit c48d85026508e35a98bbf4828e688a7bef0249eb
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 19:32:18 2010 +0200

    s3-winbind: Use rpc_rids_to_names in samr.

commit fd79bc9a58ccb06f59cda1f42fe9067f3f8af473
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 19:31:51 2010 +0200

    s3-winbind: Added a common rpc_rids_to_names function.

commit aa745bedd3c9862c793d2d2dbaa70ff85ea40614
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 16:25:33 2010 +0200

    s3-winbind: Use rpc_sid_to_name in samr.

commit 506dc899b26eea7b3115748b6311e8a07fb16909
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 16:25:07 2010 +0200

    s3-winbind: Added a common rpc_sid_to_name function.

commit 22c9ced11952bc61c0f074103b5ca9a312f53c70
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 16:07:02 2010 +0200

    s3-winbind: Use rpc_name_to_sid in samr.

commit 37dbfaebc7a31a6c44d51003770945cb4dab8848
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 16:06:34 2010 +0200

    s3-winbind: Added a common rpc_name_to_sid function.

commit 01730e4b471b7ccf699f9435b87a997980156c37
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 15:53:06 2010 +0200

    s3-winbind: Use rpc_enum_local_groups in samr.

commit 44c6432d64635c94348d2a1b0e7c42ac03ea9373
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 15:52:44 2010 +0200

    s3-winbind: Use rpc_enum_local_groups in msrpc.

commit 89c8ef97c4141e748e5c566a4c25981c31fba507
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 15:51:58 2010 +0200

    s3-winbind: Added a common rpc_enum_local_groups function.

commit 8159b1281be6ebbad0626c71070ddf457f2558e0
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 14:55:19 2010 +0200

    s3-winbind: Use rpc_query_user_list in samr.

commit e44d7e1582d84473c5cf1d75ee5ea0396b88cee4
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 14:54:55 2010 +0200

    s3-winbind: Use rpc_query_user_list in msrpc.

commit c83e8cbe4ae3192b576b47bfae2a4ba90d6e0ce9
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 14:54:02 2010 +0200

    s3-winbind: Added a common rpc_query_user_list function.

commit b3f4e18859e051602a236ee552a641ecd743fc68
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 13:57:12 2010 +0200

    s3-winbind: Use rpc_enum_dom_groups in samr.

commit 11610a4e996fd70a2df3b1124f8e658cc9188827
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jun 17 13:56:54 2010 +0200

    s3-winbind: Use rpc_enum_dom_groups in msrpc.

commit bec184048ee691d9f709365f65104a53f2f33cc0
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 16 21:15:54 2010 +0200

    s3-winbind: Added a common rpc_enum_dom_groups function.

commit 692cc06f0c1e1c2dd0d553bb65a8af78ad0a6523
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 16 17:43:57 2010 +0200

    s3-winbind: Rename winbindd_rpc.c to winbindd_msrpc.c.

commit e1c4b5bbe91b0f2e0abf4e1ddfcd9a7232b12fc8
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 16:44:02 2010 +0200

    s3-winbind: Replace the passdb backend with a samr/lsa based backend.

commit 488badb8acdb6bcf9135a3073b08e4f5526d73b0
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 15:20:13 2010 +0200

    s3-winbind: Implemented samr backend function common_sequence_number.

commit 645ce68e357948c8bddf46e7b3777788af4d0a72
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 15:12:37 2010 +0200

    s3-winbind: Implemented samr backend function common_lookup_useraliases.

commit d92cb43b7723c8103a62602dfe1a02eba2526576
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 14:57:15 2010 +0200

    s3-winbind: Implemented samr backend function common_lookup_usergroups.

commit c60a9e8077d875f7b4c9a11351f06506fafda133
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 14:41:54 2010 +0200

    s3-winbind: Implemented samr backend function common_password_policy.

commit 54e8f8bd578ce6c0df30eecde471190ee700dc32
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 14:39:55 2010 +0200

    s3-winbind: Implemented samr backend function common_lockout_policy.

commit de7990bca160c1f54ce4c1ad848b2761b77c5960
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 14:33:02 2010 +0200

    s3-winbind: Implemented samr backend function common_rids_to_names.

commit 79700e690e44485b5037bd191934a56b6e765655
Author: Andreas Schneider <asn at samba.org>
Date:   Wed Jun 9 11:52:26 2010 +0200

    s3-winbind: Implemented samr backend function common_sid_to_name.

commit f11648bfd7dfdacff5889dc3f12d89b59146b4f4
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jun 8 14:42:59 2010 +0200

    s3-winbind: Implemented samr backend function common_name_to_sid.

commit 483d4528d97670d13d1cdb69a041d587e6e2194f
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jun 8 08:47:13 2010 +0200

    s3-winbind: Implemented samr backend function common_enum_local_groups.

commit 47447809c825c90992abd67ef38a7e38b835a072
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 7 22:15:37 2010 +0200

    s3-winbind: Implemented samr backend function sam_lookup_groupmem.

commit 41939ce32f66c288e51013648adfdcae64a97396
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 7 21:46:02 2010 +0200

    s3-winbind: Implemented samr backend function sam_trusted_domains.

commit 48147555d2a2e879b027c09fb48c2ab7c40f4126
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 7 21:20:15 2010 +0200

    s3-winbind: Implemented samr backend function sam_query_user.

commit 7ee0ebe40604123e38b02661ac9cba294ee23563
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 7 16:39:44 2010 +0200

    s3-winbind: Implemented samr backend function sam_enum_dom_groups.

commit 9d0d6ed66f582464dd874ec793cdeb7cf1b9aece
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 7 16:18:12 2010 +0200

    s3-winbind: Implemented samr backend function sam_query_user_list.

commit cc3d9dd042c6c7abd1815acca0af4ab3fb427c73
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 7 10:18:01 2010 +0200

    s3-winbind: Added a skeleton for samr based functions.
    
    The goal is to replace the passdb backend later.

commit 9fa72399073731aba54dfe70c35677b3c2960589
Author: Andreas Schneider <asn at samba.org>
Date:   Thu May 27 12:06:24 2010 +0200

    s3-winbind: Initialize the server_info on winbindd start.

commit 30d25210a97403c083f7f8babe2eaa4d4cdfc1ad
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jun 11 11:48:37 2010 +0200

    s3-rpc_client: Use the right memory context for array elements.

commit 7d013f4065caad4caf742adc37b0b7622419de1a
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Jun 14 11:49:32 2010 +0200

    s3-winbind: Free some memory which isn't needed anymore.

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

Summary of changes:
 source3/Makefile.in                  |    7 +-
 source3/rpc_client/cli_lsarpc.c      |    6 +-
 source3/winbindd/winbindd.c          |    5 +
 source3/winbindd/winbindd_dual_srv.c |    2 +
 source3/winbindd/winbindd_msrpc.c    | 1169 +++++++++++++++++++++++++
 source3/winbindd/winbindd_passdb.c   |  723 ----------------
 source3/winbindd/winbindd_rpc.c      | 1581 +++++++++++++---------------------
 source3/winbindd/winbindd_rpc.h      |  134 +++
 source3/winbindd/winbindd_samr.c     | 1006 +++++++++++++++++++++
 source3/wscript_build                |    6 +-
 10 files changed, 2906 insertions(+), 1733 deletions(-)
 create mode 100644 source3/winbindd/winbindd_msrpc.c
 delete mode 100644 source3/winbindd/winbindd_passdb.c
 create mode 100644 source3/winbindd/winbindd_rpc.h
 create mode 100644 source3/winbindd/winbindd_samr.c


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index e813197..69f3425 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1176,10 +1176,11 @@ WINBINDD_OBJ1 = \
 		winbindd/winbindd_misc.o  \
 		winbindd/winbindd_cm.o    \
 		winbindd/winbindd_wins.o  \
+		winbindd/winbindd_msrpc.o \
 		winbindd/winbindd_rpc.o   \
 		winbindd/winbindd_reconnect.o \
 		winbindd/winbindd_ads.o   \
-		winbindd/winbindd_passdb.o \
+		winbindd/winbindd_samr.o \
 		winbindd/winbindd_dual.o  \
 		winbindd/winbindd_dual_ndr.o  \
 		winbindd/winbindd_dual_srv.o  \
@@ -1255,13 +1256,14 @@ WINBINDD_OBJ1 = \
 		winbindd/winbindd_pam_chauthtok.o \
 		winbindd/winbindd_pam_chng_pswd_auth_crap.o \
 		winbindd/winbindd_pam_logoff.o \
+		auth/auth_util.o \
 		auth/token_util.o \
+		auth/user_util.o \
 		auth/check_samsec.o \
 		auth/server_info.o \
 		auth/server_info_sam.o \
 		auth/user_info.o \
 		auth/pampass.o \
-		rpc_server/srv_samr_chgpasswd.o \
 		../nsswitch/libwbclient/wb_reqtrans.o
 
 WINBINDD_OBJ = \
@@ -1271,6 +1273,7 @@ WINBINDD_OBJ = \
 		$(PROFILE_OBJ) $(SLCACHE_OBJ) $(SMBLDAP_OBJ) \
 		$(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) \
 		$(DCUTIL_OBJ) $(IDMAP_OBJ) $(NSS_INFO_OBJ) \
+		$(RPC_NCACN_NP_INTERNAL) $(RPC_SAMR_OBJ) $(RPC_LSA_OBJ) \
 		$(AFS_OBJ) $(AFS_SETTOKEN_OBJ) \
 		$(LIBADS_SERVER_OBJ) \
 		$(TDB_VALIDATE_OBJ)
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index 649200a..72514e7 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -225,7 +225,7 @@ static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli,
 			name = lsa_names.names[i].name.string;
 
 			if (name) {
-				(names)[i] = talloc_strdup(mem_ctx, name);
+				(names)[i] = talloc_strdup(names, name);
 				if ((names)[i] == NULL) {
 					DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
 					result = NT_STATUS_UNSUCCESSFUL;
@@ -234,8 +234,8 @@ static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli,
 			} else {
 				(names)[i] = NULL;
 			}
-			domains[i] = talloc_strdup(
-				mem_ctx, dom_name ? dom_name : "");
+			domains[i] = talloc_strdup(domains,
+						   dom_name ? dom_name : "");
 			(types)[i] = lsa_names.names[i].sid_type;
 			if (((domains)[i] == NULL)) {
 				DEBUG(0, ("cli_lsa_lookup_sids_noalloc(): out of memory\n"));
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index cdbf2d6..25d4e1d 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -1289,6 +1289,11 @@ int main(int argc, char **argv, char **envp)
 
 	winbindd_register_handlers();
 
+	if (!init_system_info()) {
+		DEBUG(0,("ERROR: failed to setup system user info.\n"));
+		exit(1);
+	}
+
 	/* setup listen sockets */
 
 	if (!winbindd_setup_listeners()) {
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index b247d5a..77aa299 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -274,6 +274,8 @@ NTSTATUS _wbint_QueryGroupList(pipes_struct *p, struct wbint_QueryGroupList *r)
 
 	r->out.groups->num_principals = num_groups;
 	r->out.groups->principals = result;
+
+	TALLOC_FREE(groups);
 	return NT_STATUS_OK;
 }
 
diff --git a/source3/winbindd/winbindd_msrpc.c b/source3/winbindd/winbindd_msrpc.c
new file mode 100644
index 0000000..09da950
--- /dev/null
+++ b/source3/winbindd/winbindd_msrpc.c
@@ -0,0 +1,1169 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Winbind rpc backend functions
+
+   Copyright (C) Tim Potter 2000-2001,2003
+   Copyright (C) Andrew Tridgell 2001
+   Copyright (C) Volker Lendecke 2005
+   Copyright (C) Guenther Deschner 2008 (pidl conversion)
+
+   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/>.
+*/
+
+#include "includes.h"
+#include "winbindd.h"
+#include "winbindd_rpc.h"
+
+#include "../librpc/gen_ndr/cli_samr.h"
+#include "rpc_client/cli_samr.h"
+#include "../librpc/gen_ndr/cli_lsa.h"
+#include "rpc_client/cli_lsarpc.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_WINBIND
+
+
+/* Query display info for a domain.  This returns enough information plus a
+   bit extra to give an overview of domain users for the User Manager
+   application. */
+static NTSTATUS msrpc_query_user_list(struct winbindd_domain *domain,
+				      TALLOC_CTX *mem_ctx,
+				      uint32_t *pnum_info,
+				      struct wbint_userinfo **pinfo)
+{
+	struct rpc_pipe_client *samr_pipe = NULL;
+	struct policy_handle dom_pol;
+	struct wbint_userinfo *info = NULL;
+	uint32_t num_info = 0;
+	TALLOC_CTX *tmp_ctx;
+	NTSTATUS status;
+
+	DEBUG(3,("rpc_query_user_list\n"));
+
+	if (pnum_info) {
+		*pnum_info = 0;
+	}
+
+	tmp_ctx = talloc_stackframe();
+	if (tmp_ctx == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	if ( !winbindd_can_contact_domain( domain ) ) {
+		DEBUG(10,("query_user_list: No incoming trust for domain %s\n",
+			  domain->name));
+		status = NT_STATUS_OK;
+		goto done;
+	}
+
+	status = cm_connect_sam(domain, tmp_ctx, &samr_pipe, &dom_pol);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	status = rpc_query_user_list(tmp_ctx,
+				     samr_pipe,
+				     &dom_pol,
+				     &domain->sid,
+				     &num_info,
+				     &info);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	if (pnum_info) {
+		*pnum_info = num_info;
+	}
+
+	if (pinfo) {
+		*pinfo = talloc_move(mem_ctx, &info);
+	}
+
+done:
+	TALLOC_FREE(tmp_ctx);
+	return status;
+}
+
+/* list all domain groups */
+static NTSTATUS msrpc_enum_dom_groups(struct winbindd_domain *domain,
+				      TALLOC_CTX *mem_ctx,
+				      uint32_t *pnum_info,
+				      struct acct_info **pinfo)
+{
+	struct rpc_pipe_client *samr_pipe;
+	struct policy_handle dom_pol;
+	struct acct_info *info = NULL;
+	uint32_t num_info = 0;
+	TALLOC_CTX *tmp_ctx;
+	NTSTATUS status;
+
+	DEBUG(3,("msrpc_enum_dom_groups\n"));
+
+	if (pnum_info) {
+		*pnum_info = 0;
+	}
+
+	tmp_ctx = talloc_stackframe();
+	if (tmp_ctx == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	if ( !winbindd_can_contact_domain( domain ) ) {
+		DEBUG(10,("enum_domain_groups: No incoming trust for domain %s\n",
+			  domain->name));
+		status = NT_STATUS_OK;
+		goto done;
+	}
+
+	status = cm_connect_sam(domain, tmp_ctx, &samr_pipe, &dom_pol);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	status = rpc_enum_dom_groups(tmp_ctx,
+				     samr_pipe,
+				     &dom_pol,
+				     &num_info,
+				     &info);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	if (pnum_info) {
+		*pnum_info = num_info;
+	}
+
+	if (pinfo) {
+		*pinfo = talloc_move(mem_ctx, &info);
+	}
+
+done:
+	TALLOC_FREE(tmp_ctx);
+	return status;
+}
+
+/* List all domain groups */
+
+static NTSTATUS msrpc_enum_local_groups(struct winbindd_domain *domain,
+					TALLOC_CTX *mem_ctx,
+					uint32_t *pnum_info,
+					struct acct_info **pinfo)
+{
+	struct rpc_pipe_client *samr_pipe;
+	struct policy_handle dom_pol;
+	struct acct_info *info = NULL;
+	uint32_t num_info = 0;
+	TALLOC_CTX *tmp_ctx;
+	NTSTATUS status;
+
+	DEBUG(3,("msrpc_enum_local_groups\n"));
+
+	if (pnum_info) {
+		*pnum_info = 0;
+	}
+
+	tmp_ctx = talloc_stackframe();
+	if (tmp_ctx == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	if ( !winbindd_can_contact_domain( domain ) ) {
+		DEBUG(10,("enum_local_groups: No incoming trust for domain %s\n",
+			  domain->name));
+		status = NT_STATUS_OK;
+		goto done;
+	}
+
+	status = cm_connect_sam(domain, tmp_ctx, &samr_pipe, &dom_pol);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	status = rpc_enum_local_groups(mem_ctx,
+				       samr_pipe,
+				       &dom_pol,
+				       &num_info,
+				       &info);
+	if (!NT_STATUS_IS_OK(status)) {
+		goto done;
+	}
+
+	if (pnum_info) {
+		*pnum_info = num_info;
+	}
+
+	if (pinfo) {
+		*pinfo = talloc_move(mem_ctx, &info);
+	}
+
+done:
+	TALLOC_FREE(tmp_ctx);
+	return status;
+}
+
+/* convert a single name to a sid in a domain */
+static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
+				  TALLOC_CTX *mem_ctx,
+				  const char *domain_name,
+				  const char *name,
+				  uint32_t flags,
+				  struct dom_sid *sid,
+				  enum lsa_SidType *type)
+{
+	NTSTATUS result;
+	struct dom_sid *sids = NULL;
+	enum lsa_SidType *types = NULL;
+	char *full_name = NULL;
+	NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
+	char *mapped_name = NULL;
+
+	if (name == NULL || *name=='\0') {
+		full_name = talloc_asprintf(mem_ctx, "%s", domain_name);
+	} else if (domain_name == NULL || *domain_name == '\0') {
+		full_name = talloc_asprintf(mem_ctx, "%s", name);
+	} else {
+		full_name = talloc_asprintf(mem_ctx, "%s\\%s", domain_name, name);
+	}
+	if (!full_name) {
+		DEBUG(0, ("talloc_asprintf failed!\n"));
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	DEBUG(3,("rpc: name_to_sid name=%s\n", full_name));
+
+	name_map_status = normalize_name_unmap(mem_ctx, full_name,
+					       &mapped_name);
+
+	/* Reset the full_name pointer if we mapped anytthing */
+
+	if (NT_STATUS_IS_OK(name_map_status) ||
+	    NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED))
+	{
+		full_name = mapped_name;
+	}
+
+	DEBUG(3,("name_to_sid [rpc] %s for domain %s\n",
+		 full_name?full_name:"", domain_name ));
+
+	result = winbindd_lookup_names(mem_ctx, domain, 1,
+				       (const char **)&full_name, NULL,
+				       &sids, &types);
+	if (!NT_STATUS_IS_OK(result))
+		return result;
+
+	/* Return rid and type if lookup successful */
+
+	sid_copy(sid, &sids[0]);
+	*type = types[0];
+
+	return NT_STATUS_OK;
+}
+
+/*
+  convert a domain SID to a user or group name
+*/
+static NTSTATUS msrpc_sid_to_name(struct winbindd_domain *domain,
+				  TALLOC_CTX *mem_ctx,
+				  const struct dom_sid *sid,
+				  char **domain_name,
+				  char **name,
+				  enum lsa_SidType *type)
+{
+	char **domains;
+	char **names;
+	enum lsa_SidType *types = NULL;
+	NTSTATUS result;
+	NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
+	char *mapped_name = NULL;
+
+	DEBUG(3,("sid_to_name [rpc] %s for domain %s\n", sid_string_dbg(sid),
+		 domain->name ));
+
+	result = winbindd_lookup_sids(mem_ctx,
+				      domain,
+				      1,
+				      sid,
+				      &domains,
+				      &names,
+				      &types);
+	if (!NT_STATUS_IS_OK(result)) {
+		DEBUG(2,("msrpc_sid_to_name: failed to lookup sids: %s\n",
+			nt_errstr(result)));
+		return result;
+	}
+
+
+	*type = (enum lsa_SidType)types[0];
+	*domain_name = domains[0];
+	*name = names[0];
+
+	DEBUG(5,("Mapped sid to [%s]\\[%s]\n", domains[0], *name));
+
+	name_map_status = normalize_name_map(mem_ctx, domain, *name,
+					     &mapped_name);
+	if (NT_STATUS_IS_OK(name_map_status) ||
+	    NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED))
+	{
+		*name = mapped_name;
+		DEBUG(5,("returning mapped name -- %s\n", *name));
+	}
+
+	return NT_STATUS_OK;
+}
+
+static NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain,
+				    TALLOC_CTX *mem_ctx,
+				    const struct dom_sid *sid,
+				    uint32 *rids,
+				    size_t num_rids,
+				    char **domain_name,
+				    char ***names,
+				    enum lsa_SidType **types)
+{
+	char **domains;
+	NTSTATUS result;
+	struct dom_sid *sids;
+	size_t i;
+	char **ret_names;
+
+	DEBUG(3, ("rids_to_names [rpc] for domain %s\n", domain->name ));
+
+	if (num_rids) {
+		sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, num_rids);
+		if (sids == NULL) {
+			return NT_STATUS_NO_MEMORY;
+		}
+	} else {
+		sids = NULL;
+	}
+
+	for (i=0; i<num_rids; i++) {
+		if (!sid_compose(&sids[i], sid, rids[i])) {
+			return NT_STATUS_INTERNAL_ERROR;
+		}
+	}
+
+	result = winbindd_lookup_sids(mem_ctx,
+				      domain,
+				      num_rids,
+				      sids,
+				      &domains,
+				      names,
+				      types);
+
+	if (!NT_STATUS_IS_OK(result) &&
+	    !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
+		return result;
+	}
+
+	ret_names = *names;
+	for (i=0; i<num_rids; i++) {
+		NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
+		char *mapped_name = NULL;
+
+		if ((*types)[i] != SID_NAME_UNKNOWN) {
+			name_map_status = normalize_name_map(mem_ctx,
+							     domain,
+							     ret_names[i],
+							     &mapped_name);
+			if (NT_STATUS_IS_OK(name_map_status) ||
+			    NT_STATUS_EQUAL(name_map_status, NT_STATUS_FILE_RENAMED))
+			{
+				ret_names[i] = mapped_name;
+			}
+
+			*domain_name = domains[i];
+		}
+	}
+
+	return result;
+}
+
+/* Lookup user information from a rid or username. */
+static NTSTATUS msrpc_query_user(struct winbindd_domain *domain,
+			   TALLOC_CTX *mem_ctx, 
+			   const struct dom_sid *user_sid,
+			   struct wbint_userinfo *user_info)
+{
+	struct rpc_pipe_client *samr_pipe;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list