svn commit: samba r4284 - in branches/SAMBA_4_0/source/smb_server: .

2004-12-19 Thread tridge
Author: tridge
Date: 2004-12-20 03:12:09 + (Mon, 20 Dec 2004)
New Revision: 4284

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4284

Log:
fixed a problem with very large EA lists and OS/2 clients. These
checks on allocations need to go in a lot more places, but at least
this is a start.

Modified:
   branches/SAMBA_4_0/source/smb_server/trans2.c


Changeset:
Modified: branches/SAMBA_4_0/source/smb_server/trans2.c
===
--- branches/SAMBA_4_0/source/smb_server/trans2.c   2004-12-19 11:34:19 UTC 
(rev 4283)
+++ branches/SAMBA_4_0/source/smb_server/trans2.c   2004-12-20 03:12:09 UTC 
(rev 4284)
@@ -35,36 +35,43 @@
 /* grow the data allocation size of a trans2 reply - this guarantees
that requests to grow the data size later will not change the
pointer */
-static void trans2_grow_data_allocation(struct smbsrv_request *req, 
+static BOOL trans2_grow_data_allocation(struct smbsrv_request *req, 
struct smb_trans2 *trans,
-   uint16_t new_size)
+   uint32_t new_size)
 {
if (new_size <= trans->out.data.length) {
-   return;
+   return True;
}
trans->out.data.data = talloc_realloc(req, trans->out.data.data, 
new_size);
+   return (trans->out.data.data != NULL);
 }
 
 
 /* grow the data size of a trans2 reply */
-static void trans2_grow_data(struct smbsrv_request *req, 
+static BOOL trans2_grow_data(struct smbsrv_request *req, 
 struct smb_trans2 *trans,
-uint16_t new_size)
+uint32_t new_size)
 {
-   trans2_grow_data_allocation(req, trans, new_size);
+   if (!trans2_grow_data_allocation(req, trans, new_size)) {
+   return False;
+   }
trans->out.data.length = new_size;
+   return True;
 }
 
 /* grow the data, zero filling any new bytes */
-static void trans2_grow_data_fill(struct smbsrv_request *req, 
+static BOOL trans2_grow_data_fill(struct smbsrv_request *req, 
  struct smb_trans2 *trans,
- uint16_t new_size)
+ uint32_t new_size)
 {
-   uint16_t old_size = trans->out.data.length;
-   trans2_grow_data(req, trans, new_size);
+   uint32_t old_size = trans->out.data.length;
+   if (!trans2_grow_data(req, trans, new_size)) {
+   return False;
+   }
if (new_size > old_size) {
memset(trans->out.data.data + old_size, 0, new_size - old_size);
}
+   return True;
 }
 
 
@@ -1004,7 +1011,7 @@
 /*
   fill a single entry in a trans2 find reply 
 */
-static void find_fill_info(struct smbsrv_request *req,
+static BOOL find_fill_info(struct smbsrv_request *req,
   struct smb_trans2 *trans, 
   struct find_state *state,
   union smb_search_data *file)
@@ -1065,11 +1072,15 @@
case RAW_SEARCH_EA_LIST:
ea_size = ea_list_size(file->ea_list.eas.num_eas, 
file->ea_list.eas.eas);
if (state->flags & FLAG_TRANS2_FIND_REQUIRE_RESUME) {
-   trans2_grow_data(req, trans, ofs + 27 + ea_size);
+   if (!trans2_grow_data(req, trans, ofs + 27 + ea_size)) {
+   return False;
+   }
SIVAL(trans->out.data.data, ofs, 
file->ea_list.resume_key);
ofs += 4;
} else {
-   trans2_grow_data(req, trans, ofs + 23 + ea_size);
+   if (!trans2_grow_data(req, trans, ofs + 23 + ea_size)) {
+   return False;
+   }
}
data = trans->out.data.data + ofs;
srv_push_dos_date2(req->smb_conn, data, 0, 
file->ea_list.create_time);
@@ -1200,6 +1211,8 @@
SIVAL(data,  0, trans->out.data.length - ofs);
break;
}
+
+   return True;
 }
 
 /* callback function for trans2 findfirst/findnext */
@@ -1211,10 +1224,8 @@
 
old_length = trans->out.data.length;
 
-   find_fill_info(state->req, trans, state, file);
-
-   /* see if we have gone beyond the user specified maximum */
-   if (trans->out.data.length > trans->in.max_data) {
+   if (!find_fill_info(state->req, trans, state, file) ||
+   trans->out.data.length > trans->in.max_data) {
/* restore the old length and tell the backend to stop */
trans2_grow_data(state->req, trans, old_length);
return False;



svn commit: samba-docs r306 - in trunk/Samba-HOWTO-Collection: .

2004-12-19 Thread jht
Author: jht
Date: 2004-12-19 16:26:02 + (Sun, 19 Dec 2004)
New Revision: 306

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba-docs&rev=306

Log:
Replace drive root with environment variable that is portable.
Modified:
   trunk/Samba-HOWTO-Collection/Integrating-with-Windows.xml


Changeset:
Modified: trunk/Samba-HOWTO-Collection/Integrating-with-Windows.xml
===
--- trunk/Samba-HOWTO-Collection/Integrating-with-Windows.xml   2004-12-16 
12:33:57 UTC (rev 305)
+++ trunk/Samba-HOWTO-Collection/Integrating-with-Windows.xml   2004-12-19 
16:26:02 UTC (rev 306)
@@ -442,7 +442,7 @@
 
 LMHOSTS
 This file is usually located in MS Windows NT 4.0 or Windows 200x/XP in the 
directory
-C:\WINNT\SYSTEM32\DRIVERS\ETC and contains the IP Address
+%SystemRoot%\SYSTEM32\DRIVERS\ETC and contains the IP 
Address
 and the machine name in matched pairs. The LMHOSTS file
 performs NetBIOS name to IP address mapping.
 
@@ -538,7 +538,7 @@
 
 
 This file is usually located in MS Windows NT 4.0 or Windows 200x/XP in 
-the directory C:\WINNT\SYSTEM32\DRIVERS\ETC and contains 
+the directory %SystemRoot%\SYSTEM32\DRIVERS\ETC and 
contains 
 the IP Address and the IP hostname in matched pairs. It can be 
 used by the name resolution infrastructure in MS Windows, depending 
 on how the TCP/IP environment is configured. This file is in 



svn commit: samba-web r479 - in trunk/docs: .

2004-12-19 Thread deryck
Author: deryck
Date: 2004-12-19 14:28:17 + (Sun, 19 Dec 2004)
New Revision: 479

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba-web&rev=479

Log:

Adding info on getting docs from subversion.

--deryck

Modified:
   trunk/docs/index.html


Changeset:
Modified: trunk/docs/index.html
===
--- trunk/docs/index.html   2004-12-17 19:37:49 UTC (rev 478)
+++ trunk/docs/index.html   2004-12-19 14:28:17 UTC (rev 479)
@@ -131,6 +131,12 @@
   community, and any help is much appreciated.  Contributions can be 
simple 
   typo corrections or a write up of new or previously undocumented 
features.
 
+To get the lastest docs sources from Subversion, run:
+
+
+svn co svn://svnanon.samba.org/samba-docs/trunk samba-docs
+
+
 Documentation "patches" can be reported through 
https://bugzilla.samba.org";>bugzilla.  From the bugzilla 
home 
 page, select 'Enter a new bug report,' choose the appropriate Samba 
branch, 



svn commit: samba r4283 - in branches/SAMBA_4_0/source/rpc_server/lsa: .

2004-12-19 Thread tridge
Author: tridge
Date: 2004-12-19 11:34:19 + (Sun, 19 Dec 2004)
New Revision: 4283

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4283

Log:
adding a privilege that an account already has is not an error


Modified:
   branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c


Changeset:
Modified: branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c
===
--- branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c   2004-12-19 
10:58:36 UTC (rev 4282)
+++ branches/SAMBA_4_0/source/rpc_server/lsa/dcesrv_lsa.c   2004-12-19 
11:34:19 UTC (rev 4283)
@@ -878,7 +878,57 @@
return NT_STATUS_OK;
 }
 
+/* 
+  lsa_EnumAccountRights 
+*/
+static NTSTATUS lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, 
+ TALLOC_CTX *mem_ctx,
+ struct lsa_EnumAccountRights *r)
+{
+   struct dcesrv_handle *h;
+   struct lsa_policy_state *state;
+   int ret, i;
+   struct ldb_message **res;
+   const char * const attrs[] = { "privilege", NULL};
+   const char *sidstr;
+   struct ldb_message_element *el;
 
+   DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY);
+
+   state = h->data;
+
+   sidstr = dom_sid_string(mem_ctx, r->in.sid);
+   if (sidstr == NULL) {
+   return NT_STATUS_NO_MEMORY;
+   }
+
+   ret = samdb_search(state->sam_ctx, mem_ctx, NULL, &res, attrs, 
+  "objectSid=%s", sidstr);
+   if (ret != 1) {
+   return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+   }
+
+   el = ldb_msg_find_element(res[0], "privilege");
+   if (el == NULL || el->num_values == 0) {
+   return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+   }
+
+   r->out.rights->count = el->num_values;
+   r->out.rights->names = talloc_array_p(r->out.rights, 
+ struct lsa_String, 
r->out.rights->count);
+   if (r->out.rights->names == NULL) {
+   return NT_STATUS_NO_MEMORY;
+   }
+
+   for (i=0;inum_values;i++) {
+   r->out.rights->names[i].string = el->values[i].data;
+   }
+
+   return NT_STATUS_OK;
+}
+
+
+
 /* 
   helper for lsa_AddAccountRights and lsa_RemoveAccountRights
 */
@@ -886,7 +936,7 @@
   TALLOC_CTX *mem_ctx,
   struct lsa_policy_state *state,
   int ldb_flag,
-  const struct dom_sid *sid,
+  struct dom_sid *sid,
   const struct lsa_RightSet *rights)
 {
const char *sidstr;
@@ -894,6 +944,7 @@
struct ldb_message_element el;
int i, ret;
const char *dn;
+   struct lsa_EnumAccountRights r2;
 
sidstr = dom_sid_string(mem_ctx, sid);
if (sidstr == NULL) {
@@ -917,22 +968,54 @@
if (el.name == NULL) {
return NT_STATUS_NO_MEMORY;
}
-   el.num_values = rights->count;
-   el.values = talloc_array_p(mem_ctx, struct ldb_val, el.num_values);
+
+   if (ldb_flag == LDB_FLAG_MOD_ADD) {
+   NTSTATUS status;
+
+   r2.in.handle = &state->handle->wire_handle;
+   r2.in.sid = sid;
+   r2.out.rights = talloc_p(mem_ctx, struct lsa_RightSet);
+
+   status = lsa_EnumAccountRights(dce_call, mem_ctx, &r2);
+   if (!NT_STATUS_IS_OK(status)) {
+   ZERO_STRUCTP(r2.out.rights);
+   }
+   }
+
+   el.num_values = 0;
+   el.values = talloc_array_p(mem_ctx, struct ldb_val, rights->count);
if (el.values == NULL) {
return NT_STATUS_NO_MEMORY;
}
-   for (i=0;icount;i++) {
if (sec_privilege_id(rights->names[i].string) == -1) {
return NT_STATUS_NO_SUCH_PRIVILEGE;
}
-   el.values[i].length = strlen(rights->names[i].string);
-   el.values[i].data = talloc_strdup(mem_ctx, 
rights->names[i].string);
-   if (el.values[i].data == NULL) {
+
+   if (ldb_flag == LDB_FLAG_MOD_ADD) {
+   int j;
+   for (j=0;jcount;j++) {
+   if (StrCaseCmp(r2.out.rights->names[j].string, 
+  rights->names[i].string) == 0) {
+   break;
+   }
+   }
+   if (j != r2.out.rights->count) continue;
+   }
+
+
+   el.values[el.num_values].length = 
strlen(rights->names[i].string);
+   el.values[el.num_values].data = talloc_strdup(mem_ctx, 
rights->names[i].string);
+   if (el.values[el.num_values].data

svn commit: samba r4282 - in branches/SAMBA_4_0/source/lib/ldb/ldb_tdb: .

2004-12-19 Thread tridge
Author: tridge
Date: 2004-12-19 10:58:36 + (Sun, 19 Dec 2004)
New Revision: 4282

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4282

Log:
removed a spurious error message now we remove index entries in the modify call

Modified:
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
===
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c   2004-12-19 
10:56:29 UTC (rev 4281)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c   2004-12-19 
10:58:36 UTC (rev 4282)
@@ -769,7 +769,6 @@
if (ret == 0) {
/* it wasn't indexed. Did we have an earlier error? If we did 
then
   its gone now */
-   ldb_debug(ldb, LDB_DEBUG_ERROR, "ERROR: dn_key %s was not 
indexed\n", dn_key);
ldb_free(ldb, dn_key);
return 0;
}



svn commit: samba r4281 - in branches/SAMBA_4_0/source/lib/ldb/ldb_tdb: .

2004-12-19 Thread tridge
Author: tridge
Date: 2004-12-19 10:56:29 + (Sun, 19 Dec 2004)
New Revision: 4281

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=4281

Log:
fixed an ldb indexing bug in ldb found by volker.

index entries were not always being removed on modify

Modified:
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
   branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c
===
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c   2004-12-19 
07:50:19 UTC (rev 4280)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_index.c   2004-12-19 
10:56:29 UTC (rev 4281)
@@ -746,8 +746,8 @@
 /*
   delete an index entry for one message element
 */
-static int ltdb_index_del1(struct ldb_module *module, const char *dn, 
-  struct ldb_message_element *el, int v_idx)
+int ltdb_index_del_value(struct ldb_module *module, const char *dn, 
+struct ldb_message_element *el, int v_idx)
 {
struct ldb_context *ldb = module->ldb;
struct ldb_message msg;
@@ -826,7 +826,7 @@
continue;
}
for (j=0;jelements[i].num_values;j++) {
-   ret = ltdb_index_del1(module, msg->dn, 
&msg->elements[i], j);
+   ret = ltdb_index_del_value(module, msg->dn, 
&msg->elements[i], j);
if (ret == -1) {
return -1;
}

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c
===
--- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2004-12-19 07:50:19 UTC 
(rev 4280)
+++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2004-12-19 10:56:29 UTC 
(rev 4281)
@@ -403,10 +403,11 @@
 /*
   delete all elements having a specified attribute name
 */
-static int msg_delete_attribute(struct ldb_context *ldb,
+static int msg_delete_attribute(struct ldb_module *module,
+   struct ldb_context *ldb,
struct ldb_message *msg, const char *name)
 {
-   unsigned int i, count=0;
+   unsigned int i, j, count=0;
struct ldb_message_element *el2;
 
el2 = ldb_malloc_array_p(ldb, struct ldb_message_element, 
msg->num_elements);
@@ -419,6 +420,9 @@
if (ldb_attr_cmp(msg->elements[i].name, name) != 0) {
el2[count++] = msg->elements[i];
} else {
+   for (j=0;jelements[i].num_values;j++) {
+   ltdb_index_del_value(module, msg->dn, 
&msg->elements[i], j);
+   }
ldb_free(ldb, msg->elements[i].values);
}
}
@@ -460,7 +464,7 @@
}
el->num_values--;
if (el->num_values == 0) {
-   return msg_delete_attribute(ldb, msg, name);
+   return msg_delete_attribute(module, ldb, msg, 
name);
}
return 0;
}
@@ -532,7 +536,7 @@
case LDB_FLAG_MOD_REPLACE:
/* replace all elements of this attribute name with the 
elements
   listed. The attribute not existing is not an error */
-   msg_delete_attribute(ldb, &msg2, msg->elements[i].name);
+   msg_delete_attribute(module, ldb, &msg2, 
msg->elements[i].name);
 
/* add the replacement element, if not empty */
if (msg->elements[i].num_values != 0 &&
@@ -545,7 +549,7 @@
/* we could be being asked to delete all
   values or just some values */
if (msg->elements[i].num_values == 0) {
-   if (msg_delete_attribute(ldb, &msg2, 
+   if (msg_delete_attribute(module, ldb, &msg2, 
 msg->elements[i].name) 
!= 0) {
ltdb->last_err_string = "No such 
attribute";
goto failed;
@@ -560,6 +564,9 @@
ltdb->last_err_string = "No such 
attribute";
goto failed;
}
+   if (ltdb_index_del_value(module, msg->dn, 
&msg->elements[i], j) != 0) {
+   goto failed;
+   }
}
break;
}

Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.h