summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-11-07 18:32:29 +0000
committerJeremy Allison <jra@samba.org>2003-11-07 18:32:29 +0000
commita3aa2c9ed44f5967986d340456efd5828bd5f2ff (patch)
tree0e56075981a33c9323376067e337571f7b91d0cd /source3/rpc_server
parente9bd28d0a7b0fd667e52683013404dc4b1e03673 (diff)
downloadsamba-a3aa2c9ed44f5967986d340456efd5828bd5f2ff.tar.gz
samba-a3aa2c9ed44f5967986d340456efd5828bd5f2ff.tar.bz2
samba-a3aa2c9ed44f5967986d340456efd5828bd5f2ff.zip
Handle munged dial string. Patch from Aur?lien Degr?mont <adegremont@idealx.com>
with memory leak fixes by me. Jeremy. (This used to be commit daceed37387c517b3f0ab9c173f419215e3d676b)
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_samr_nt.c37
-rw-r--r--source3/rpc_server/srv_samr_util.c60
2 files changed, 86 insertions, 11 deletions
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 71e5bc7d70..446eff9045 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -2789,6 +2789,38 @@ static BOOL set_unix_primary_group(SAM_ACCOUNT *sampass)
/*******************************************************************
+ set_user_info_20
+ ********************************************************************/
+
+static BOOL set_user_info_20(SAM_USER_INFO_20 *id20, DOM_SID *sid)
+{
+ SAM_ACCOUNT *pwd = NULL;
+
+ if (id20 == NULL) {
+ DEBUG(5, ("set_user_info_20: NULL id20\n"));
+ return False;
+ }
+
+ pdb_init_sam(&pwd);
+
+ if (!pdb_getsampwsid(pwd, sid)) {
+ pdb_free_sam(&pwd);
+ return False;
+ }
+
+ copy_id20_to_sam_passwd(pwd, id20);
+
+ /* write the change out */
+ if(!pdb_update_sam_account(pwd)) {
+ pdb_free_sam(&pwd);
+ return False;
+ }
+
+ pdb_free_sam(&pwd);
+
+ return True;
+}
+/*******************************************************************
set_user_info_21
********************************************************************/
@@ -3091,6 +3123,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_
if (!set_user_info_21(ctr->info.id21, &sid))
return NT_STATUS_ACCESS_DENIED;
break;
+ case 20:
+ if (!set_user_info_20(ctr->info.id20, &sid))
+ return NT_STATUS_ACCESS_DENIED;
+ break;
case 16:
if (!set_user_info_10(ctr->info.id10, &sid))
return NT_STATUS_ACCESS_DENIED;
@@ -4537,4 +4573,3 @@ NTSTATUS _samr_set_dom_info(pipes_struct *p, SAMR_Q_SET_DOMAIN_INFO *q_u, SAMR_R
return r_u->status;
}
-
diff --git a/source3/rpc_server/srv_samr_util.c b/source3/rpc_server/srv_samr_util.c
index db6649073e..82f93a5b4c 100644
--- a/source3/rpc_server/srv_samr_util.c
+++ b/source3/rpc_server/srv_samr_util.c
@@ -31,6 +31,36 @@
(!old_string && new_string) ||\
(old_string && new_string && (strcmp(old_string, new_string) != 0))
+#define STRING_CHANGED_NC(s1,s2) ((s1) && !(s2)) ||\
+ (!(s1) && (s2)) ||\
+ ((s1) && (s2) && (strcmp((s1), (s2)) != 0))
+
+/*************************************************************
+ Copies a SAM_USER_INFO_20 to a SAM_ACCOUNT
+**************************************************************/
+
+void copy_id20_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_20 *from)
+{
+ const char *old_string;
+ char *new_string;
+ DATA_BLOB mung;
+
+ if (from == NULL || to == NULL)
+ return;
+
+ if (from->hdr_munged_dial.buffer) {
+ old_string = pdb_get_munged_dial(to);
+ mung.length = from->hdr_munged_dial.uni_str_len;
+ mung.data = (uint8 *) from->uni_munged_dial.buffer;
+ new_string = base64_encode_data_blob(mung);
+ DEBUG(10,("INFO_20 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
+ if (STRING_CHANGED_NC(old_string,new_string))
+ pdb_set_munged_dial(to , new_string, PDB_CHANGED);
+
+ SAFE_FREE(new_string);
+ }
+}
+
/*************************************************************
Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT
**************************************************************/
@@ -39,6 +69,7 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
{
time_t unix_time, stored_time;
const char *old_string, *new_string;
+ DATA_BLOB mung;
if (from == NULL || to == NULL)
return;
@@ -162,11 +193,16 @@ void copy_id21_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_21 *from)
}
if (from->hdr_munged_dial.buffer) {
+ char *newstr;
old_string = pdb_get_munged_dial(to);
- new_string = unistr2_static(&from->uni_munged_dial);
- DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
- if (STRING_CHANGED)
- pdb_set_munged_dial(to , new_string, PDB_CHANGED);
+ mung.length = from->hdr_munged_dial.uni_str_len;
+ mung.data = (uint8 *) from->uni_munged_dial.buffer;
+ newstr = base64_encode_data_blob(mung);
+ DEBUG(10,("INFO_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr));
+ if (STRING_CHANGED_NC(old_string,newstr))
+ pdb_set_munged_dial(to , newstr, PDB_CHANGED);
+
+ SAFE_FREE(newstr);
}
if (from->user_rid == 0) {
@@ -250,6 +286,7 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
{
time_t unix_time, stored_time;
const char *old_string, *new_string;
+ DATA_BLOB mung;
if (from == NULL || to == NULL)
return;
@@ -373,11 +410,16 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
}
if (from->hdr_munged_dial.buffer) {
+ char *newstr;
old_string = pdb_get_munged_dial(to);
- new_string = unistr2_static(&from->uni_munged_dial);
- DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
- if (STRING_CHANGED)
- pdb_set_munged_dial(to , new_string, PDB_CHANGED);
+ mung.length = from->hdr_munged_dial.uni_str_len;
+ mung.data = (uint8 *) from->uni_munged_dial.buffer;
+ newstr = base64_encode_data_blob(mung);
+ DEBUG(10,("INFO_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, newstr));
+ if (STRING_CHANGED_NC(old_string, newstr))
+ pdb_set_munged_dial(to , newstr, PDB_CHANGED);
+
+ SAFE_FREE(newstr);
}
if (from->user_rid == 0) {
@@ -450,5 +492,3 @@ void copy_id23_to_sam_passwd(SAM_ACCOUNT *to, SAM_USER_INFO_23 *from)
DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4));
}
-
-