summaryrefslogtreecommitdiff
path: root/source3/lib
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/lib
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/lib')
-rw-r--r--source3/lib/membuffer.c14
-rw-r--r--source3/lib/msrpc-client.c11
-rw-r--r--source3/lib/passcheck.c18
-rw-r--r--source3/lib/util.c7
-rw-r--r--source3/lib/vuser.c88
5 files changed, 85 insertions, 53 deletions
diff --git a/source3/lib/membuffer.c b/source3/lib/membuffer.c
index 170433074f..e228503643 100644
--- a/source3/lib/membuffer.c
+++ b/source3/lib/membuffer.c
@@ -70,7 +70,7 @@ void mem_init(struct mem_buf *buf, int margin)
buf->next = NULL;
buf->offset.start = 0;
- buf->offset.end = 0;
+ buf->offset.end = 0x0;
}
/*******************************************************************
@@ -119,6 +119,7 @@ BOOL mem_alloc_data(struct mem_buf *buf, int size)
}
bzero(buf->data, buf->data_size);
+ buf->offset.end = buf->offset.start + size;
return True;
}
@@ -229,6 +230,7 @@ void mem_free_data(struct mem_buf *buf)
if (buf->data != NULL && buf->dynamic)
{
free(buf->data); /* delete data in this structure */
+ buf->data = NULL;
}
mem_init(buf, buf->margin);
}
@@ -276,6 +278,10 @@ BOOL mem_realloc_data(struct mem_buf *buf, size_t new_size)
return False;
}
+ buf->offset.end = buf->offset.start + new_size;
+
+ DEBUG(150,("mem_realloc_data: size: %d start: %d end: %d\n",
+ new_size, buf->offset.start, buf->offset.end));
return True;
}
@@ -286,13 +292,13 @@ BOOL mem_grow_data(struct mem_buf **buf, BOOL io, int new_size, BOOL force_grow)
{
if (new_size + (*buf)->margin >= (*buf)->data_size)
{
- if (io && !force_grow)
+ if (!io || force_grow)
{
- DEBUG(3,("mem_grow_data: cannot resize when reading from a data stream\n"));
+ /* writing or forge realloc */
+ return mem_realloc_data((*buf), new_size);
}
else
{
- return mem_realloc_data((*buf), new_size);
}
}
return True;
diff --git a/source3/lib/msrpc-client.c b/source3/lib/msrpc-client.c
index 6e80063862..e13850a9e2 100644
--- a/source3/lib/msrpc-client.c
+++ b/source3/lib/msrpc-client.c
@@ -41,6 +41,9 @@ BOOL msrpc_send_prs(struct msrpc_state *msrpc, prs_struct *ps)
{
size_t len = mem_buf_len(ps->data);
+ DEBUG(10,("msrpc_send_prs: len %d\n", len));
+ dbgflush();
+
_smb_setlen(msrpc->outbuf, len);
mem_buf_copy(&msrpc->outbuf[4], ps->data, 0, len);
@@ -176,14 +179,6 @@ static BOOL msrpc_authenticate(struct msrpc_state *msrpc,
command = usr != NULL ? AGENT_CMD_CON : AGENT_CMD_CON_ANON;
- if (usr != NULL)
- {
- usr->ptr_ntc = 1;
- usr->ptr_uxc = 1;
- usr->ptr_nts = 0;
- usr->ptr_uxs = 0;
- }
-
if (!create_user_creds(&ps, msrpc->pipe_name, 0x0, command, usr))
{
DEBUG(0,("could not parse credentials\n"));
diff --git a/source3/lib/passcheck.c b/source3/lib/passcheck.c
index 195a404ff3..bec6455059 100644
--- a/source3/lib/passcheck.c
+++ b/source3/lib/passcheck.c
@@ -35,7 +35,7 @@ core of smb password checking routine.
****************************************************************************/
static BOOL smb_pwd_check_ntlmv1(char *password, unsigned char *part_passwd,
unsigned char *c8,
- uchar sess_key[16])
+ uchar user_sess_key[16])
{
/* Finish the encryption of part_passwd. */
unsigned char p24[24];
@@ -47,9 +47,9 @@ static BOOL smb_pwd_check_ntlmv1(char *password, unsigned char *part_passwd,
return True;
SMBOWFencrypt(part_passwd, c8, p24);
- if (sess_key != NULL)
+ if (user_sess_key != NULL)
{
- SMBsesskeygen_ntv1(part_passwd, NULL, sess_key);
+ SMBsesskeygen_ntv1(part_passwd, NULL, user_sess_key);
}
#if DEBUG_PASSWORD
@@ -72,7 +72,7 @@ static BOOL smb_pwd_check_ntlmv2(char *password, size_t pwd_len,
unsigned char *part_passwd,
unsigned char const *c8,
const char *user, const char *domain,
- char *sess_key)
+ char *user_sess_key)
{
/* Finish the encryption of part_passwd. */
unsigned char kr[16];
@@ -90,9 +90,9 @@ static BOOL smb_pwd_check_ntlmv2(char *password, size_t pwd_len,
ntv2_owf_gen(part_passwd, user, domain, kr);
SMBOWFencrypt_ntv2(kr, c8, 8, password+16, pwd_len-16, resp);
- if (sess_key != NULL)
+ if (user_sess_key != NULL)
{
- SMBsesskeygen_ntv2(kr, resp, sess_key);
+ SMBsesskeygen_ntv2(kr, resp, user_sess_key);
}
#if DEBUG_PASSWORD
@@ -117,7 +117,7 @@ BOOL smb_password_ok(struct smb_passwd *smb_pass, uchar challenge[8],
const char *user, const char *domain,
uchar *lm_pass, size_t lm_pwd_len,
uchar *nt_pass, size_t nt_pwd_len,
- uchar sess_key[16])
+ uchar user_sess_key[16])
{
if (smb_pass == NULL)
{
@@ -151,7 +151,7 @@ BOOL smb_password_ok(struct smb_passwd *smb_pass, uchar challenge[8],
if (smb_pwd_check_ntlmv2(nt_pass, nt_pwd_len,
(uchar *)smb_pass->smb_nt_passwd,
challenge, user, domain,
- sess_key))
+ user_sess_key))
{
return True;
}
@@ -162,7 +162,7 @@ BOOL smb_password_ok(struct smb_passwd *smb_pass, uchar challenge[8],
if (smb_pwd_check_ntlmv1((char *)nt_pass,
(uchar *)smb_pass->smb_nt_passwd,
challenge,
- sess_key))
+ user_sess_key))
{
DEBUG(4,("NT MD4 password check succeeded\n"));
return True;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 65908ff19e..22adee49df 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -3012,7 +3012,12 @@ void dump_data(int level, const char *buf1, int len)
{
unsigned char const *buf = (unsigned char const *)buf1;
int i=0;
- if (len<=0) return;
+ if (len<0) return;
+ if (len == 0)
+ {
+ DEBUG(level,("\n"));
+ return;
+ }
DEBUG(level,("[%03X] ",i));
for (i=0;i<len;)
diff --git a/source3/lib/vuser.c b/source3/lib/vuser.c
index dfad258152..09a553e4e6 100644
--- a/source3/lib/vuser.c
+++ b/source3/lib/vuser.c
@@ -55,18 +55,12 @@ void invalidate_vuid(uint16 vuid)
vuser->uid = (uid_t)-1;
vuser->gid = (gid_t)-1;
- vuser->n_sids = 0;
-
/* same number of igroups as groups */
vuser->n_groups = 0;
if (vuser->groups)
free((char *)vuser->groups);
- if (vuser->sids)
- free((char *)vuser->sids);
-
- vuser->sids = NULL;
vuser->groups = NULL;
}
@@ -89,9 +83,53 @@ register a uid/name pair as being valid and that a valid password
has been given. vuid is biased by an offset. This allows us to
tell random client vuid's (normally zero) from valid vuids.
****************************************************************************/
-uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, BOOL guest, uchar user_sess_key[16])
+uint16 create_vuid(uid_t uid, gid_t gid, int n_groups, gid_t *groups,
+ char *unix_name, char *requested_name,
+ char *real_name,
+ BOOL guest, uchar user_sess_key[16])
{
user_struct *vuser;
+
+ validated_users = (user_struct *)Realloc(validated_users,
+ sizeof(user_struct)*
+ (num_validated_users+1));
+
+ if (!validated_users)
+ {
+ DEBUG(0,("Failed to realloc users struct!\n"));
+ num_validated_users = 0;
+ return UID_FIELD_INVALID;
+ }
+
+ vuser = &validated_users[num_validated_users];
+ num_validated_users++;
+
+ vuser->uid = uid;
+ vuser->gid = gid;
+ vuser->guest = guest;
+ fstrcpy(vuser->name,unix_name);
+ fstrcpy(vuser->requested_name,requested_name);
+ fstrcpy(vuser->real_name,real_name);
+ memcpy(vuser->user_sess_key, user_sess_key, sizeof(vuser->user_sess_key));
+
+ vuser->n_groups = n_groups;
+ vuser->groups = groups;
+
+ DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name));
+
+ return (uint16)((num_validated_users - 1) + VUID_OFFSET);
+}
+
+/****************************************************************************
+register a uid/name pair as being valid and that a valid password
+has been given. vuid is biased by an offset. This allows us to
+tell random client vuid's (normally zero) from valid vuids.
+****************************************************************************/
+uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name, BOOL guest, uchar user_sess_key[16])
+{
+ int n_groups;
+ gid_t *groups;
+ fstring real_name;
struct passwd *pwfile; /* for getting real name from passwd file */
/* Ensure no vuid gets registered in share level security. */
@@ -130,40 +168,28 @@ uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name,
return UID_FIELD_INVALID;
}
- vuser = &validated_users[num_validated_users];
- num_validated_users++;
-
- vuser->uid = uid;
- vuser->gid = gid;
- vuser->guest = guest;
- fstrcpy(vuser->name,unix_name);
- fstrcpy(vuser->requested_name,requested_name);
- memcpy(vuser->dc.user_sess_key, user_sess_key, sizeof(vuser->dc.user_sess_key));
-
- vuser->n_sids = 0;
- vuser->sids = NULL;
-
- vuser->n_groups = 0;
- vuser->groups = NULL;
-
/* Find all the groups this uid is in and store them.
Used by become_user() */
get_unixgroups(unix_name,uid,gid,
- &vuser->n_groups,
- &vuser->groups);
+ &n_groups,
+ &groups);
DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name));
DEBUG(3, ("Clearing default real name\n"));
- fstrcpy(vuser->real_name, "<Full Name>\0");
- if (lp_unix_realname()) {
- if ((pwfile=hashed_getpwnam(vuser->name))!= NULL)
+ fstrcpy(real_name, "<Full Name>\0");
+ if (lp_unix_realname())
+ {
+ if ((pwfile=hashed_getpwnam(unix_name))!= NULL)
{
- DEBUG(3, ("User name: %s\tReal name: %s\n",vuser->name,pwfile->pw_gecos));
- fstrcpy(vuser->real_name, pwfile->pw_gecos);
+ DEBUG(3, ("User name: %s\tReal name: %s\n",unix_name,pwfile->pw_gecos));
+ fstrcpy(real_name, pwfile->pw_gecos);
}
}
- return (uint16)((num_validated_users - 1) + VUID_OFFSET);
+ return create_vuid(uid, gid, n_groups, groups,
+ unix_name, requested_name,
+ real_name,
+ guest, user_sess_key);
}