[PATCH] Re: Take Ownership

Manoj Naik manoj at almaden.ibm.com
Fri Jun 29 22:29:40 GMT 2001


I've built a patch that implements the 0x2D LSA RPC
(LsaGetConnectedCredentials) used by 'Take Ownership'. Structures
modified slightly from TNG code.

Manoj.

jtrostel at connex.com wrote:
> When clicking the 'Take Ownership' button in the Security/Ownership dialog,
> I don't see what code is actually executed within samba.  I have a (highly)
> modified Linux/XFS system that now supports delete, change ownership, and
> change permission ACLs, but getting the 'Take Ownership' button to actually do
> something is a stopping point for me.
> 
> It looks like the code that follows in smbd/posix_acls.c might be run, but I
> never see the dgbtext output in front of it in my log files.
> 
>          /*
>          * Do we need to chown ?
>          */
>         dbgtext(" CONNEX: about to do chown check\n");
>         if((user != (uid_t)-1 || grp != (uid_t)-1) && (orig_uid != user ||
> orig_gid != grp)) {
> 
> // CONNEX was set to debug level 3
>                 DEBUG(1,("set_nt_acl: chown %s. uid = %u, gid = %u.\n",
>                                 fsp->fsp_name, (unsigned int)user, (unsigned
> int)grp ));
> 
>                 if(vfs_chown( fsp->conn, fsp->fsp_name, user, grp) == -1) {
>                         DEBUG(1,("set_nt_acl: chown %s, %u, %u failed. Error =
> %s.\n",
>                                 fsp->fsp_name, (unsigned int)user, (unsigned
> int)grp, strerror(errno) ));
>                         return False;
>                 }
> 
> --
> John M. Trostel
> Linux OS Engineer
> Connex
> jtrostel at connex.com
-------------- next part --------------
Index: source/include/rpc_lsa.h
===================================================================
RCS file: /cvsroot/samba/source/include/rpc_lsa.h,v
retrieving revision 1.25
diff -u -r1.25 rpc_lsa.h
--- source/include/rpc_lsa.h	11 Mar 2001 00:32:02 -0000	1.25
+++ source/include/rpc_lsa.h	29 Jun 2001 22:13:47 -0000
@@ -48,6 +48,7 @@
 #define LSA_OPENPOLICY         0x06
 #define LSA_OPENPOLICY2        0x2c
 #define LSA_OPENSECRET         0x1C
+#define LSA_UNK_2D             0x2d /* LsaGetConnectedCredentials ? */
 
 /* XXXX these are here to get a compile! */
 #define LSA_LOOKUPRIDS      0xFD
@@ -379,5 +380,32 @@
 	uint32 dummy4;
 	uint32 status;
 } LSA_R_OPEN_SECRET;
+
+/* LSA_Q_UNK_2D - gets username\domain of connected user
+                  called when "Take Ownership" is clicked -SK */
+typedef struct lsa_q_unk_2d
+{
+  uint32 ptr_srvname;
+  UNISTR2 uni2_srvname;
+  uint32 unk1; /* 3 unknown uint32's are seen right after uni2_srvname */
+  uint32 unk2; /* unk2 appears to be a ptr, unk1 = unk3 = 0 usually */
+  uint32 unk3; 
+} LSA_Q_UNK_2D;
+
+/* LSA_R_UNK_2D */
+typedef struct lsa_r_unk_2d
+{
+  uint32 ptr_user_name;
+  UNIHDR hdr_user_name;
+  UNISTR2 uni2_user_name;
+  
+  uint32 unk1;
+  
+  uint32 ptr_dom_name;
+  UNIHDR hdr_dom_name;
+  UNISTR2 uni2_dom_name;
+
+  uint32 status;
+} LSA_R_UNK_2D;
 
 #endif /* _RPC_LSA_H */
Index: source/rpc_parse/parse_lsa.c
===================================================================
RCS file: /cvsroot/samba/source/rpc_parse/parse_lsa.c,v
retrieving revision 1.55
diff -u -r1.55 parse_lsa.c
--- source/rpc_parse/parse_lsa.c	22 Jun 2001 02:37:52 -0000	1.55
+++ source/rpc_parse/parse_lsa.c	29 Jun 2001 22:13:47 -0000
@@ -1281,3 +1281,73 @@
 
 	return True;
 }
+
+/*******************************************************************
+ Reads or writes an LSA_Q_UNK_2D structure.
+********************************************************************/
+
+BOOL lsa_io_q_unk_2d(char *desc, LSA_Q_UNK_2D *q_c, prs_struct *ps, int depth)
+{
+	prs_debug(ps, depth, desc, "lsa_io_q_unk_2d");
+	depth++;
+
+	if(!prs_align(ps))
+		return False;
+   
+	if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname))
+		return False;
+
+	if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */
+		return False;
+
+	if(!prs_uint32("unk1", ps, depth, &q_c->unk1))
+		return False;
+	if(!prs_uint32("unk2", ps, depth, &q_c->unk2))
+		return False;
+	if(!prs_uint32("unk3", ps, depth, &q_c->unk3))
+		return False;
+
+	/* Don't bother to read or write at present... */
+	return True;
+}
+
+/*******************************************************************
+ Reads or writes an LSA_R_UNK_2D structure.
+********************************************************************/
+
+BOOL lsa_io_r_unk_2d(char *desc, LSA_R_UNK_2D *r_c, prs_struct *ps, int depth)
+{
+	prs_debug(ps, depth, desc, "lsa_io_r_unk_2d");
+	depth++;
+
+	if(!prs_align(ps))
+		return False;
+   
+	if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name))
+		return False;
+	if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth))
+		return False;
+	if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth))
+		return False;
+
+	if (!prs_align(ps))
+	  return False;
+	
+	if(!prs_uint32("unk1", ps, depth, &r_c->unk1))
+		return False;
+
+	if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name))
+		return False;
+	if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth))
+		return False;
+	if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth))
+		return False;
+
+	if (!prs_align(ps))
+	  return False;
+	
+	if(!prs_uint32("status", ps, depth, &r_c->status))
+		return False;
+
+	return True;
+}
Index: source/rpc_server/srv_lsa.c
===================================================================
RCS file: /cvsroot/samba/source/rpc_server/srv_lsa.c,v
retrieving revision 1.72
diff -u -r1.72 srv_lsa.c
--- source/rpc_server/srv_lsa.c	11 Mar 2001 00:32:06 -0000	1.72
+++ source/rpc_server/srv_lsa.c	29 Jun 2001 22:13:47 -0000
@@ -269,6 +269,37 @@
 }
 
 /***************************************************************************
+ api_lsa_unk_2d
+ ***************************************************************************/
+
+static BOOL api_lsa_unk_2d(pipes_struct *p)
+{
+	LSA_Q_UNK_2D q_u;
+	LSA_R_UNK_2D r_u;
+	
+	prs_struct *data = &p->in_data.data;
+	prs_struct *rdata = &p->out_data.rdata;
+
+	ZERO_STRUCT(q_u);
+	ZERO_STRUCT(r_u);
+
+	if(!lsa_io_q_unk_2d("", &q_u, data, 0)) {
+		DEBUG(0,("api_lsa_unk_2d: failed to unmarshall LSA_Q_UNK_2D.\n"));
+		return False;
+	}
+
+	r_u.status = _lsa_unk_2d(p, &q_u, &r_u);
+
+	/* store the response in the SMB stream */
+	if(!lsa_io_r_unk_2d("", &r_u, rdata, 0)) {
+		DEBUG(0,("api_lsa_unk_2d: Failed to marshall LSA_R_UNK_2D.\n"));
+		return False;
+	}
+
+	return True;
+}
+
+/***************************************************************************
  \PIPE\ntlsa commands
  ***************************************************************************/
 
@@ -282,6 +313,7 @@
 	{ "LSA_OPENSECRET"      , LSA_OPENSECRET      , api_lsa_open_secret    },
 	{ "LSA_LOOKUPSIDS"      , LSA_LOOKUPSIDS      , api_lsa_lookup_sids    },
 	{ "LSA_LOOKUPNAMES"     , LSA_LOOKUPNAMES     , api_lsa_lookup_names   },
+	{ "LSA_UNK_2D"		, LSA_UNK_2D	      , api_lsa_unk_2d	       },
 	{ NULL                  , 0                   , NULL                   }
 };
 
Index: source/rpc_server/srv_lsa_nt.c
===================================================================
RCS file: /cvsroot/samba/source/rpc_server/srv_lsa_nt.c,v
retrieving revision 1.21
diff -u -r1.21 srv_lsa_nt.c
--- source/rpc_server/srv_lsa_nt.c	5 Jun 2001 01:26:06 -0000	1.21
+++ source/rpc_server/srv_lsa_nt.c	29 Jun 2001 22:13:47 -0000
@@ -519,3 +519,33 @@
 {
 	return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 }
+
+uint32 _lsa_unk_2d(pipes_struct *p, LSA_Q_UNK_2D *q_u, LSA_R_UNK_2D *r_u)
+{
+  fstring username, domname;
+  int ulen, dlen;
+  user_struct *vuser = get_valid_user_struct(p->vuid);
+  
+  if (vuser == NULL)
+    return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
+  
+  fstrcpy(username, vuser->user.smb_name);
+  fstrcpy(domname, vuser->user.domain);
+  
+  ulen = strlen(username);
+  dlen = strlen(domname);
+  
+  init_uni_hdr(&r_u->hdr_user_name, ulen);
+  r_u->ptr_user_name = 1;
+  init_unistr2(&r_u->uni2_user_name, username, ulen);
+
+  r_u->unk1 = 1;
+  
+  init_uni_hdr(&r_u->hdr_dom_name, dlen);
+  r_u->ptr_dom_name = 1;
+  init_unistr2(&r_u->uni2_dom_name, domname, dlen);
+
+  r_u->status = NT_STATUS_NO_PROBLEMO;
+  
+  return r_u->status;
+}



More information about the samba-technical mailing list