Author: jra
Date: 2006-01-14 17:47:10 +0000 (Sat, 14 Jan 2006)
New Revision: 12937

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

Log:
Patch janitor for ab.... From 3.0
-------------------------------------------------------------------
After discussion with Volker fix bug #3397 using a variant of the patch
by Alex Deiter ([EMAIL PROTECTED]).
Introduces level 9 of getuserinfo and allows to successfully install MS
SMS2003
on a member of a Samba domain. Also added support for this level in
rpcclient.

The code for infolevel 9 is modelled upon Samba-TNG by Alex Deiter.

Jerry, we need this in 3.0.21b.
-------------------------------------------------------------------
Jeremy.

Modified:
   trunk/source/include/rpc_samr.h
   trunk/source/rpc_parse/parse_samr.c
   trunk/source/rpc_server/srv_samr_nt.c
   trunk/source/rpcclient/cmd_samr.c


Changeset:
Modified: trunk/source/include/rpc_samr.h
===================================================================
--- trunk/source/include/rpc_samr.h     2006-01-14 15:25:33 UTC (rev 12936)
+++ trunk/source/include/rpc_samr.h     2006-01-14 17:47:10 UTC (rev 12937)
@@ -408,6 +408,7 @@
 
 } SAM_USER_INFO_16;
 
+
 /* SAM_USER_INFO_7 */
 typedef struct sam_user_info_7
 {
@@ -417,6 +418,13 @@
 } SAM_USER_INFO_7;
 
 
+/* SAM_USER_INFO_9 */
+typedef struct sam_user_info_9
+{
+       uint32 rid_group;     /* Primary Group RID */
+} SAM_USER_INFO_9;
+
+
 /* SAMR_Q_CLOSE_HND - probably a policy handle close */
 typedef struct q_samr_close_hnd_info
 {
@@ -1255,6 +1263,7 @@
        union
        {
                SAM_USER_INFO_7  *id7;
+               SAM_USER_INFO_9  *id9;
                SAM_USER_INFO_16 *id16;
                SAM_USER_INFO_17 *id17;
                SAM_USER_INFO_18 *id18;

Modified: trunk/source/rpc_parse/parse_samr.c
===================================================================
--- trunk/source/rpc_parse/parse_samr.c 2006-01-14 15:25:33 UTC (rev 12936)
+++ trunk/source/rpc_parse/parse_samr.c 2006-01-14 17:47:10 UTC (rev 12937)
@@ -5183,6 +5183,39 @@
 }
 
 /*******************************************************************
+inits a SAM_USER_INFO_9 structure.
+********************************************************************/
+
+void init_sam_user_info9(SAM_USER_INFO_9 * usr, uint32 rid_group)
+{
+       DEBUG(5, ("init_sam_user_info9\n"));
+
+       usr->rid_group = rid_group;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+
+static BOOL sam_io_user_info9(const char *desc, SAM_USER_INFO_9 * usr,
+                       prs_struct *ps, int depth)
+{
+       if (usr == NULL)
+               return False;
+
+       prs_debug(ps, depth, desc, "samr_io_r_user_info9");
+       depth++;
+
+       if(!prs_align(ps))
+               return False;
+
+       if(!prs_uint32("rid_group", ps, depth, &usr->rid_group))
+               return False;
+
+       return True;
+}
+
+/*******************************************************************
 inits a SAM_USER_INFO_16 structure.
 ********************************************************************/
 
@@ -6354,6 +6387,15 @@
                }
                ret = sam_io_user_info7("", ctr->info.id7, ps, depth);
                break;
+       case 9:
+               if (UNMARSHALLING(ps))
+                       ctr->info.id9 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_9,1);
+               if (ctr->info.id9 == NULL) {
+                       DEBUG(2,("samr_io_userinfo_ctr: info pointer not 
initialised\n"));
+                       return False;
+               }
+               ret = sam_io_user_info9("", ctr->info.id9, ps, depth);
+               break;
        case 16:
                if (UNMARSHALLING(ps))
                        ctr->info.id16 = PRS_ALLOC_MEM(ps,SAM_USER_INFO_16,1);

Modified: trunk/source/rpc_server/srv_samr_nt.c
===================================================================
--- trunk/source/rpc_server/srv_samr_nt.c       2006-01-14 15:25:33 UTC (rev 
12936)
+++ trunk/source/rpc_server/srv_samr_nt.c       2006-01-14 17:47:10 UTC (rev 
12937)
@@ -1672,7 +1672,42 @@
 
        return NT_STATUS_OK;
 }
+
 /*************************************************************************
+ get_user_info_9. Only gives out primary group SID.
+ *************************************************************************/
+static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, 
DOM_SID *user_sid)
+{
+       SAM_ACCOUNT *smbpass=NULL;
+       BOOL ret;
+       NTSTATUS nt_status;
+
+       nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass);
+
+       if (!NT_STATUS_IS_OK(nt_status)) {
+               return nt_status;
+       }
+
+       become_root();
+       ret = pdb_getsampwsid(smbpass, user_sid);
+       unbecome_root();
+
+       if (ret==False) {
+               DEBUG(4,("User %s not found\n", sid_string_static(user_sid)));
+               return NT_STATUS_NO_SUCH_USER;
+       }
+
+       DEBUG(3,("User:[%s]\n", pdb_get_username(smbpass) ));
+
+       ZERO_STRUCTP(id9);
+       init_sam_user_info9(id9, pdb_get_group_rid(smbpass) );
+
+       pdb_free_sam(&smbpass);
+
+       return NT_STATUS_OK;
+}
+
+/*************************************************************************
  get_user_info_16. Safe. Only gives out acb bits.
  *************************************************************************/
 
@@ -1864,6 +1899,8 @@
        /* ok!  user info levels (lots: see MSDEV help), off we go... */
        ctr->switch_value = q_u->switch_value;
 
+       DEBUG(5,("_samr_query_userinfo: user info level: %d\n", 
q_u->switch_value));
+
        switch (q_u->switch_value) {
        case 7:
                ctr->info.id7 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_7);
@@ -1873,6 +1910,14 @@
                if (!NT_STATUS_IS_OK(r_u->status = get_user_info_7(p->mem_ctx, 
ctr->info.id7, &info->sid)))
                        return r_u->status;
                break;
+       case 9:
+               ctr->info.id9 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_9);
+               if (ctr->info.id9 == NULL)
+                       return NT_STATUS_NO_MEMORY;
+
+               if (!NT_STATUS_IS_OK(r_u->status = get_user_info_9(p->mem_ctx, 
ctr->info.id9, &info->sid)))
+                       return r_u->status;
+               break;
        case 16:
                ctr->info.id16 = TALLOC_ZERO_P(p->mem_ctx, SAM_USER_INFO_16);
                if (ctr->info.id16 == NULL)
@@ -2699,8 +2744,12 @@
 
        ZERO_STRUCT(sid);
 
-       if (!secrets_fetch_domain_sid(domain_name, &sid)) {
-               r_u->status = NT_STATUS_NO_SUCH_DOMAIN;
+       if (strequal(domain_name, builtin_domain_name())) {
+               sid_copy(&sid, &global_sid_Builtin);
+       } else {
+               if (!secrets_fetch_domain_sid(domain_name, &sid)) {
+                       r_u->status = NT_STATUS_NO_SUCH_DOMAIN;
+               }
        }
 
        DEBUG(2,("Returning domain sid for domain %s -> %s\n", domain_name, 
sid_string_static(&sid)));

Modified: trunk/source/rpcclient/cmd_samr.c
===================================================================
--- trunk/source/rpcclient/cmd_samr.c   2006-01-14 15:25:33 UTC (rev 12936)
+++ trunk/source/rpcclient/cmd_samr.c   2006-01-14 17:47:10 UTC (rev 12937)
@@ -39,6 +39,14 @@
 }
 
 /****************************************************************************
+ display sam_user_info_9 structure
+ ****************************************************************************/
+static void display_sam_user_info_9(SAM_USER_INFO_9 *usr)
+{
+       printf("\tPrimary group RID   :\tox%x\n", usr->rid_group);
+}
+
+/****************************************************************************
  display sam_user_info_21 structure
  ****************************************************************************/
 static void display_sam_user_info_21(SAM_USER_INFO_21 *usr)
@@ -398,6 +406,9 @@
        case 7:
                display_sam_user_info_7(user_ctr->info.id7);
                break;
+       case 9:
+               display_sam_user_info_9(user_ctr->info.id9);
+               break;
        default:
                printf("Unsupported infolevel: %d\n", info_level);
                break;

Reply via email to