summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-François Micouleau <jfm@samba.org>2001-05-08 16:33:18 +0000
committerJean-François Micouleau <jfm@samba.org>2001-05-08 16:33:18 +0000
commitb6a6b4b02ef923ce71a8be8258ccee1cbb439c6f (patch)
tree4adc6c0fce3385d225493b43a544e12c43a5fd46
parentacc0ca79a0d95160c2bcca40957b7d09c236c516 (diff)
downloadsamba-b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f.tar.gz
samba-b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f.tar.bz2
samba-b6a6b4b02ef923ce71a8be8258ccee1cbb439c6f.zip
fixes to the group mapping code.
Not ready yet. J.F. (This used to be commit 62a7a567fdea230b77cc97a3f74d868542c34700)
-rw-r--r--source3/groupdb/mapping.c1
-rw-r--r--source3/passdb/passdb.c4
-rw-r--r--source3/rpc_parse/parse_samr.c21
-rw-r--r--source3/rpc_server/srv_samr.c31
-rw-r--r--source3/rpc_server/srv_samr_nt.c56
5 files changed, 94 insertions, 19 deletions
diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c
index bc5ac3e9eb..5b844e93d2 100644
--- a/source3/groupdb/mapping.c
+++ b/source3/groupdb/mapping.c
@@ -662,6 +662,7 @@ BOOL get_uid_list_of_group(gid_t gid, uid_t **uid, int *num_uids)
char *gr;
*num_uids = 0;
+ *uid=NULL;
if ( (grp=getgrgid(gid)) == NULL)
return False;
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 05572e3de2..7b1ecdbc23 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -507,7 +507,7 @@ BOOL local_lookup_rid(uint32 rid, char *name, enum SID_NAME_USE *psid_name_use)
DEBUG(5,("local_lookup_rid: found NT group %s mapped to Unix gid %u for rid %u\n",
name, (unsigned int)map.gid, (unsigned int)rid ));
- if(!getgrgid(gid))
+ if(!getgrgid(map.gid))
return False;
else
return True;
@@ -1521,7 +1521,7 @@ BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, uint8 *pwd)
if (!sampass || !*pwd) return False;
if (sampass->lm_pw!=NULL)
- DEBUG(0,("pdb_set_nt_passwd: LM hash non NULL overwritting ?\n"));
+ DEBUG(0,("pdb_set_lanman_passwd: LM hash non NULL overwritting ?\n"));
else
sampass->lm_pw=(unsigned char *)malloc(sizeof(unsigned char)*16);
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 03226d522f..0d60880615 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -2047,29 +2047,32 @@ BOOL samr_io_group_info4(char *desc, GROUP_INFO4 * gr4,
reads or writes a structure.
********************************************************************/
-static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR * ctr,
+static BOOL samr_group_info_ctr(char *desc, GROUP_INFO_CTR **ctr,
prs_struct *ps, int depth)
{
- if (ctr == NULL)
+ if (UNMARSHALLING(ps))
+ *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR));
+
+ if (*ctr == NULL)
return False;
prs_debug(ps, depth, desc, "samr_group_info_ctr");
depth++;
- if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1))
+ if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1))
return False;
- if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2))
+ if(!prs_uint16("switch_value2", ps, depth, &(*ctr)->switch_value2))
return False;
- switch (ctr->switch_value1) {
+ switch ((*ctr)->switch_value1) {
case 1:
if(!samr_io_group_info1("group_info1",
- &ctr->group.info1, ps, depth))
+ &(*ctr)->group.info1, ps, depth))
return False;
break;
case 4:
if(!samr_io_group_info4("group_info4",
- &ctr->group.info4, ps, depth))
+ &(*ctr)->group.info4, ps, depth))
return False;
break;
default:
@@ -2395,7 +2398,7 @@ BOOL samr_io_q_set_groupinfo(char *desc, SAMR_Q_SET_GROUPINFO * q_e,
if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth))
return False;
- if(!samr_group_info_ctr("ctr", q_e->ctr, ps, depth))
+ if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth))
return False;
return True;
@@ -2507,7 +2510,7 @@ BOOL samr_io_r_query_groupinfo(char *desc, SAMR_R_QUERY_GROUPINFO * r_u,
return False;
if (r_u->ptr != 0) {
- if(!samr_group_info_ctr("ctr", r_u->ctr, ps, depth))
+ if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth))
return False;
}
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index 5012f0c483..9ab8ad5d15 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -1189,6 +1189,36 @@ static BOOL api_samr_set_groupinfo(pipes_struct *p)
}
/*******************************************************************
+ api_samr_set_aliasinfo
+ ********************************************************************/
+
+static BOOL api_samr_set_aliasinfo(pipes_struct *p)
+{
+ SAMR_Q_SET_ALIASINFO q_u;
+ SAMR_R_SET_ALIASINFO 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 (!samr_io_q_set_aliasinfo("", &q_u, data, 0)) {
+ DEBUG(0,("api_samr_set_aliasinfo: unable to unmarshall SAMR_Q_SET_ALIASINFO.\n"));
+ return False;
+ }
+
+ r_u.status = _samr_set_aliasinfo(p, &q_u, &r_u);
+
+ if (!samr_io_r_set_aliasinfo("", &r_u, rdata, 0)) {
+ DEBUG(0,("api_samr_set_aliasinfo: unable to marshall SAMR_R_SET_ALIASINFO.\n"));
+ return False;
+ }
+
+ return True;
+}
+
+/*******************************************************************
api_samr_get_dom_pwinfo
********************************************************************/
@@ -1320,6 +1350,7 @@ static struct api_struct api_samr_cmds [] =
{"SAMR_QUERY_ALIASINFO" , SAMR_QUERY_ALIASINFO , api_samr_query_aliasinfo },
{"SAMR_QUERY_GROUPINFO" , SAMR_QUERY_GROUPINFO , api_samr_query_groupinfo },
{"SAMR_SET_GROUPINFO" , SAMR_SET_GROUPINFO , api_samr_set_groupinfo },
+ {"SAMR_SET_ALIASINFO" , SAMR_SET_ALIASINFO , api_samr_set_aliasinfo },
{"SAMR_CREATE_USER" , SAMR_CREATE_USER , api_samr_create_user },
{"SAMR_LOOKUP_RIDS" , SAMR_LOOKUP_RIDS , api_samr_lookup_rids },
{"SAMR_GET_DOM_PWINFO" , SAMR_GET_DOM_PWINFO , api_samr_get_dom_pwinfo },
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index e09f93185c..693ef95df9 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -211,6 +211,8 @@ static BOOL jf_get_sampwd_entries(SAM_USER_INFO_21 *pw_buf, int start_idx,
pdb_get_username(pwd), pdb_get_user_rid(pwd), pdb_get_acct_ctrl(pwd) ));
(*num_entries)++;
+
+ pdb_reset_sam(pwd);
}
pdb_endsampwent();
@@ -1411,6 +1413,8 @@ uint32 _api_samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_U
if (!find_policy_by_hnd(p, &domain_pol, NULL))
return NT_STATUS_INVALID_HANDLE;
+ pdb_init_sam(&sampass);
+
become_root();
ret=pdb_getsampwrid(sampass, user_rid);
unbecome_root();
@@ -1540,6 +1544,8 @@ static BOOL get_user_info_21(SAM_USER_INFO_21 *id21, uint32 user_rid)
return False;
}
+ pdb_init_sam(&sampass);
+
become_root();
ret = pdb_getsampwrid(sampass, user_rid);
unbecome_root();
@@ -2520,8 +2526,8 @@ uint32 _samr_query_aliasmem(pipes_struct *p, SAMR_Q_QUERY_ALIASMEM *q_u, SAMR_R_
DEBUG(10, ("sid is %s\n", alias_sid_str));
sid = (DOM_SID2 *)talloc(p->mem_ctx, sizeof(DOM_SID2) * num_uids);
- if (sid == NULL)
- return NT_STATUS_NO_SUCH_ALIAS;
+ if (num_uids!=0 && sid == NULL)
+ return NT_STATUS_NO_MEMORY;
for (i = 0; i < num_uids; i++) {
sid_copy(&temp_sid, &global_sam_sid);
@@ -2581,7 +2587,7 @@ uint32 _samr_query_groupmem(pipes_struct *p, SAMR_Q_QUERY_GROUPMEM *q_u, SAMR_R_
rid=talloc(p->mem_ctx, sizeof(uint32)*num_uids);
attr=talloc(p->mem_ctx, sizeof(uint32)*num_uids);
- if (rid==NULL || attr==NULL)
+ if (num_uids!=0 && (rid==NULL || attr==NULL))
return NT_STATUS_NO_MEMORY;
for (i=0; i<num_uids; i++) {
@@ -2859,10 +2865,6 @@ uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAM
r_u->rid=pdb_gid_to_group_rid(grp->gr_gid);
- /* add the group to the mapping table */
- if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, NULL, NULL, SE_PRIV_NONE))
- return NT_STATUS_ACCESS_DENIED;
-
if ((info = (struct samr_info *)malloc(sizeof(struct samr_info))) == NULL)
return NT_STATUS_NO_MEMORY;
@@ -2872,6 +2874,10 @@ uint32 _samr_create_dom_alias(pipes_struct *p, SAMR_Q_CREATE_DOM_ALIAS *q_u, SAM
sid_append_rid(&info->sid, r_u->rid);
sid_to_string(sid_string, &info->sid);
+ /* add the group to the mapping table */
+ if(!add_initial_entry(grp->gr_gid, sid_string, SID_NAME_ALIAS, name, NULL, SE_PRIV_NONE))
+ return NT_STATUS_ACCESS_DENIED;
+
/* get a (unique) handle. open a policy on it. */
if (!create_policy_hnd(p, &r_u->alias_pol, free_samr_info, (void *)info))
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
@@ -2890,7 +2896,7 @@ uint32 _samr_query_groupinfo(pipes_struct *p, SAMR_Q_QUERY_GROUPINFO *q_u, SAMR_
{
DOM_SID group_sid;
GROUP_MAP map;
- uid_t *uid;
+ uid_t *uid=NULL;
int num_uids=0;
GROUP_INFO_CTR *ctr;
@@ -2963,6 +2969,40 @@ uint32 _samr_set_groupinfo(pipes_struct *p, SAMR_Q_SET_GROUPINFO *q_u, SAMR_R_SE
}
/*********************************************************************
+ _samr_set_groupinfo
+
+ update a domain group's comment.
+*********************************************************************/
+
+uint32 _samr_set_aliasinfo(pipes_struct *p, SAMR_Q_SET_ALIASINFO *q_u, SAMR_R_SET_ALIASINFO *r_u)
+{
+ DOM_SID group_sid;
+ GROUP_MAP map;
+ ALIAS_INFO_CTR *ctr;
+
+ if (!get_lsa_policy_samr_sid(p, &q_u->alias_pol, &group_sid))
+ return NT_STATUS_INVALID_HANDLE;
+
+ if (!get_local_group_from_sid(group_sid, &map))
+ return NT_STATUS_NO_SUCH_GROUP;
+
+ ctr=&q_u->ctr;
+
+ switch (ctr->switch_value1) {
+ case 3:
+ unistr2_to_ascii(map.comment, &(ctr->alias.info3.uni_acct_desc), sizeof(map.comment)-1);
+ break;
+ default:
+ return NT_STATUS_INVALID_INFO_CLASS;
+ }
+
+ if(!add_mapping_entry(&map, TDB_REPLACE))
+ return NT_STATUS_NO_SUCH_GROUP;
+
+ return NT_STATUS_NO_PROBLEMO;
+}
+
+/*********************************************************************
_samr_get_dom_pwinfo
*********************************************************************/