[PATCH] TSE/munged dial : bugfix !
Aurélien Degrémont
adegremont at idealx.com
Fri Nov 7 10:50:31 GMT 2003
Hi,
There is a problem with my previous patch concerning TSE. Only 2 of the
four diff of the modified files were present.
Be aware that that buggy patch compiles without warnings and Samba run
without complaining, but the data inside munged_dial are totally broken.
Here is the correct patch for it :)
Aurélien
-------------- next part --------------
diff -ruN samba-3.0.1pre1/source/rpc_parse/parse_misc.c samba-tse-3.0.1pre1/source/rpc_parse/parse_misc.c
--- samba-3.0.1pre1/source/rpc_parse/parse_misc.c 2003-10-10 20:08:36.000000000 +0200
+++ samba-tse-3.0.1pre1/source/rpc_parse/parse_misc.c 2003-11-05 14:42:36.000000000 +0100
@@ -1001,6 +1001,23 @@
}
/*******************************************************************
+ Inits a UNISTR2 structure from a DATA_BLOB.
+ The length of the data_blob must count the bytes of the buffer.
+********************************************************************/
+void init_unistr2_from_datablob(UNISTR2 *str, DATA_BLOB *blob)
+{
+ /* Allocs the unistring */
+ init_unistr2(str, NULL, UNI_FLAGS_NONE);
+
+ /* Sets the values */
+ str->uni_str_len = blob->length / sizeof(uint16);
+ str->uni_max_len = str->uni_str_len;
+ str->offset = 0;
+ str->buffer = (uint16 *) blob->data;
+
+}
+
+/*******************************************************************
Reads or writes a UNISTR2 structure.
XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
the uni_str_len member tells you how long the string is;
diff -ruN samba-3.0.1pre1/source/rpc_parse/parse_samr.c samba-tse-3.0.1pre1/source/rpc_parse/parse_samr.c
--- samba-3.0.1pre1/source/rpc_parse/parse_samr.c 2003-10-10 20:08:36.000000000 +0200
+++ samba-tse-3.0.1pre1/source/rpc_parse/parse_samr.c 2003-11-05 14:57:32.000000000 +0100
@@ -5485,6 +5485,8 @@
LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
char newpass[516], uint32 unknown_6)
{
+ DATA_BLOB blob = base64_decode_data_blob(mung_dial);
+
usr->logon_time = *logon_time; /* all zeros */
usr->logoff_time = *logoff_time; /* all zeros */
usr->kickoff_time = *kickoff_time; /* all zeros */
@@ -5544,7 +5546,7 @@
init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
- init_unistr2(&usr->uni_munged_dial, mung_dial, UNI_FLAGS_NONE);
+ init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
usr->unknown_6 = unknown_6; /* 0x0000 04ec */
@@ -5934,6 +5936,7 @@
const char* description = pdb_get_acct_desc(pw);
const char* workstations = pdb_get_workstations(pw);
const char* munged_dial = pdb_get_munged_dial(pw);
+ DATA_BLOB blob = base64_decode_data_blob(munged_dial);
uint32 user_rid;
const DOM_SID *user_sid;
@@ -6042,7 +6045,7 @@
init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
- init_unistr2(&usr->uni_munged_dial, munged_dial, UNI_STR_TERMINATE);
+ init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
usr->unknown_6 = pdb_get_unknown_6(pw);
@@ -6184,9 +6187,11 @@
void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
{
const char *munged_dial = pdb_get_munged_dial(pw);
-
- init_unistr2(&usr->uni_munged_dial, munged_dial, UNI_STR_TERMINATE);
+ DATA_BLOB blob = base64_decode_data_blob(munged_dial);
+
+ init_unistr2_from_datablob(&usr->uni_munged_dial, &blob);
init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
+
}
diff -ruN samba-3.0.1pre1/source/rpc_server/srv_samr_nt.c samba-tse-3.0.1pre1/source/rpc_server/srv_samr_nt.c
--- samba-3.0.1pre1/source/rpc_server/srv_samr_nt.c 2003-10-10 20:08:36.000000000 +0200
+++ samba-tse-3.0.1pre1/source/rpc_server/srv_samr_nt.c 2003-11-04 18:30:49.000000000 +0100
@@ -2789,6 +2789,38 @@
/*******************************************************************
+ 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 @@
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 @@
return r_u->status;
}
-
diff -ruN samba-3.0.1pre1/source/rpc_server/srv_samr_util.c samba-tse-3.0.1pre1/source/rpc_server/srv_samr_util.c
--- samba-3.0.1pre1/source/rpc_server/srv_samr_util.c 2003-10-10 20:08:36.000000000 +0200
+++ samba-tse-3.0.1pre1/source/rpc_server/srv_samr_util.c 2003-11-05 15:00:44.000000000 +0100
@@ -32,6 +32,31 @@
(old_string && new_string && (strcmp(old_string, new_string) != 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, *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)
+ pdb_set_munged_dial(to , new_string, PDB_CHANGED);
+ }
+
+}
+
+
+/*************************************************************
Copies a SAM_USER_INFO_21 to a SAM_ACCOUNT
**************************************************************/
@@ -39,6 +64,7 @@
{
time_t unix_time, stored_time;
const char *old_string, *new_string;
+ DATA_BLOB mung;
if (from == NULL || to == NULL)
return;
@@ -163,7 +189,9 @@
if (from->hdr_munged_dial.buffer) {
old_string = pdb_get_munged_dial(to);
- new_string = unistr2_static(&from->uni_munged_dial);
+ 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_21 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
if (STRING_CHANGED)
pdb_set_munged_dial(to , new_string, PDB_CHANGED);
@@ -250,6 +278,7 @@
{
time_t unix_time, stored_time;
const char *old_string, *new_string;
+ DATA_BLOB mung;
if (from == NULL || to == NULL)
return;
@@ -374,7 +403,9 @@
if (from->hdr_munged_dial.buffer) {
old_string = pdb_get_munged_dial(to);
- new_string = unistr2_static(&from->uni_munged_dial);
+ 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_23 UNI_MUNGED_DIAL: %s -> %s\n",old_string, new_string));
if (STRING_CHANGED)
pdb_set_munged_dial(to , new_string, PDB_CHANGED);
@@ -450,5 +481,3 @@
DEBUG(10,("INFO_23 PADDING_4: %08X\n",from->padding4));
}
-
-
More information about the samba-technical
mailing list