summaryrefslogtreecommitdiff
path: root/source3/rpc_parse/parse_creds.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-12-12 01:25:49 +0000
committerLuke Leighton <lkcl@samba.org>1999-12-12 01:25:49 +0000
commit0ce128e3550794d4dbbd1def00e87c020f72c992 (patch)
tree9ff25319ff380a5bb219788d8a116ff5110a3343 /source3/rpc_parse/parse_creds.c
parent12ca139d5cb79f7e61a84d7dfe8a4c64ed56d82b (diff)
downloadsamba-0ce128e3550794d4dbbd1def00e87c020f72c992.tar.gz
samba-0ce128e3550794d4dbbd1def00e87c020f72c992.tar.bz2
samba-0ce128e3550794d4dbbd1def00e87c020f72c992.zip
delineation between smb and msrpc more marked. smbd now constructs
pdus, and then feeds them over either a "local" function call or a "remote" function call to an msrpc service. the "remote" msrpc daemon, on the other side of a unix socket, then calls the same "local" function that smbd would, if the msrpc service were being run from inside smbd. this allows a transition from local msrpc services (inside the same smbd process) to remote (over a unix socket). removed reference to pipes_struct in msrpc services. all msrpc processing functions take rpcsrv_struct which is a structure containing state info for the msrpc functions to decode and create pdus. created become_vuser() which does everything not related to connection_struct that become_user() does. removed, as best i could, connection_struct dependencies from the nt spoolss printing code. todo: remove dcinfo from rpcsrv_struct because this stores NETLOGON-specific info on a per-connection basis, and if the connection dies then so does the info, and that's a fairly serious problem. had to put pretty much everything that is in user_struct into parse_creds.c to feed unix user info over to the msrpc daemons. why? because it's expensive to do unix password/group database lookups, and it's definitely expensive to do nt user profile lookups, not to mention pretty difficult and if you did either of these it would introduce a complication / unnecessary interdependency. so, send uid/gid/num_groups/gid_t* + SID+num_rids+domain_group_rids* + unix username + nt username + nt domain + user session key etc. this is the MINIMUM info identified so far that's actually implemented. missing bits include the called and calling netbios names etc. (basically, anything that can be loaded into standard_sub() and standard_sub_basic()...) (This used to be commit aa3c659a8dba0437c17c60055a6ed30fdfecdb6d)
Diffstat (limited to 'source3/rpc_parse/parse_creds.c')
-rw-r--r--source3/rpc_parse/parse_creds.c87
1 files changed, 78 insertions, 9 deletions
diff --git a/source3/rpc_parse/parse_creds.c b/source3/rpc_parse/parse_creds.c
index 127557d1b8..c661d5a3c6 100644
--- a/source3/rpc_parse/parse_creds.c
+++ b/source3/rpc_parse/parse_creds.c
@@ -30,13 +30,19 @@ extern int DEBUGLEVEL;
/*******************************************************************
makes a CREDS_UNIX structure.
********************************************************************/
-BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name)
+BOOL make_creds_unix(CREDS_UNIX *r_u, const char* user_name,
+ const char* requested_name,
+ const char* real_name,
+ BOOL guest)
{
if (r_u == NULL) return False;
DEBUG(5,("make_creds_unix\n"));
- fstrcpy(r_u->user_name, user_name);
+ fstrcpy(r_u->user_name , user_name);
+ fstrcpy(r_u->requested_name, requested_name);
+ fstrcpy(r_u->real_name , real_name);
+ r_u->guest = guest;
return True;
}
@@ -54,7 +60,11 @@ BOOL creds_io_unix(char *desc, CREDS_UNIX *r_u, prs_struct *ps, int depth)
prs_align(ps);
prs_string("user_name", ps, depth, r_u->user_name, strlen(r_u->user_name), sizeof(r_u->user_name));
prs_align(ps);
-
+ prs_string("requested_name", ps, depth, r_u->requested_name, strlen(r_u->requested_name), sizeof(r_u->requested_name));
+ prs_align(ps);
+ prs_string("real_name", ps, depth, r_u->real_name, strlen(r_u->real_name), sizeof(r_u->real_name));
+ prs_align(ps);
+ prs_uint32("guest", ps, depth, &(r_u->guest));
return True;
}
@@ -70,8 +80,9 @@ void creds_free_unix(CREDS_UNIX *r_u)
makes a CREDS_UNIX_SEC structure.
********************************************************************/
BOOL make_creds_unix_sec(CREDS_UNIX_SEC *r_u,
- uint32 uid, uint32 gid, uint32 num_grps, uint32 *grps)
+ uint32 uid, uint32 gid, uint32 num_grps, gid_t *grps)
{
+ int i;
if (r_u == NULL) return False;
DEBUG(5,("make_creds_unix_sec\n"));
@@ -79,7 +90,16 @@ BOOL make_creds_unix_sec(CREDS_UNIX_SEC *r_u,
r_u->uid = uid;
r_u->gid = gid;
r_u->num_grps = num_grps;
- r_u->grps = grps;
+ r_u->grps = (uint32*)Realloc(NULL, sizeof(r_u->grps[0]) *
+ r_u->num_grps);
+ if (r_u->grps == NULL && num_grps != 0)
+ {
+ return False;
+ }
+ for (i = 0; i < num_grps; i++)
+ {
+ r_u->grps[i] = (gid_t)grps[i];
+ }
return True;
}
@@ -114,7 +134,6 @@ BOOL creds_io_unix_sec(char *desc, CREDS_UNIX_SEC *r_u, prs_struct *ps, int dept
}
for (i = 0; i < r_u->num_grps; i++)
{
- prs_grow(ps);
prs_uint32("", ps, depth, &(r_u->grps[i]));
}
return True;
@@ -134,10 +153,39 @@ void creds_free_unix_sec(CREDS_UNIX_SEC *r_u)
}
/*******************************************************************
+makes a CREDS_NT_SEC structure.
+********************************************************************/
+BOOL make_creds_nt_sec(CREDS_NT_SEC *r_u,
+ DOM_SID *sid, uint32 num_grps, uint32 *grps)
+{
+ int i;
+ if (r_u == NULL) return False;
+
+ DEBUG(5,("make_creds_unix_sec\n"));
+
+ sid_copy(&r_u->sid, sid);
+ r_u->num_grps = num_grps;
+ r_u->grp_rids = (uint32*)Realloc(NULL, sizeof(r_u->grp_rids[0]) *
+ r_u->num_grps);
+
+ if (r_u->grp_rids == NULL && num_grps != 0)
+ {
+ return False;
+ }
+ for (i = 0; i < num_grps; i++)
+ {
+ r_u->grp_rids[i] = grps[i];
+ }
+
+ return True;
+}
+
+/*******************************************************************
reads or writes a structure.
********************************************************************/
BOOL creds_io_nt_sec(char *desc, CREDS_NT_SEC *r_u, prs_struct *ps, int depth)
{
+ int i;
if (r_u == NULL) return False;
prs_debug(ps, depth, desc, "creds_io_nt");
@@ -148,8 +196,22 @@ BOOL creds_io_nt_sec(char *desc, CREDS_NT_SEC *r_u, prs_struct *ps, int depth)
smb_io_dom_sid ("sid", &r_u->sid, ps, depth);
prs_align(ps);
- sec_io_desc_buf("sd ", &r_u->sd , ps, depth);
- prs_align(ps);
+ prs_uint32("num_grps", ps, depth, &(r_u->num_grps));
+ if (r_u->num_grps != 0)
+ {
+ r_u->grp_rids = (uint32*)Realloc(r_u->grp_rids,
+ sizeof(r_u->grp_rids[0]) *
+ r_u->num_grps);
+ if (r_u->grp_rids == NULL)
+ {
+ creds_free_nt_sec(r_u);
+ return False;
+ }
+ }
+ for (i = 0; i < r_u->num_grps; i++)
+ {
+ prs_uint32("", ps, depth, &(r_u->grp_rids[i]));
+ }
return True;
}
@@ -159,6 +221,11 @@ frees a structure.
********************************************************************/
void creds_free_nt_sec(CREDS_NT_SEC *r_u)
{
+ if (r_u->grp_rids != NULL)
+ {
+ free(r_u->grp_rids);
+ r_u->grp_rids = NULL;
+ }
}
/*******************************************************************
@@ -265,6 +332,8 @@ BOOL creds_io_hybrid(char *desc, CREDS_HYBRID *r_u, prs_struct *ps, int depth)
prs_uint32("reuse", ps, depth, &(r_u->reuse));
prs_uint32("ptr_ntc", ps, depth, &(r_u->ptr_ntc));
prs_uint32("ptr_uxc", ps, depth, &(r_u->ptr_uxc));
+ prs_uint32("ptr_nts", ps, depth, &(r_u->ptr_nts));
+ prs_uint32("ptr_uxs", ps, depth, &(r_u->ptr_uxs));
if (r_u->ptr_ntc != 0)
{
if (!creds_io_nt ("ntc", &r_u->ntc, ps, depth)) return False;
@@ -321,7 +390,7 @@ void copy_unix_sec_creds(CREDS_UNIX_SEC *to, const CREDS_UNIX_SEC *from)
if (from->num_grps != 0)
{
- size_t size = to->num_grps * sizeof(to->grps[0]);
+ size_t size = from->num_grps * sizeof(from->grps[0]);
to->grps = (uint32*)malloc(size);
if (to->grps == NULL)
{