svn commit: samba r24732 - in branches/SAMBA_4_0/source/libnet: .

2007-08-28 Thread mimir
Author: mimir
Date: 2007-08-28 09:57:47 + (Tue, 28 Aug 2007)
New Revision: 24732

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

Log:
Add comments and fix memory leak.


rafal


Modified:
   branches/SAMBA_4_0/source/libnet/libnet_group.c


Changeset:
Modified: branches/SAMBA_4_0/source/libnet/libnet_group.c
===
--- branches/SAMBA_4_0/source/libnet/libnet_group.c 2007-08-28 05:43:26 UTC 
(rev 24731)
+++ branches/SAMBA_4_0/source/libnet/libnet_group.c 2007-08-28 09:57:47 UTC 
(rev 24732)
@@ -41,7 +41,15 @@
 static void continue_name_found(struct composite_context *ctx);
 static void continue_group_info(struct composite_context *ctx);
 
-
+/**
+ * Sends request to get group information
+ *
+ * @param ctx initialised libnet context
+ * @param mem_ctx memory context of this call
+ * @param io pointer to structure containing arguments the call
+ * @param monitor function pointer for receiving monitor messages
+ * @return composite context of this request
+ */
 struct composite_context* libnet_GroupInfo_send(struct libnet_context *ctx,
TALLOC_CTX *mem_ctx,
struct libnet_GroupInfo *io,
@@ -61,9 +69,9 @@
 
c->private_data = s;
 
+   /* store arguments in the state structure */
s->monitor_fn = monitor;
-   s->ctx = ctx;
-   
+   s->ctx = ctx;   
s->domain_name = talloc_strdup(c, io->in.domain_name);
s->group_name  = talloc_strdup(c, io->in.group_name);
 
@@ -71,18 +79,24 @@
prereq_met = samr_domain_opened(ctx, s->domain_name, &c, &s->domopen,
continue_domain_open_info, monitor);
if (!prereq_met) return c;
-
+   
+   /* prepare arguments for LookupName call */
s->lookup.in.name= s->group_name;
s->lookup.in.domain_name = s->domain_name;
 
+   /* send the request */
lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, 
s->monitor_fn);
if (composite_nomem(lookup_req, c)) return c;
 
+   /* set the next stage */
composite_continue(c, lookup_req, continue_name_found, c);
return c;
 }
 
 
+/*
+ * Stage 0.5 (optional): receive opened domain and send lookup name request
+ */
 static void continue_domain_open_info(struct composite_context *ctx)
 {
struct composite_context *c;
@@ -92,19 +106,26 @@
c = talloc_get_type(ctx->async.private_data, struct composite_context);
s = talloc_get_type(c->private_data, struct group_info_state);

+   /* receive domain handle */
c->status = libnet_DomainOpen_recv(ctx, s->ctx, c, &s->domopen);
if (!composite_is_ok(c)) return;
 
+   /* prepare arguments for LookupName call */
s->lookup.in.name= s->group_name;
s->lookup.in.domain_name = s->domain_name;
-   
+
+   /* send the request */
lookup_req = libnet_LookupName_send(s->ctx, c, &s->lookup, 
s->monitor_fn);
if (composite_nomem(lookup_req, c)) return;

+   /* set the next stage */
composite_continue(c, lookup_req, continue_name_found, c);
 }
 
 
+/*
+ * Stage 1: Receive SID found and send request for group info
+ */
 static void continue_name_found(struct composite_context *ctx)
 {
struct composite_context *c;
@@ -113,27 +134,36 @@
 
c = talloc_get_type(ctx->async.private_data, struct composite_context);
s = talloc_get_type(c->private_data, struct group_info_state);
-   
+
+   /* receive SID assiociated with name found */
c->status = libnet_LookupName_recv(ctx, c, &s->lookup);
if (!composite_is_ok(c)) return;
-
+   
+   /* Is is a group SID actually ? */
if (s->lookup.out.sid_type != SID_NAME_DOM_GRP &&
s->lookup.out.sid_type != SID_NAME_ALIAS) {
composite_error(c, NT_STATUS_NO_SUCH_GROUP);
}
 
+   /* prepare arguments for groupinfo call */
s->info.in.domain_handle = s->ctx->samr.handle;
s->info.in.groupname = s->group_name;
s->info.in.sid   = s->lookup.out.sidstr;
+   /* we're looking for all information available */
s->info.in.level = GROUPINFOALL;
-   
+
+   /* send the request */
info_req = libnet_rpc_groupinfo_send(s->ctx->samr.pipe, &s->info, 
s->monitor_fn);
if (composite_nomem(info_req, c)) return;
 
+   /* set the next stage */
composite_continue(c, info_req, continue_group_info, c);
 }
 
 
+/*
+ * Stage 2: Receive group information
+ */
 static void continue_group_info(struct composite_context *ctx)
 {
struct composite_context *c;
@@ -142,13 +172,23 @@
c = talloc_get_type(ctx->async.private_data, struct composite_context);
s = talloc_get_type(c->private_data, struct group_info_state);
 
+   /* receive group i

svn commit: samba r24734 - in branches: SAMBA_3_2/source/nsswitch SAMBA_3_2_0/source/nsswitch

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 12:49:46 + (Tue, 28 Aug 2007)
New Revision: 24734

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

Log:
Move nss_err_str() to a more public place.

Guenther

Modified:
   branches/SAMBA_3_2/source/nsswitch/wb_common.c
   branches/SAMBA_3_2/source/nsswitch/winbind_client.h
   branches/SAMBA_3_2/source/nsswitch/winbind_nss_linux.c
   branches/SAMBA_3_2_0/source/nsswitch/wb_common.c
   branches/SAMBA_3_2_0/source/nsswitch/winbind_client.h
   branches/SAMBA_3_2_0/source/nsswitch/winbind_nss_linux.c


Changeset:
Modified: branches/SAMBA_3_2/source/nsswitch/wb_common.c
===
--- branches/SAMBA_3_2/source/nsswitch/wb_common.c  2007-08-28 12:40:01 UTC 
(rev 24733)
+++ branches/SAMBA_3_2/source/nsswitch/wb_common.c  2007-08-28 12:49:46 UTC 
(rev 24734)
@@ -673,3 +673,23 @@
return putenv(s) != -1;
 }
 
+/*
+ /
+
+const char *nss_err_str(NSS_STATUS ret)
+{
+   switch (ret) {
+   case NSS_STATUS_TRYAGAIN:
+   return "NSS_STATUS_TRYAGAIN";
+   case NSS_STATUS_SUCCESS:
+   return "NSS_STATUS_SUCCESS";
+   case NSS_STATUS_NOTFOUND:
+   return "NSS_STATUS_NOTFOUND";
+   case NSS_STATUS_UNAVAIL:
+   return "NSS_STATUS_UNAVAIL";
+   case NSS_STATUS_RETURN:
+   return "NSS_STATUS_RETURN";
+   default:
+   return "UNKNOWN RETURN CODE!!!";
+   }
+}

Modified: branches/SAMBA_3_2/source/nsswitch/winbind_client.h
===
--- branches/SAMBA_3_2/source/nsswitch/winbind_client.h 2007-08-28 12:40:01 UTC 
(rev 24733)
+++ branches/SAMBA_3_2/source/nsswitch/winbind_client.h 2007-08-28 12:49:46 UTC 
(rev 24734)
@@ -15,4 +15,5 @@
 int read_reply(struct winbindd_response *response);
 void close_sock(void);
 void free_response(struct winbindd_response *response);
+const char *nss_err_str(NSS_STATUS ret);
 

Modified: branches/SAMBA_3_2/source/nsswitch/winbind_nss_linux.c
===
--- branches/SAMBA_3_2/source/nsswitch/winbind_nss_linux.c  2007-08-28 
12:40:01 UTC (rev 24733)
+++ branches/SAMBA_3_2/source/nsswitch/winbind_nss_linux.c  2007-08-28 
12:49:46 UTC (rev 24734)
@@ -67,25 +67,6 @@
 
 extern int winbindd_fd;
 
-#ifdef DEBUG_NSS
-static const char *nss_err_str(NSS_STATUS ret) {
-   switch (ret) {
-   case NSS_STATUS_TRYAGAIN:
-   return "NSS_STATUS_TRYAGAIN";
-   case NSS_STATUS_SUCCESS:
-   return "NSS_STATUS_SUCCESS";
-   case NSS_STATUS_NOTFOUND:
-   return "NSS_STATUS_NOTFOUND";
-   case NSS_STATUS_UNAVAIL:
-   return "NSS_STATUS_UNAVAIL";
-   case NSS_STATUS_RETURN:
-   return "NSS_STATUS_RETURN";
-   default:
-   return "UNKNOWN RETURN CODE!!!";
-   }
-}
-#endif
-
 /* Allocate some space from the nss static buffer.  The buffer and buflen
are the pointers passed in by the C library to the _nss_ntdom_*
functions. */

Modified: branches/SAMBA_3_2_0/source/nsswitch/wb_common.c
===
--- branches/SAMBA_3_2_0/source/nsswitch/wb_common.c2007-08-28 12:40:01 UTC 
(rev 24733)
+++ branches/SAMBA_3_2_0/source/nsswitch/wb_common.c2007-08-28 12:49:46 UTC 
(rev 24734)
@@ -673,3 +673,23 @@
return putenv(s) != -1;
 }
 
+/*
+ /
+
+const char *nss_err_str(NSS_STATUS ret)
+{
+   switch (ret) {
+   case NSS_STATUS_TRYAGAIN:
+   return "NSS_STATUS_TRYAGAIN";
+   case NSS_STATUS_SUCCESS:
+   return "NSS_STATUS_SUCCESS";
+   case NSS_STATUS_NOTFOUND:
+   return "NSS_STATUS_NOTFOUND";
+   case NSS_STATUS_UNAVAIL:
+   return "NSS_STATUS_UNAVAIL";
+   case NSS_STATUS_RETURN:
+   return "NSS_STATUS_RETURN";
+   default:
+   return "UNKNOWN RETURN CODE!!!";
+   }
+}

Modified: branches/SAMBA_3_2_0/source/nsswitch/winbind_client.h
===
--- branches/SAMBA_3_2_0/source/nsswitch/winbind_client.h   2007-08-28 
12:40:01 UTC (rev 24733)
+++ branches/SAMBA_3_2_0/source/nsswitch/winbind_client.h   2007-08-28 
12:49:46 UTC (rev 24734)
@@ -15,4 +15,5 @@
 int read_

svn commit: samba r24735 - in branches/SAMBA_4_0: . source/torture source/torture/basic source/torture/libnet source/torture/raw source/torture/rpc

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-28 12:54:27 + (Tue, 28 Aug 2007)
New Revision: 24735

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

Log:
Use torture API in more places.

Removed:
   branches/SAMBA_4_0/source/torture/rpc/dcom.c
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/torture/basic/base.c
   branches/SAMBA_4_0/source/torture/config.mk
   branches/SAMBA_4_0/source/torture/libnet/domain.c
   branches/SAMBA_4_0/source/torture/libnet/groupinfo.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_group.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_share.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_user.c
   branches/SAMBA_4_0/source/torture/libnet/userinfo.c
   branches/SAMBA_4_0/source/torture/libnet/userman.c
   branches/SAMBA_4_0/source/torture/raw/acls.c
   branches/SAMBA_4_0/source/torture/raw/chkpath.c
   branches/SAMBA_4_0/source/torture/raw/close.c
   branches/SAMBA_4_0/source/torture/raw/composite.c
   branches/SAMBA_4_0/source/torture/raw/context.c
   branches/SAMBA_4_0/source/torture/raw/eas.c
   branches/SAMBA_4_0/source/torture/raw/ioctl.c
   branches/SAMBA_4_0/source/torture/raw/lock.c
   branches/SAMBA_4_0/source/torture/raw/mkdir.c
   branches/SAMBA_4_0/source/torture/raw/mux.c
   branches/SAMBA_4_0/source/torture/raw/notify.c
   branches/SAMBA_4_0/source/torture/raw/open.c
   branches/SAMBA_4_0/source/torture/raw/oplock.c
   branches/SAMBA_4_0/source/torture/raw/qfileinfo.c
   branches/SAMBA_4_0/source/torture/raw/qfsinfo.c
   branches/SAMBA_4_0/source/torture/raw/raw.c
   branches/SAMBA_4_0/source/torture/raw/read.c
   branches/SAMBA_4_0/source/torture/raw/rename.c
   branches/SAMBA_4_0/source/torture/raw/search.c
   branches/SAMBA_4_0/source/torture/raw/seek.c
   branches/SAMBA_4_0/source/torture/raw/setfileinfo.c
   branches/SAMBA_4_0/source/torture/raw/streams.c
   branches/SAMBA_4_0/source/torture/raw/unlink.c
   branches/SAMBA_4_0/source/torture/raw/write.c
   branches/SAMBA_4_0/source/torture/rpc/alter_context.c
   branches/SAMBA_4_0/source/torture/rpc/bench.c
   branches/SAMBA_4_0/source/torture/rpc/bind.c
   branches/SAMBA_4_0/source/torture/rpc/drsuapi.c
   branches/SAMBA_4_0/source/torture/rpc/dssetup.c
   branches/SAMBA_4_0/source/torture/rpc/epmapper.c
   branches/SAMBA_4_0/source/torture/rpc/handles.c
   branches/SAMBA_4_0/source/torture/rpc/initshutdown.c
   branches/SAMBA_4_0/source/torture/rpc/lsa.c
   branches/SAMBA_4_0/source/torture/rpc/lsa_lookup.c
   branches/SAMBA_4_0/source/torture/rpc/mgmt.c
   branches/SAMBA_4_0/source/torture/rpc/netlogon.c
   branches/SAMBA_4_0/source/torture/rpc/oxidresolve.c
   branches/SAMBA_4_0/source/torture/rpc/remact.c
   branches/SAMBA_4_0/source/torture/rpc/rot.c
   branches/SAMBA_4_0/source/torture/rpc/rpc.c
   branches/SAMBA_4_0/source/torture/rpc/samba3rpc.c
   branches/SAMBA_4_0/source/torture/rpc/samlogon.c
   branches/SAMBA_4_0/source/torture/rpc/samsync.c
   branches/SAMBA_4_0/source/torture/rpc/scanner.c
   branches/SAMBA_4_0/source/torture/rpc/session_key.c
   branches/SAMBA_4_0/source/torture/rpc/spoolss.c
   branches/SAMBA_4_0/source/torture/rpc/srvsvc.c
   branches/SAMBA_4_0/source/torture/rpc/svcctl.c
   branches/SAMBA_4_0/source/torture/rpc/testjoin.c


Changeset:
Sorry, the patch is too large (3509 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24735


svn commit: samba r24733 - in branches: SAMBA_3_2/source/lib SAMBA_3_2/source/torture SAMBA_3_2_0/source/lib SAMBA_3_2_0/source/torture

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 12:40:01 + (Tue, 28 Aug 2007)
New Revision: 24733

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

Log:
Add support for storing DATA_BLOBs in gencache.tdb (including torturetest).

Mimir, please have a look. DATA_BLOBs will now just show up as "DATA_BLOB"
values with "net cache list".

Guenther


Modified:
   branches/SAMBA_3_2/source/lib/gencache.c
   branches/SAMBA_3_2/source/torture/torture.c
   branches/SAMBA_3_2_0/source/lib/gencache.c
   branches/SAMBA_3_2_0/source/torture/torture.c


Changeset:
Modified: branches/SAMBA_3_2/source/lib/gencache.c
===
--- branches/SAMBA_3_2/source/lib/gencache.c2007-08-28 09:57:47 UTC (rev 
24732)
+++ branches/SAMBA_3_2/source/lib/gencache.c2007-08-28 12:40:01 UTC (rev 
24733)
@@ -28,6 +28,8 @@
 #define TIMEOUT_LEN 12
 #define CACHE_DATA_FMT "%12u/%s"
 #define READ_CACHE_DATA_FMT_TEMPLATE "%%12u/%%%us"
+#define BLOB_TYPE "DATA_BLOB"
+#define BLOB_TYPE_LEN 9
 
 static TDB_CONTEXT *cache;
 static BOOL cache_readonly;
@@ -243,8 +245,163 @@
return True;
 } 
 
+/**
+ * Get existing entry from the cache file.
+ *
+ * @param keystr string that represents a key of this entry
+ * @param blob DATA_BLOB that is filled with entry's blob
+ * @param expired pointer to a BOOL that indicates whether the entry is expired
+ *
+ * @retval true when entry is successfuly fetched
+ * @retval False for failure
+ **/
 
+BOOL gencache_get_data_blob(const char *keystr, DATA_BLOB *blob, BOOL *expired)
+{
+   TDB_DATA databuf;
+   time_t t;
+   char *blob_type;
+   unsigned char *buf = NULL;
+   BOOL ret = False;
+   fstring valstr;
+   int buflen = 0, len = 0, blob_len = 0;
+   unsigned char *blob_buf = NULL;
+
+   /* fail completely if get null pointers passed */
+   SMB_ASSERT(keystr);
+
+   if (!gencache_init()) {
+   return False;
+   }
+
+   databuf = tdb_fetch_bystring(cache, keystr);
+   if (!databuf.dptr) {
+   DEBUG(10,("Cache entry with key = %s couldn't be found\n",
+ keystr));
+   return False;
+   }
+
+   buf = (unsigned char *)databuf.dptr;
+   buflen = databuf.dsize;
+
+   len += tdb_unpack(buf+len, buflen-len, "fB",
+ &valstr,
+ &blob_len, &blob_buf);
+   if (len == -1) {
+   goto out;
+   }
+
+   t = strtol(valstr, &blob_type, 10);
+
+   if (strcmp(blob_type+1, BLOB_TYPE) != 0) {
+   goto out;
+   }
+
+   DEBUG(10,("Returning %s cache entry: key = %s, "
+ "timeout = %s", t > time(NULL) ? "valid" :
+ "expired", keystr, ctime(&t)));
+
+   if (t <= time(NULL)) {
+   /* We're expired */
+   if (expired) {
+   *expired = True;
+   }
+   }
+
+   if (blob) {
+   *blob = data_blob(blob_buf, blob_len);
+   if (!blob->data) {
+   goto out;
+   }
+   }
+
+   ret = True;
+ out:
+   SAFE_FREE(blob_buf);
+   SAFE_FREE(databuf.dptr);
+
+   return ret;
+}
+
 /**
+ * Set an entry in the cache file. If there's no such
+ * one, then add it.
+ *
+ * @param keystr string that represents a key of this entry
+ * @param blob DATA_BLOB value being cached
+ * @param timeout time when the value is expired
+ *
+ * @retval true when entry is successfuly stored
+ * @retval false on failure
+ **/
+
+BOOL gencache_set_data_blob(const char *keystr, DATA_BLOB *blob, time_t 
timeout)
+{
+   BOOL ret = False;
+   int tdb_ret;
+   TDB_DATA databuf;
+   char *valstr = NULL;
+   unsigned char *buf = NULL;
+   int len = 0, buflen = 0;
+
+   /* fail completely if get null pointers passed */
+   SMB_ASSERT(keystr && blob);
+
+   if (!gencache_init()) {
+   return False;
+   }
+
+   if (cache_readonly) {
+   return False;
+   }
+
+   asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE);
+   if (!valstr) {
+   return False;
+   }
+
+ again:
+   len = 0;
+
+   len += tdb_pack(buf+len, buflen-len, "fB",
+   valstr,
+   blob->length, blob->data);
+
+   if (len == -1) {
+   goto out;
+   }
+
+   if (buflen < len) {
+   SAFE_FREE(buf);
+   buf = SMB_MALLOC_ARRAY(unsigned char, len);
+   if (!buf) {
+   goto out;
+   }
+   buflen = len;
+   goto again;
+   }
+
+   databuf = make_tdb_data(buf, len);
+
+   DEBUG(10,("Adding cache entry with key = %s; "
+ "blob size = %d and timeout = %s"
+ "(%d seconds %s)\n", keystr, (int)databuf.dsize,
+ ctime(&timeout), (int)(timeout - t

svn commit: samba r24736 - in branches/SAMBA_4_0: . source/torture/rpc

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-28 13:49:34 + (Tue, 28 Aug 2007)
New Revision: 24736

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

Log:
Convert to using torture API.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/torture/rpc/rpc.c
   branches/SAMBA_4_0/source/torture/rpc/srvsvc.c


Changeset:
Sorry, the patch is too large (785 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24736


svn commit: samba r24739 - in branches: SAMBA_3_2/source/libads SAMBA_3_2/source/libsmb SAMBA_3_2_0/source/libads SAMBA_3_2_0/source/libsmb

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 14:27:48 + (Tue, 28 Aug 2007)
New Revision: 24739

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

Log:
With resolve_ads() allow to query for PDCs as well.
Also add dns query functions to find GCs and DCs by GUID.

Guenther

Modified:
   branches/SAMBA_3_2/source/libads/dns.c
   branches/SAMBA_3_2/source/libsmb/namequery.c
   branches/SAMBA_3_2_0/source/libads/dns.c
   branches/SAMBA_3_2_0/source/libsmb/namequery.c


Changeset:
Modified: branches/SAMBA_3_2/source/libads/dns.c
===
--- branches/SAMBA_3_2/source/libads/dns.c  2007-08-28 14:25:46 UTC (rev 
24738)
+++ branches/SAMBA_3_2/source/libads/dns.c  2007-08-28 14:27:48 UTC (rev 
24739)
@@ -740,21 +740,23 @@
  Query with optional sitename.
 /
 
-NTSTATUS ads_dns_query_internal(TALLOC_CTX *ctx,
-   const char *servicename,
-   const char *realm,
-   const char *sitename,
-   struct dns_rr_srv **dclist,
-   int *numdcs )
+static NTSTATUS ads_dns_query_internal(TALLOC_CTX *ctx,
+  const char *servicename,
+  const char *dc_pdc_gc_domains,
+  const char *realm,
+  const char *sitename,
+  struct dns_rr_srv **dclist,
+  int *numdcs )
 {
char *name;
if (sitename) {
-   name = talloc_asprintf(ctx, "%s._tcp.%s._sites.dc._msdcs.%s",
-   servicename, sitename, realm );
-   } else {
-   name = talloc_asprintf(ctx, "%s._tcp.dc._msdcs.%s",
-   servicename, realm );
-   }
+   name = talloc_asprintf(ctx, "%s._tcp.%s._sites.%s._msdcs.%s",
+  servicename, sitename,
+  dc_pdc_gc_domains, realm);
+   } else {
+   name = talloc_asprintf(ctx, "%s._tcp.%s._msdcs.%s",
+   servicename, dc_pdc_gc_domains, realm);
+   }
if (!name) {
return NT_STATUS_NO_MEMORY;
}
@@ -766,14 +768,14 @@
 /
 
 NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
-   const char *realm,
-   const char *sitename,
-   struct dns_rr_srv **dclist,
-   int *numdcs )
+  const char *realm,
+  const char *sitename,
+  struct dns_rr_srv **dclist,
+  int *numdcs )
 {
NTSTATUS status;
 
-   status = ads_dns_query_internal(ctx, "_ldap", realm, sitename,
+   status = ads_dns_query_internal(ctx, "_ldap", "dc", realm, sitename,
dclist, numdcs);
 
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
@@ -781,40 +783,119 @@
return status;
}
 
-   if (sitename && !NT_STATUS_IS_OK(status)) {
+   if (sitename &&
+   ((!NT_STATUS_IS_OK(status)) ||
+(NT_STATUS_IS_OK(status) && (numdcs == 0 {
/* Sitename DNS query may have failed. Try without. */
-   status = ads_dns_query_internal(ctx, "_ldap", realm, NULL,
-   dclist, numdcs);
+   status = ads_dns_query_internal(ctx, "_ldap", "dc", realm,
+   NULL, dclist, numdcs);
}
return status;
 }
 
 /
+ Query for AD GC's.
+/
+
+NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
+  const char *realm,
+  const char *sitename,
+  struct dns_rr_srv **dclist,
+  int *numdcs )
+{
+   NTSTATUS status;
+
+   status = ads_dns_query_internal(ctx, "_ldap", "gc", realm, sitename,
+   dclist, numdcs);
+
+   if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
+   NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_REFUSED)) {
+   return status;
+   }
+
+   if (sitename &&
+   ((!NT_STATUS_IS_OK(status)) ||
+(NT_STATUS_IS_OK(status) && (numdcs == 0 {
+   /* Sitename DNS query may have failed. Try without. */
+   status = ads_dns_query_internal(ctx, "_ldap", "gc", realm,
+   NULL, dclist, numdcs);
+   }
+   r

svn commit: samba r24738 - in branches: SAMBA_3_0_25/source/tdb/common SAMBA_3_2/source/lib/tdb/common SAMBA_3_2_0/source/lib/tdb/common SAMBA_4_0/source/lib/tdb/common

2007-08-28 Thread obnox
Author: obnox
Date: 2007-08-28 14:25:46 + (Tue, 28 Aug 2007)
New Revision: 24738

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

Log:
Fix one more use of pwrite in tdb code in the spirit of r23972 and r23977.

Michael


Modified:
   branches/SAMBA_3_0_25/source/tdb/common/io.c
   branches/SAMBA_3_2/source/lib/tdb/common/io.c
   branches/SAMBA_3_2_0/source/lib/tdb/common/io.c
   branches/SAMBA_4_0/source/lib/tdb/common/io.c


Changeset:
Modified: branches/SAMBA_3_0_25/source/tdb/common/io.c
===
--- branches/SAMBA_3_0_25/source/tdb/common/io.c2007-08-28 14:20:53 UTC 
(rev 24737)
+++ branches/SAMBA_3_0_25/source/tdb/common/io.c2007-08-28 14:25:46 UTC 
(rev 24738)
@@ -89,12 +89,31 @@
 
if (tdb->map_ptr) {
memcpy(off + (char *)tdb->map_ptr, buf, len);
-   } else if (pwrite(tdb->fd, buf, len, off) != (ssize_t)len) {
-   /* Ensure ecode is set for log fn. */
-   tdb->ecode = TDB_ERR_IO;
-   TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d len=%d 
(%s)\n",
-  off, len, strerror(errno)));
-   return TDB_ERRCODE(TDB_ERR_IO, -1);
+   } else {
+   ssize_t written = pwrite(tdb->fd, buf, len, off);
+   if ((written != (ssize_t)len) && (written != -1)) {
+   /* try once more */
+   TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only "
+"%d of %d bytes at %d, trying once more\n",
+written, len, off));
+   errno = ENOSPC;
+   written = pwrite(tdb->fd, (void *)((char *)buf+written),
+len-written,
+off+written);
+   }
+   if (written == -1) {
+   /* Ensure ecode is set for log fn. */
+   tdb->ecode = TDB_ERR_IO;
+   TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d "
+"len=%d (%s)\n", off, len, strerror(errno)));
+   return TDB_ERRCODE(TDB_ERR_IO, -1);
+   } else if (written != (ssize_t)len) {
+   TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: failed to "
+"write %d bytes at %d in two attempts\n",
+len, off));
+   errno = ENOSPC;
+   return TDB_ERRCODE(TDB_ERR_IO, -1);
+   }
}
return 0;
 }

Modified: branches/SAMBA_3_2/source/lib/tdb/common/io.c
===
--- branches/SAMBA_3_2/source/lib/tdb/common/io.c   2007-08-28 14:20:53 UTC 
(rev 24737)
+++ branches/SAMBA_3_2/source/lib/tdb/common/io.c   2007-08-28 14:25:46 UTC 
(rev 24738)
@@ -88,12 +88,31 @@
 
if (tdb->map_ptr) {
memcpy(off + (char *)tdb->map_ptr, buf, len);
-   } else if (pwrite(tdb->fd, buf, len, off) != (ssize_t)len) {
-   /* Ensure ecode is set for log fn. */
-   tdb->ecode = TDB_ERR_IO;
-   TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d len=%d 
(%s)\n",
-  off, len, strerror(errno)));
-   return TDB_ERRCODE(TDB_ERR_IO, -1);
+   } else {
+   ssize_t written = pwrite(tdb->fd, buf, len, off);
+   if ((written != (ssize_t)len) && (written != -1)) {
+   /* try once more */
+   TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only "
+"%d of %d bytes at %d, trying once more\n",
+written, len, off));
+   errno = ENOSPC;
+   written = pwrite(tdb->fd, (void *)((char *)buf+written),
+len-written,
+off+written);
+   }
+   if (written == -1) {
+   /* Ensure ecode is set for log fn. */
+   tdb->ecode = TDB_ERR_IO;
+   TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_write failed at %d "
+"len=%d (%s)\n", off, len, strerror(errno)));
+   return TDB_ERRCODE(TDB_ERR_IO, -1);
+   } else if (written != (ssize_t)len) {
+   TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: failed to "
+"write %d bytes at %d in two attempts\n",
+len, off));
+   errno = ENOSPC;
+   return TDB_ERRCODE(TDB_ERR_IO, -1);
+   }
}
return 0;
 }

Modified: branches/SAMBA_3_2_0/source/lib/tdb/common/io.c
===

svn commit: samba r24737 - in branches: SAMBA_3_2/source/libsmb SAMBA_3_2/source/nsswitch SAMBA_3_2_0/source/libsmb SAMBA_3_2_0/source/nsswitch

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 14:20:53 + (Tue, 28 Aug 2007)
New Revision: 24737

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

Log:
Remove older TODO: Convert internal_resolve_name() and friends to NTSTATUS.

Guenther

Modified:
   branches/SAMBA_3_2/source/libsmb/cliconnect.c
   branches/SAMBA_3_2/source/libsmb/namequery.c
   branches/SAMBA_3_2/source/nsswitch/winbindd_wins.c
   branches/SAMBA_3_2/source/nsswitch/wins.c
   branches/SAMBA_3_2_0/source/libsmb/cliconnect.c
   branches/SAMBA_3_2_0/source/libsmb/namequery.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_wins.c
   branches/SAMBA_3_2_0/source/nsswitch/wins.c


Changeset:
Sorry, the patch is too large (1213 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24737


svn commit: samba r24741 - in branches/SAMBA_4_0: . source source/selftest source/torture source/torture/raw source/torture/rpc

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-28 14:42:37 + (Tue, 28 Aug 2007)
New Revision: 24741

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

Log:
More use of the torture API.

Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/samba4-knownfail
   branches/SAMBA_4_0/source/selftest/selftest.pl
   branches/SAMBA_4_0/source/torture/raw/write.c
   branches/SAMBA_4_0/source/torture/rpc/handles.c
   branches/SAMBA_4_0/source/torture/rpc/initshutdown.c
   branches/SAMBA_4_0/source/torture/rpc/rpc.c
   branches/SAMBA_4_0/source/torture/rpc/srvsvc.c
   branches/SAMBA_4_0/source/torture/rpc/winreg.c
   branches/SAMBA_4_0/source/torture/smbtorture.c
   branches/SAMBA_4_0/source/torture/ui.c
   branches/SAMBA_4_0/source/torture/util.c


Changeset:

Property changes on: branches/SAMBA_4_0
___
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/samba4-knownfail
===
--- branches/SAMBA_4_0/source/samba4-knownfail  2007-08-28 14:31:31 UTC (rev 
24740)
+++ branches/SAMBA_4_0/source/samba4-knownfail  2007-08-28 14:42:37 UTC (rev 
24741)
@@ -8,3 +8,5 @@
 LOCAL-REGISTRY/security # Not implemented yet
 RPC-WKSSVC.*NetWkstaGetInfo
 RPC-WKSSVC.*NetWkstaTransportEnum
+RPC-HANDLES.*/lsarpc-shared
+RPC-HANDLES.*/mixed-shared

Modified: branches/SAMBA_4_0/source/selftest/selftest.pl
===
--- branches/SAMBA_4_0/source/selftest/selftest.pl  2007-08-28 14:31:31 UTC 
(rev 24740)
+++ branches/SAMBA_4_0/source/selftest/selftest.pl  2007-08-28 14:42:37 UTC 
(rev 24741)
@@ -504,6 +504,7 @@
 # ensure any one smbtorture call doesn't run too long
 push (@torture_options, "--maximum-runtime=$torture_maxtime");
 push (@torture_options, "--target=$opt_target");
+push (@torture_options, "--basedir=$prefix");
 push (@torture_options, "--option=torture:progress=no") if ($opt_format eq 
"buildfarm");
 push (@torture_options, "--format=subunit");
 push (@torture_options, "--option=torture:quick=yes") if ($opt_quick);

Modified: branches/SAMBA_4_0/source/torture/raw/write.c
===
--- branches/SAMBA_4_0/source/torture/raw/write.c   2007-08-28 14:31:31 UTC 
(rev 24740)
+++ branches/SAMBA_4_0/source/torture/raw/write.c   2007-08-28 14:42:37 UTC 
(rev 24741)
@@ -237,9 +237,9 @@
union smb_fileinfo finfo;
int max_bits=63;
 
-   if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
+   if (!torture_setting_bool(tctx, "dangerous", false)) {
max_bits=33;
-   printf("dangerous not set - limiting range of test to 2^%d\n", 
max_bits);
+   torture_comment(tctx, "dangerous not set - limiting range of 
test to 2^%d\n", max_bits);
}
 
buf = talloc_zero_size(tctx, maxsize);

Modified: branches/SAMBA_4_0/source/torture/rpc/handles.c
===
--- branches/SAMBA_4_0/source/torture/rpc/handles.c 2007-08-28 14:31:31 UTC 
(rev 24740)
+++ branches/SAMBA_4_0/source/torture/rpc/handles.c 2007-08-28 14:42:37 UTC 
(rev 24741)
@@ -116,11 +116,6 @@
 
torture_comment(torture, "RPC-HANDLE-LSARPC-SHARED\n");
 
-   if (torture_setting_bool(torture, "samba4", false)) {
-   torture_comment(torture, "LSA shared-policy-handle test against 
Samba4 - skipping\n");
-   return true;
-   }
-
torture_comment(torture, "connect lsa pipe1\n");
status = torture_rpc_connection(torture, &p1, &ndr_table_lsarpc);
torture_assert_ntstatus_ok(torture, status, "opening lsa pipe1");
@@ -399,11 +394,6 @@
 
torture_comment(torture, "RPC-HANDLE-MIXED-SHARED\n");
 
-   if (torture_setting_bool(torture, "samba4", false)) {
-   torture_comment(torture, "Mixed shared-policy-handle test 
against Samba4 - skipping\n");
-   return true;
-   }
-
torture_comment(torture, "connect samr pipe1\n");
status = torture_rpc_connection(torture, &p1, &ndr_table_samr);
torture_assert_ntstatus_ok(torture, status, "opening samr pipe1");

Modified: branches/SAMBA_4_0/source/torture/rpc/initshutdown.c
===
--- branches/SAMBA_4_0/source/torture/rpc/initshutdown.c2007-08-28 
14:31:31 UTC (rev 24740)
+++ branches/SAMBA_4_0/source/torture/rpc/initshutdown.c2007-08-28 
14:42:37 UTC (rev 24741)
@@ -129,7 +129,8 @@
}
 
if (!torture_setting_bool(torture, "dangerous", False)) {
-   printf("initshutdown tests disabled - enable dangerous tests to 
use\n");
+   torture_comment(torture, 
+   "initshutdown tests disabled - 
enable dangerous tests

svn commit: samba r24740 - in branches: SAMBA_3_2/source/nsswitch SAMBA_3_2_0/source/nsswitch

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 14:31:31 + (Tue, 28 Aug 2007)
New Revision: 24740

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

Log:
Fix the build.

Guenther

Modified:
   branches/SAMBA_3_2/source/nsswitch/wb_common.c
   branches/SAMBA_3_2_0/source/nsswitch/wb_common.c


Changeset:
Modified: branches/SAMBA_3_2/source/nsswitch/wb_common.c
===
--- branches/SAMBA_3_2/source/nsswitch/wb_common.c  2007-08-28 14:27:48 UTC 
(rev 24739)
+++ branches/SAMBA_3_2/source/nsswitch/wb_common.c  2007-08-28 14:31:31 UTC 
(rev 24740)
@@ -687,8 +687,10 @@
return "NSS_STATUS_NOTFOUND";
case NSS_STATUS_UNAVAIL:
return "NSS_STATUS_UNAVAIL";
+#ifdef NSS_STATUS_RETURN
case NSS_STATUS_RETURN:
return "NSS_STATUS_RETURN";
+#endif
default:
return "UNKNOWN RETURN CODE!!!";
}

Modified: branches/SAMBA_3_2_0/source/nsswitch/wb_common.c
===
--- branches/SAMBA_3_2_0/source/nsswitch/wb_common.c2007-08-28 14:27:48 UTC 
(rev 24739)
+++ branches/SAMBA_3_2_0/source/nsswitch/wb_common.c2007-08-28 14:31:31 UTC 
(rev 24740)
@@ -687,8 +687,10 @@
return "NSS_STATUS_NOTFOUND";
case NSS_STATUS_UNAVAIL:
return "NSS_STATUS_UNAVAIL";
+#ifdef NSS_STATUS_RETURN
case NSS_STATUS_RETURN:
return "NSS_STATUS_RETURN";
+#endif
default:
return "UNKNOWN RETURN CODE!!!";
}



svn commit: samba r24746 - in branches: SAMBA_3_2/source/nsswitch SAMBA_3_2_0/source/nsswitch

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 15:16:42 + (Tue, 28 Aug 2007)
New Revision: 24746

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

Log:
As the winbindd pipe is officially broken since a while: split out request
specfic and generic flags in a winbindd_request.

It turns out that the WBFLAG_RECURSE flag is the only non-PAM specific flag we
put into the "flags" field of a winbind request anyway. Now each request
command can use the entire space of the "flags" field.

Guenther

Modified:
   branches/SAMBA_3_2/source/nsswitch/wb_common.c
   branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h
   branches/SAMBA_3_2_0/source/nsswitch/wb_common.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_nss.h


Changeset:
Modified: branches/SAMBA_3_2/source/nsswitch/wb_common.c
===
--- branches/SAMBA_3_2/source/nsswitch/wb_common.c  2007-08-28 15:12:11 UTC 
(rev 24745)
+++ branches/SAMBA_3_2/source/nsswitch/wb_common.c  2007-08-28 15:16:42 UTC 
(rev 24746)
@@ -320,7 +320,7 @@
 
/* version-check the socket */
 
-   request.flags = WBFLAG_RECURSE;
+   request.wb_flags = WBFLAG_RECURSE;
if ((winbindd_request_response(WINBINDD_INTERFACE_VERSION, &request, 
&response) != NSS_STATUS_SUCCESS) || (response.data.interface_version != 
WINBIND_INTERFACE_VERSION)) {
close_sock();
return -1;
@@ -328,7 +328,7 @@
 
/* try and get priv pipe */
 
-   request.flags = WBFLAG_RECURSE;
+   request.wb_flags = WBFLAG_RECURSE;
if (winbindd_request_response(WINBINDD_PRIV_PIPE_DIR, &request, 
&response) == NSS_STATUS_SUCCESS) {
int fd;
if ((fd = winbind_named_pipe_sock((char 
*)response.extra_data.data)) != -1) {
@@ -567,13 +567,13 @@
init_request(request, req_type);

if (write_sock(request, sizeof(*request),
-  request->flags & WBFLAG_RECURSE, need_priv) == -1) {
+  request->wb_flags & WBFLAG_RECURSE, need_priv) == -1) {
return NSS_STATUS_UNAVAIL;
}
 
if ((request->extra_len != 0) &&
(write_sock(request->extra_data.data, request->extra_len,
-   request->flags & WBFLAG_RECURSE, need_priv) == -1)) {
+   request->wb_flags & WBFLAG_RECURSE, need_priv) == -1)) {
return NSS_STATUS_UNAVAIL;
}


Modified: branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h
===
--- branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h   2007-08-28 15:12:11 UTC 
(rev 24745)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h   2007-08-28 15:16:42 UTC 
(rev 24746)
@@ -42,7 +42,7 @@
 
 /* Update this when you change the interface.  */
 
-#define WINBIND_INTERFACE_VERSION 18
+#define WINBIND_INTERFACE_VERSION 19
 
 /* Have to deal with time_t being 4 or 8 bytes due to structure alignment.
On a 64bit Linux box, we have to support a constant structure size
@@ -194,26 +194,27 @@
uint32 gr_mem_ofs;   /* offset to group membership */
 } WINBINDD_GR;
 
-
+/* PAM specific request flags */
 #define WBFLAG_PAM_INFO3_NDR   0x0001
 #define WBFLAG_PAM_INFO3_TEXT  0x0002
 #define WBFLAG_PAM_USER_SESSION_KEY0x0004
 #define WBFLAG_PAM_LMKEY   0x0008
 #define WBFLAG_PAM_CONTACT_TRUSTDOM0x0010
-#define WBFLAG_QUERY_ONLY  0x0020
 #define WBFLAG_PAM_UNIX_NAME   0x0080
 #define WBFLAG_PAM_AFS_TOKEN   0x0100
 #define WBFLAG_PAM_NT_STATUS_SQUASH0x0200
+#define WBFLAG_PAM_KRB50x1000
+#define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x2000
+#define WBFLAG_PAM_CACHED_LOGIN0x4000
+#define WBFLAG_PAM_GET_PWD_POLICY  0x8000  /* not used */
 
+/* generic request flags */
+#define WBFLAG_QUERY_ONLY  0x0020  /* not used */
 /* This is a flag that can only be sent from parent to child */
-#define WBFLAG_IS_PRIVILEGED   0x0400
+#define WBFLAG_IS_PRIVILEGED   0x0400  /* not used */
 /* Flag to say this is a winbindd internal send - don't recurse. */
 #define WBFLAG_RECURSE 0x0800
 
-#define WBFLAG_PAM_KRB50x1000
-#define WBFLAG_PAM_FALLBACK_AFTER_KRB5 0x2000
-#define WBFLAG_PAM_CACHED_LOGIN0x4000
-#define WBFLAG_PAM_GET_PWD_POLICY  0x8000  /* not used */
 
 #define WINBINDD_MAX_EXTRA_DATA (128*1024)
 
@@ -233,7 +234,8 @@
enum winbindd_cmd original_cmd;   /* Original Winbindd command
 issued to parent process */
pid_t pid;   /* pid of calling process */
-   uint32 flags;/* flags relavant to a given request */
+   uint32 wb_flags; /* generic flags */
+   uint32 flag

svn commit: samba r24747 - in branches: SAMBA_3_2/source/nsswitch SAMBA_3_2_0/source/nsswitch

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 15:20:54 + (Tue, 28 Aug 2007)
New Revision: 24747

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

Log:
Add WINBINDD_DSGETDCNAME call.

Guenther

Modified:
   branches/SAMBA_3_2/source/nsswitch/wbinfo.c
   branches/SAMBA_3_2/source/nsswitch/winbindd.c
   branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c
   branches/SAMBA_3_2/source/nsswitch/winbindd_misc.c
   branches/SAMBA_3_2/source/nsswitch/winbindd_nss.h
   branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_dual.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_misc.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_nss.h


Changeset:
Modified: branches/SAMBA_3_2/source/nsswitch/wbinfo.c
===
--- branches/SAMBA_3_2/source/nsswitch/wbinfo.c 2007-08-28 15:16:42 UTC (rev 
24746)
+++ branches/SAMBA_3_2/source/nsswitch/wbinfo.c 2007-08-28 15:20:54 UTC (rev 
24747)
@@ -500,6 +500,35 @@
return True;
 }
 
+/* Find a DC */
+static BOOL wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)
+{
+   struct winbindd_request request;
+   struct winbindd_response response;
+
+   ZERO_STRUCT(request);
+   ZERO_STRUCT(response);
+
+   fstrcpy(request.domain_name, domain_name);
+   request.flags = flags;
+
+   request.flags |= DS_DIRECTORY_SERVICE_REQUIRED;
+
+   /* Send request */
+
+   if (winbindd_request_response(WINBINDD_DSGETDCNAME, &request, 
&response) !=
+   NSS_STATUS_SUCCESS) {
+   d_fprintf(stderr, "Could not find dc for %s\n", domain_name);
+   return False;
+   }
+
+   /* Display response */
+
+   d_printf("%s\n", response.data.dc_name);
+
+   return True;
+}
+
 /* Check trust account password */
 
 static BOOL wbinfo_check_secret(void)
@@ -1225,6 +1254,7 @@
OPT_DOMAIN_NAME,
OPT_SEQUENCE,
OPT_GETDCNAME,
+   OPT_DSGETDCNAME,
OPT_USERDOMGROUPS,
OPT_USERSIDS,
OPT_ALLOCATE_UID,
@@ -1284,6 +1314,7 @@
{ "set-auth-user", 0, POPT_ARG_STRING, &string_arg, 
OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", 
"user%password" },
{ "getdcname", 0, POPT_ARG_STRING, &string_arg, OPT_GETDCNAME,
  "Get a DC name for a foreign domain", "domainname" },
+   { "dsgetdcname", 0, POPT_ARG_STRING, &string_arg, 
OPT_DSGETDCNAME, "Find a DC for a domain", "domainname" },
{ "get-auth-user", 0, POPT_ARG_NONE, NULL, OPT_GET_AUTH_USER, 
"Retrieve user and password used by winbindd (root only)", NULL },
{ "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if 
it is alive" },
{ "domain", 0, POPT_ARG_STRING, &opt_domain_name, 
OPT_DOMAIN_NAME, "Define to the domain to restrict operation", "domain" },
@@ -1540,6 +1571,11 @@
goto done;
}
break;
+   case OPT_DSGETDCNAME:
+   if (!wbinfo_dsgetdcname(string_arg, 0)) {
+   goto done;
+   }
+   break;
case OPT_SEPARATOR: {
const char sep = winbind_separator_int(True);
if ( !sep ) {

Modified: branches/SAMBA_3_2/source/nsswitch/winbindd.c
===
--- branches/SAMBA_3_2/source/nsswitch/winbindd.c   2007-08-28 15:16:42 UTC 
(rev 24746)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd.c   2007-08-28 15:20:54 UTC 
(rev 24747)
@@ -282,6 +282,7 @@
{ WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir,
  "WINBINDD_PRIV_PIPE_DIR" },
{ WINBINDD_GETDCNAME, winbindd_getdcname, "GETDCNAME" },
+   { WINBINDD_DSGETDCNAME, winbindd_dsgetdcname, "DSGETDCNAME" },
 
/* Credential cache access */
{ WINBINDD_CCACHE_NTLMAUTH, winbindd_ccache_ntlm_auth, "NTLMAUTH" },

Modified: branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c
===
--- branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c  2007-08-28 15:16:42 UTC 
(rev 24746)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd_dual.c  2007-08-28 15:20:54 UTC 
(rev 24747)
@@ -423,6 +423,7 @@
{ WINBINDD_LIST_TRUSTDOM,winbindd_dual_list_trusted_domains,  
"LIST_TRUSTDOM" },
{ WINBINDD_INIT_CONNECTION,  winbindd_dual_init_connection,   
"INIT_CONNECTION" },
{ WINBINDD_GETDCNAME,winbindd_dual_getdcname, 
"GETDCNAME" },
+   { WINBINDD_DSGETDCNAME,  winbindd_dual_dsgetdcname,   
"DSGETDCNAME" },
{ WINBINDD_SHOW_SEQUENCE,winbindd_dual_show_sequence, 
"SHOW_SEQUENCE" },
{ WINBINDD_PAM_AUTH, winbi

svn commit: samba r24743 - in branches: SAMBA_3_2/source/lib/tdb/common SAMBA_3_2_0/source/lib/tdb/common

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 15:07:13 + (Tue, 28 Aug 2007)
New Revision: 24743

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

Log:
Fix build warning.

Guenther

Modified:
   branches/SAMBA_3_2/source/lib/tdb/common/io.c
   branches/SAMBA_3_2_0/source/lib/tdb/common/io.c


Changeset:
Modified: branches/SAMBA_3_2/source/lib/tdb/common/io.c
===
--- branches/SAMBA_3_2/source/lib/tdb/common/io.c   2007-08-28 15:01:23 UTC 
(rev 24742)
+++ branches/SAMBA_3_2/source/lib/tdb/common/io.c   2007-08-28 15:07:13 UTC 
(rev 24743)
@@ -94,7 +94,7 @@
/* try once more */
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only "
 "%d of %d bytes at %d, trying once more\n",
-written, len, off));
+(int)written, len, off));
errno = ENOSPC;
written = pwrite(tdb->fd, (void *)((char *)buf+written),
 len-written,

Modified: branches/SAMBA_3_2_0/source/lib/tdb/common/io.c
===
--- branches/SAMBA_3_2_0/source/lib/tdb/common/io.c 2007-08-28 15:01:23 UTC 
(rev 24742)
+++ branches/SAMBA_3_2_0/source/lib/tdb/common/io.c 2007-08-28 15:07:13 UTC 
(rev 24743)
@@ -94,7 +94,7 @@
/* try once more */
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_write: wrote only "
 "%d of %d bytes at %d, trying once more\n",
-written, len, off));
+(int)written, len, off));
errno = ENOSPC;
written = pwrite(tdb->fd, (void *)((char *)buf+written),
 len-written,



svn commit: samba r24744 - in branches: SAMBA_3_2/source/lib SAMBA_3_2_0/source/lib

2007-08-28 Thread vlendec
Author: vlendec
Date: 2007-08-28 15:09:47 + (Tue, 28 Aug 2007)
New Revision: 24744

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

Log:
Increase length by what we got from recv, not from ioctl

Modified:
   branches/SAMBA_3_2/source/lib/packet.c
   branches/SAMBA_3_2_0/source/lib/packet.c


Changeset:
Modified: branches/SAMBA_3_2/source/lib/packet.c
===
--- branches/SAMBA_3_2/source/lib/packet.c  2007-08-28 15:07:13 UTC (rev 
24743)
+++ branches/SAMBA_3_2/source/lib/packet.c  2007-08-28 15:09:47 UTC (rev 
24744)
@@ -83,6 +83,8 @@
return NT_STATUS_NO_MEMORY;
}
 
+   ctx->in.data = in;
+
res = recv(ctx->fd, in + ctx->in.length, available, 0);
 
if (res < 0) {
@@ -94,8 +96,7 @@
return NT_STATUS_END_OF_FILE;
}
 
-   ctx->in.data = in;
-   ctx->in.length += available;
+   ctx->in.length += res;
 
return NT_STATUS_OK;
 }

Modified: branches/SAMBA_3_2_0/source/lib/packet.c
===
--- branches/SAMBA_3_2_0/source/lib/packet.c2007-08-28 15:07:13 UTC (rev 
24743)
+++ branches/SAMBA_3_2_0/source/lib/packet.c2007-08-28 15:09:47 UTC (rev 
24744)
@@ -83,6 +83,8 @@
return NT_STATUS_NO_MEMORY;
}
 
+   ctx->in.data = in;
+
res = recv(ctx->fd, in + ctx->in.length, available, 0);
 
if (res < 0) {
@@ -94,8 +96,7 @@
return NT_STATUS_END_OF_FILE;
}
 
-   ctx->in.data = in;
-   ctx->in.length += available;
+   ctx->in.length += res;
 
return NT_STATUS_OK;
 }



svn commit: samba r24745 - in branches: SAMBA_3_2/source SAMBA_3_2_0/source

2007-08-28 Thread jerry
Author: jerry
Date: 2007-08-28 15:12:11 + (Tue, 28 Aug 2007)
New Revision: 24745

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

Log:
Merge Simo's shared lib build fix from svn r22842 that was lost
somehow.  Don't include the PIE_FLAGS when building shared libs.


Modified:
   branches/SAMBA_3_2/source/Makefile.in
   branches/SAMBA_3_2_0/source/Makefile.in


Changeset:
Modified: branches/SAMBA_3_2/source/Makefile.in
===
--- branches/SAMBA_3_2/source/Makefile.in   2007-08-28 15:09:47 UTC (rev 
24744)
+++ branches/SAMBA_3_2/source/Makefile.in   2007-08-28 15:12:11 UTC (rev 
24745)
@@ -35,9 +35,9 @@
 CPPFLAGS=-DHAVE_CONFIG_H @CPPFLAGS@
 
 [EMAIL PROTECTED]@
[EMAIL PROTECTED]@ @LDFLAGS@
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@ @LDFLAGS@
[EMAIL PROTECTED]@ @LDFLAGS@
 
 # The MODULE_EXPORTS variable conatins the platform-specific linker flags
 # needed to restrict the exports for VFS, IDMAP, RPC and PASSDB modules.
@@ -1354,7 +1354,7 @@
 
 bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(LIBADDNS_OBJ)
@echo Linking libaddns shared library $@
-   @$(SHLD_DSO) $(LIBADDNS_OBJ) $(LDFLAGS) $(LIBS) \
+   @$(SHLD_DSO) $(LIBADDNS_OBJ) $(LIBS) \
$(KRB5LIBS) $(UUID_LIBS)\
@[EMAIL PROTECTED] [EMAIL PROTECTED](SONAME_VER)
 
@@ -1364,7 +1364,7 @@
 
 bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ)
@echo Linking libsmbclient shared library $@
-   @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) $(LDFLAGS) $(LIBS) \
+   @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) $(LIBS) \
$(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
@[EMAIL PROTECTED] [EMAIL PROTECTED](SONAME_VER)
 
@@ -1374,7 +1374,7 @@
 
 bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ)
@echo Linking libsmbsharemodes shared library $@
-   @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LDFLAGS) $(LIBS) \
+   @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) \
$(KRB5LIBS) $(LDAP_LIBS) \
@[EMAIL PROTECTED] [EMAIL PROTECTED](SONAME_VER)
 

Modified: branches/SAMBA_3_2_0/source/Makefile.in
===
--- branches/SAMBA_3_2_0/source/Makefile.in 2007-08-28 15:09:47 UTC (rev 
24744)
+++ branches/SAMBA_3_2_0/source/Makefile.in 2007-08-28 15:12:11 UTC (rev 
24745)
@@ -35,10 +35,10 @@
 CPPFLAGS=-DHAVE_CONFIG_H @CPPFLAGS@
 
 [EMAIL PROTECTED]@
[EMAIL PROTECTED]@ @LDFLAGS@
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@ @LDFLAGS@
 [EMAIL PROTECTED]@ @LDFLAGS@
[EMAIL PROTECTED]@ @LDFLAGS@
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@
 [EMAIL PROTECTED]@
@@ -1312,7 +1312,7 @@
 
 bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(LIBADDNS_OBJ)
@echo Linking libaddns shared library $@
-   @$(SHLD_DSO) $(LIBADDNS_OBJ) $(LDFLAGS) $(LIBS) \
+   @$(SHLD_DSO) $(LIBADDNS_OBJ) $(LIBS) \
$(KRB5LIBS) $(UUID_LIBS)\
@[EMAIL PROTECTED] [EMAIL PROTECTED](SONAME_VER)
 
@@ -1322,7 +1322,7 @@
 
 bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(LIBSMBCLIENT_OBJ)
@echo Linking libsmbclient shared library $@
-   @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) $(LDFLAGS) $(LIBS) \
+   @$(SHLD_DSO) $(LIBSMBCLIENT_OBJ) $(LIBS) \
$(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
@[EMAIL PROTECTED] [EMAIL PROTECTED](SONAME_VER)
 
@@ -1332,7 +1332,7 @@
 
 bin/[EMAIL PROTECTED]@: $(BINARY_PREREQS) $(LIBSMBSHAREMODES_OBJ)
@echo Linking libsmbsharemodes shared library $@
-   @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LDFLAGS) $(LIBS) \
+   @$(SHLD_DSO) $(LIBSMBSHAREMODES_OBJ) $(LIBS) \
$(KRB5LIBS) $(LDAP_LIBS) \
@[EMAIL PROTECTED] [EMAIL PROTECTED](SONAME_VER)
 



svn commit: samba r24748 - in branches: SAMBA_3_2/source SAMBA_3_2/source/libads SAMBA_3_2_0/source SAMBA_3_2_0/source/libads

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 15:26:59 + (Tue, 28 Aug 2007)
New Revision: 24748

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

Log:
Remove all dependencies to samba internals and convert the krb5 locator plugin
into a tiny winbindd DsGetDcName client. This still does not solve the case of
using the locator from within winbindd itself but at least gencache.tdb and
others are no longer corrupted.

Guenther

Modified:
   branches/SAMBA_3_2/source/Makefile.in
   branches/SAMBA_3_2/source/libads/smb_krb5_locator.c
   branches/SAMBA_3_2_0/source/Makefile.in
   branches/SAMBA_3_2_0/source/libads/smb_krb5_locator.c


Changeset:
Sorry, the patch is too large (593 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24748


svn commit: samba r24749 - in branches: SAMBA_3_2/source/libsmb SAMBA_3_2_0/source/libsmb

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 15:31:42 + (Tue, 28 Aug 2007)
New Revision: 24749

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

Log:
Increase debuglevel.

Guenther

Modified:
   branches/SAMBA_3_2/source/libsmb/dsgetdcname.c
   branches/SAMBA_3_2_0/source/libsmb/dsgetdcname.c


Changeset:
Modified: branches/SAMBA_3_2/source/libsmb/dsgetdcname.c
===
--- branches/SAMBA_3_2/source/libsmb/dsgetdcname.c  2007-08-28 15:26:59 UTC 
(rev 24748)
+++ branches/SAMBA_3_2/source/libsmb/dsgetdcname.c  2007-08-28 15:31:42 UTC 
(rev 24749)
@@ -508,7 +508,7 @@
/* FIXME: check for DSGETDC_VALID_FLAGS and check for excluse bits
 * (DS_PDC_REQUIRED, DS_KDC_REQUIRED, DS_GC_SERVER_REQUIRED) */
 
-   debug_dsdcinfo_flags(0, flags);
+   debug_dsdcinfo_flags(10, flags);
 
if (return_type == (DS_RETURN_FLAT_NAME|DS_RETURN_DNS_NAME)) {
return False;

Modified: branches/SAMBA_3_2_0/source/libsmb/dsgetdcname.c
===
--- branches/SAMBA_3_2_0/source/libsmb/dsgetdcname.c2007-08-28 15:26:59 UTC 
(rev 24748)
+++ branches/SAMBA_3_2_0/source/libsmb/dsgetdcname.c2007-08-28 15:31:42 UTC 
(rev 24749)
@@ -508,7 +508,7 @@
/* FIXME: check for DSGETDC_VALID_FLAGS and check for excluse bits
 * (DS_PDC_REQUIRED, DS_KDC_REQUIRED, DS_GC_SERVER_REQUIRED) */
 
-   debug_dsdcinfo_flags(0, flags);
+   debug_dsdcinfo_flags(10, flags);
 
if (return_type == (DS_RETURN_FLAT_NAME|DS_RETURN_DNS_NAME)) {
return False;



svn commit: samba r24750 - in branches: SAMBA_3_2/source/libsmb SAMBA_3_2_0/source/libsmb

2007-08-28 Thread obnox
Author: obnox
Date: 2007-08-28 15:38:03 + (Tue, 28 Aug 2007)
New Revision: 24750

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

Log:
Fix one more caller of  name_resolve_bcast().

Michael


Modified:
   branches/SAMBA_3_2/source/libsmb/libsmbclient.c
   branches/SAMBA_3_2_0/source/libsmb/libsmbclient.c


Changeset:
Modified: branches/SAMBA_3_2/source/libsmb/libsmbclient.c
===
--- branches/SAMBA_3_2/source/libsmb/libsmbclient.c 2007-08-28 15:31:42 UTC 
(rev 24749)
+++ branches/SAMBA_3_2/source/libsmb/libsmbclient.c 2007-08-28 15:38:03 UTC 
(rev 24750)
@@ -2665,7 +2665,9 @@
  */
 
 ip_list = NULL;
-if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) {
+if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list,
+&count)))
+   {
 
 SAFE_FREE(ip_list);
 

Modified: branches/SAMBA_3_2_0/source/libsmb/libsmbclient.c
===
--- branches/SAMBA_3_2_0/source/libsmb/libsmbclient.c   2007-08-28 15:31:42 UTC 
(rev 24749)
+++ branches/SAMBA_3_2_0/source/libsmb/libsmbclient.c   2007-08-28 15:38:03 UTC 
(rev 24750)
@@ -2675,7 +2675,9 @@
  */
 
 ip_list = NULL;
-if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) {
+if (!NT_STATUS_IS_OK(name_resolve_bcast(MSBROWSE, 1, &ip_list,
+&count)))
+   {
 
 SAFE_FREE(ip_list);
 



svn commit: samba r24751 - in branches/SAMBA_4_0: . source source/librpc/idl source/selftest source/torture source/torture/rpc

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-28 16:24:18 + (Tue, 28 Aug 2007)
New Revision: 24751

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

Log:
Run more tests, remove empty testsuites, more small improvements.
Removed:
   branches/SAMBA_4_0/source/torture/rpc/rot.c
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/librpc/idl/dfs.idl
   branches/SAMBA_4_0/source/samba4-knownfail
   branches/SAMBA_4_0/source/samba4-skip
   branches/SAMBA_4_0/source/selftest/test_rpc.sh
   branches/SAMBA_4_0/source/torture/config.mk
   branches/SAMBA_4_0/source/torture/rpc/atsvc.c
   branches/SAMBA_4_0/source/torture/rpc/dfs.c
   branches/SAMBA_4_0/source/torture/rpc/echo.c
   branches/SAMBA_4_0/source/torture/rpc/epmapper.c
   branches/SAMBA_4_0/source/torture/rpc/eventlog.c
   branches/SAMBA_4_0/source/torture/rpc/initshutdown.c
   branches/SAMBA_4_0/source/torture/rpc/oxidresolve.c
   branches/SAMBA_4_0/source/torture/rpc/remact.c
   branches/SAMBA_4_0/source/torture/rpc/rpc.c
   branches/SAMBA_4_0/source/torture/rpc/srvsvc.c
   branches/SAMBA_4_0/source/torture/rpc/svcctl.c
   branches/SAMBA_4_0/source/torture/rpc/unixinfo.c
   branches/SAMBA_4_0/source/torture/rpc/winreg.c
   branches/SAMBA_4_0/source/torture/rpc/wkssvc.c


Changeset:
Sorry, the patch is too large (1317 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24751


svn commit: samba r24752 - in branches: SAMBA_3_2/source/libads SAMBA_3_2_0/source/libads

2007-08-28 Thread gd
Author: gd
Date: 2007-08-28 16:39:03 + (Tue, 28 Aug 2007)
New Revision: 24752

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

Log:
Make sure to return properly when the locator is called from within winbindd.

Guenther

Modified:
   branches/SAMBA_3_2/source/libads/smb_krb5_locator.c
   branches/SAMBA_3_2_0/source/libads/smb_krb5_locator.c


Changeset:
Modified: branches/SAMBA_3_2/source/libads/smb_krb5_locator.c
===
--- branches/SAMBA_3_2/source/libads/smb_krb5_locator.c 2007-08-28 16:24:18 UTC 
(rev 24751)
+++ branches/SAMBA_3_2/source/libads/smb_krb5_locator.c 2007-08-28 16:39:03 UTC 
(rev 24752)
@@ -340,16 +340,12 @@
"failed to query winbindd\n",
(unsigned int)getpid());
 #endif
-
-#ifdef KRB5_PLUGIN_NO_HANDLE
-   return KRB5_PLUGIN_NO_HANDLE;
-#else
-   return KRB5_KDC_UNREACH; /* Heimdal */
-#endif
+   goto failed;
}
} else {
/* FIXME: here comes code for locator being called from within
 * winbind */
+goto failed;
}
 #ifdef DEBUG_KRB5
fprintf(stderr, "[%5u]: smb_krb5_locator_lookup: "
@@ -367,6 +363,13 @@
SAFE_FREE(kdc_name);
 
return ret;
+
+ failed:
+#ifdef KRB5_PLUGIN_NO_HANDLE
+   return KRB5_PLUGIN_NO_HANDLE;
+#else
+   return KRB5_KDC_UNREACH; /* Heimdal */
+#endif
 }
 
 #ifdef HEIMDAL_KRB5_LOCATE_PLUGIN_H

Modified: branches/SAMBA_3_2_0/source/libads/smb_krb5_locator.c
===
--- branches/SAMBA_3_2_0/source/libads/smb_krb5_locator.c   2007-08-28 
16:24:18 UTC (rev 24751)
+++ branches/SAMBA_3_2_0/source/libads/smb_krb5_locator.c   2007-08-28 
16:39:03 UTC (rev 24752)
@@ -340,16 +340,12 @@
"failed to query winbindd\n",
(unsigned int)getpid());
 #endif
-
-#ifdef KRB5_PLUGIN_NO_HANDLE
-   return KRB5_PLUGIN_NO_HANDLE;
-#else
-   return KRB5_KDC_UNREACH; /* Heimdal */
-#endif
+   goto failed;
}
} else {
/* FIXME: here comes code for locator being called from within
 * winbind */
+goto failed;
}
 #ifdef DEBUG_KRB5
fprintf(stderr, "[%5u]: smb_krb5_locator_lookup: "
@@ -367,6 +363,13 @@
SAFE_FREE(kdc_name);
 
return ret;
+
+ failed:
+#ifdef KRB5_PLUGIN_NO_HANDLE
+   return KRB5_PLUGIN_NO_HANDLE;
+#else
+   return KRB5_KDC_UNREACH; /* Heimdal */
+#endif
 }
 
 #ifdef HEIMDAL_KRB5_LOCATE_PLUGIN_H



svn commit: samba r24753 - in branches/SAMBA_4_0: . source/librpc/rpc source/librpc/tests

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-28 17:45:57 + (Tue, 28 Aug 2007)
New Revision: 24753

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

Log:
Allow host name in binding string without transport.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
   branches/SAMBA_4_0/source/librpc/tests/binding_string.c


Changeset:

Property changes on: branches/SAMBA_4_0
___
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
===
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h   2007-08-28 16:39:03 UTC 
(rev 24752)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h   2007-08-28 17:45:57 UTC 
(rev 24753)
@@ -28,9 +28,9 @@
 #include "librpc/ndr/libndr.h"
 
 enum dcerpc_transport_t {
-   NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, NCACN_VNS_SPP, 
-   NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, 
NCADG_UNIX_DGRAM,
-   NCACN_HTTP, NCADG_IPX, NCACN_SPX };
+   NCA_UNKNOWN, NCACN_NP, NCACN_IP_TCP, NCACN_IP_UDP, NCACN_VNS_IPC, 
+   NCACN_VNS_SPP, NCACN_AT_DSP, NCADG_AT_DDP, NCALRPC, NCACN_UNIX_STREAM, 
+   NCADG_UNIX_DGRAM, NCACN_HTTP, NCADG_IPX, NCACN_SPX };
 
 /*
   this defines a generic security context for signed/sealed dcerpc pipes.

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c  2007-08-28 16:39:03 UTC 
(rev 24752)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c  2007-08-28 17:45:57 UTC 
(rev 24753)
@@ -235,24 +235,31 @@
 {
char *s = talloc_strdup(mem_ctx, "");
int i;
-   const char *t_name=NULL;
+   const char *t_name = NULL;
 
-   for (i=0;itransport) {
-   t_name = transports[i].name;
+   if (b->transport != NCA_UNKNOWN) {
+   for (i=0;itransport) {
+   t_name = transports[i].name;
+   }
}
+   if (!t_name) {
+   return NULL;
+   }
}
-   if (!t_name) {
-   return NULL;
-   }
 
if (!GUID_all_zero(&b->object.uuid)) { 
s = talloc_asprintf(s, "%s@",
GUID_string(mem_ctx, &b->object.uuid));
}
 
-   s = talloc_asprintf_append(s, "%s:", t_name);
-   if (!s) return NULL;
+   if (t_name != NULL) {
+   s = talloc_asprintf_append(s, "%s:", t_name);
+   if (s == NULL) 
+   return NULL;
+   } else {
+   s = NULL;
+   }
 
if (b->host) {
s = talloc_asprintf_append(s, "%s", b->host);
@@ -323,27 +330,29 @@
b->object.if_version = 0;
 
p = strchr(s, ':');
-   if (!p) {
-   return NT_STATUS_INVALID_PARAMETER;
-   }
 
-   type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
-   if (!type) {
-   return NT_STATUS_NO_MEMORY;
-   }
+   if (p == NULL) {
+   b->transport = NCA_UNKNOWN;
+   } else {
+   type = talloc_strndup(mem_ctx, s, PTR_DIFF(p, s));
+   if (!type) {
+   return NT_STATUS_NO_MEMORY;
+   }
 
-   for (i=0;itransport = transports[i].transport;
-   break;
+   for (i=0;itransport = transports[i].transport;
+   break;
+   }
}
+
+   if (i==ARRAY_SIZE(transports)) {
+   DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
+   return NT_STATUS_INVALID_PARAMETER;
+   }
+   
+   s = p+1;
}
-   if (i==ARRAY_SIZE(transports)) {
-   DEBUG(0,("Unknown dcerpc transport '%s'\n", type));
-   return NT_STATUS_INVALID_PARAMETER;
-   }
-   
-   s = p+1;
 
p = strchr(s, '[');
if (p) {

Modified: branches/SAMBA_4_0/source/librpc/tests/binding_string.c
===
--- branches/SAMBA_4_0/source/librpc/tests/binding_string.c 2007-08-28 
16:39:03 UTC (rev 24752)
+++ branches/SAMBA_4_0/source/librpc/tests/binding_string.c 2007-08-28 
17:45:57 UTC (rev 24753)
@@ -95,6 +95,27 @@
"ncacn_unix_stream:[/tmp/epmapper,sign]",
 };
 
+static bool test_no_transport(struct torture_context *tctx)
+{
+   const char *binding = "somehost";
+   struct dcerpc_binding *b;
+   const char *s;
+
+   /* Parse */
+   torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, binding, 
&b),
+   "Error parsing binding string")

svn commit: samba r24754 - in branches: .

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-28 19:00:10 + (Tue, 28 Aug 2007)
New Revision: 24754

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

Log:
Remove temporary branch (has been merged into SAMBA_4_0)

Removed:
   branches/4.0-regwrite/


Changeset:


svn commit: samba r24755 - in branches/SAMBA_4_0: . source/librpc/rpc source/torture/libnet source/torture/rpc

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-28 19:03:08 + (Tue, 28 Aug 2007)
New Revision: 24755

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

Log:
Use common code for finding the RPC binding in the torture tests.

Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
   branches/SAMBA_4_0/source/torture/libnet/domain.c
   branches/SAMBA_4_0/source/torture/libnet/groupinfo.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_group.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_lookup.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_rpc.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_share.c
   branches/SAMBA_4_0/source/torture/libnet/libnet_user.c
   branches/SAMBA_4_0/source/torture/libnet/userinfo.c
   branches/SAMBA_4_0/source/torture/libnet/userman.c
   branches/SAMBA_4_0/source/torture/rpc/bind.c
   branches/SAMBA_4_0/source/torture/rpc/mgmt.c
   branches/SAMBA_4_0/source/torture/rpc/rpc.c
   branches/SAMBA_4_0/source/torture/rpc/samlogon.c
   branches/SAMBA_4_0/source/torture/rpc/samsync.c
   branches/SAMBA_4_0/source/torture/rpc/scanner.c
   branches/SAMBA_4_0/source/torture/rpc/spoolss.c
   branches/SAMBA_4_0/source/torture/rpc/wkssvc.c


Changeset:
Sorry, the patch is too large (908 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24755


svn commit: samba r24756 - in branches/SAMBA_3_2_0/source/nsswitch: .

2007-08-28 Thread jerry
Author: jerry
Date: 2007-08-28 22:49:43 + (Tue, 28 Aug 2007)
New Revision: 24756

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

Log:
Merge svn r24722 from SAMBA_3_2 (upn logon support)
Modified:
   branches/SAMBA_3_2_0/source/nsswitch/pam_winbind.c
   branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_cache.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd_util.c


Changeset:
Modified: branches/SAMBA_3_2_0/source/nsswitch/pam_winbind.c
===
--- branches/SAMBA_3_2_0/source/nsswitch/pam_winbind.c  2007-08-28 19:03:08 UTC 
(rev 24755)
+++ branches/SAMBA_3_2_0/source/nsswitch/pam_winbind.c  2007-08-28 22:49:43 UTC 
(rev 24756)
@@ -1614,6 +1614,89 @@
return ret;
 }
 
+/**
+ * Retrieve the winbind separator.
+ *
+ * @param pamh PAM handle
+ * @param ctrl PAM winbind options.
+ *
+ * @return string separator character. NULL on failure.
+ */
+
+static char winbind_get_separator(pam_handle_t *pamh, int ctrl)
+{
+   struct winbindd_request request;
+   struct winbindd_response response;
+
+   ZERO_STRUCT(request);
+   ZERO_STRUCT(response);
+
+   if (pam_winbind_request_log(pamh, ctrl, WINBINDD_INFO, &request, 
&response, NULL)) {
+   return '\0';
+   }
+
+   return response.data.info.winbind_separator;
+}
+
+/**
+ * Convert a upn to a name.
+ *
+ * @param pamh PAM handle
+ * @param ctrl PAM winbind options.
+ * @param upn  USer UPN to be trabslated.
+ *
+ * @return converted name. NULL pointer on failure. Caller needs to free.
+ */
+
+static char* winbind_upn_to_username(pam_handle_t *pamh, int ctrl, const char 
*upn)
+{
+   struct winbindd_request req;
+   struct winbindd_response resp;
+   int retval; 
+   char *account_name; 
+   int account_name_len;
+   char sep;   
+
+   /* This cannot work when the winbind separator = @ */
+
+   sep = winbind_get_separator(pamh, ctrl);
+   if (!sep || sep == '@') {
+   return NULL;
+   }
+   
+   /* Convert the UPN to a SID */
+
+   ZERO_STRUCT(req);
+   ZERO_STRUCT(resp);
+
+   strncpy(req.data.name.dom_name, "",
+   sizeof(req.data.name.dom_name) - 1);
+   strncpy(req.data.name.name, upn,
+   sizeof(req.data.name.name) - 1);
+   retval = pam_winbind_request_log(pamh, ctrl, WINBINDD_LOOKUPNAME, 
+&req, &resp, upn);
+   if ( retval != PAM_SUCCESS ) {  
+   return NULL;
+   }
+   
+   /* Convert the the SID back to the sAMAccountName */
+   
+   ZERO_STRUCT(req);
+   strncpy(req.data.sid, resp.data.sid.sid, sizeof(req.data.sid)-1);
+   ZERO_STRUCT(resp);
+   retval =  pam_winbind_request_log(pamh, ctrl, WINBINDD_LOOKUPSID, 
+ &req, &resp, upn);
+   if ( retval != PAM_SUCCESS ) {  
+   return NULL;
+   }
+   
+   account_name_len = asprintf(&account_name, "%s\\%s", 
+   resp.data.name.dom_name,
+   resp.data.name.name);
+
+   return account_name;
+}
+
 PAM_EXTERN
 int pam_sm_authenticate(pam_handle_t *pamh, int flags,
int argc, const char **argv)
@@ -1646,6 +1729,7 @@
goto out;
}
 
+
 #if defined(AIX)
/* Decode the user name since AIX does not support logn user
   names by default.  The name is encoded as _#uid.  */
@@ -1670,6 +1754,19 @@
}
}   
 
+   /* Maybe this was a UPN */
+
+   if (strchr(real_username, '@') != NULL) {
+   char *samaccountname = NULL;
+   
+   samaccountname = winbind_upn_to_username(pamh, ctrl, 
+real_username);
+   if (samaccountname) {
+   free(real_username);
+   real_username = samaccountname;
+   }
+   }
+
retval = _winbind_read_password(pamh, ctrl, NULL, 
"Password: ", NULL,
&password);
@@ -1697,8 +1794,8 @@
  ctrl, d);
 
/* Now use the username to look up password */
-   retval = winbind_auth_request(pamh, ctrl, username, password, member,
- cctype, warn_pwd_expire, NULL, NULL,
+   retval = winbind_auth_request(pamh, ctrl, real_username, password, 
member,
+ cctype, warn_pwd_expire, NULL, NULL, 
  &username_ret);
 
if (retval == PAM_NEW_AUTHTOK_REQD ||

Modified: branches/SAMBA_3_2_0/source/nsswitch/wbinfo.c
===
--

Build status as of Wed Aug 29 00:00:01 2007

2007-08-28 Thread build
URL: http://build.samba.org/

--- /home/build/master/cache/broken_results.txt.old 2007-08-28 
00:00:49.0 +
+++ /home/build/master/cache/broken_results.txt 2007-08-29 00:01:18.0 
+
@@ -1,4 +1,4 @@
-Build status as of Tue Aug 28 00:00:01 2007
+Build status as of Wed Aug 29 00:00:01 2007
 
 Build counts:
 Tree Total  Broken Panic 
@@ -16,9 +16,9 @@
 rsync30 11 0 
 samba-docs   0  0  0 
 samba-gtk2  2  0 
-samba4   27 16 1 
-samba_3_231 19 0 
+samba4   27 23 0 
+samba_3_230 20 3 
 smb-build27 27 0 
 talloc   30 1  0 
-tdb  29 4  0 
+tdb  28 4  0 
 


svn commit: samba r24757 - in branches/SAMBA_4_0: . source/torture

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-29 00:04:40 + (Wed, 29 Aug 2007)
New Revision: 24757

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

Log:
Try parsing a UNC location before a DCE/RPC binding string as the latter now 
accepts strings not prefixed with a transport.

Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/torture/smbtorture.c


Changeset:

Property changes on: branches/SAMBA_4_0
___
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/torture/smbtorture.c
===
--- branches/SAMBA_4_0/source/torture/smbtorture.c  2007-08-28 22:49:43 UTC 
(rev 24756)
+++ branches/SAMBA_4_0/source/torture/smbtorture.c  2007-08-29 00:04:40 UTC 
(rev 24757)
@@ -481,6 +481,7 @@
static const char *ui_ops_name = "simple";
const char *basedir = NULL;
static int list_tests = 0;
+   char *host = NULL, *share = NULL;
enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST,
  OPT_DANGEROUS,OPT_SMB_PORTS,OPT_ASYNC,OPT_NUMPROGS};

@@ -601,24 +602,19 @@
}
 
/* see if its a RPC transport specifier */
-   status = dcerpc_parse_binding(talloc_autofree_context(), argv_new[1], 
&binding_struct);
-   if (NT_STATUS_IS_OK(status)) {
+   if (!smbcli_parse_unc(argv_new[1], NULL, &host, &share)) {
+   status = dcerpc_parse_binding(talloc_autofree_context(), 
argv_new[1], &binding_struct);
+   if (NT_STATUS_IS_ERR(status)) {
+   d_printf("Invalid option: %s is not a valid torture 
target (share or binding string)\n\n", argv_new[1]);
+   usage(pc);
+   return false;
+   }
lp_set_cmdline("torture:host", binding_struct->host);
lp_set_cmdline("torture:share", "IPC$");
lp_set_cmdline("torture:binding", argv_new[1]);
} else {
-   char *binding = NULL;
-   char *host = NULL, *share = NULL;
-
-   if (!smbcli_parse_unc(argv_new[1], NULL, &host, &share)) {
-   d_printf("Invalid option: %s is not a valid torture 
target (share or binding string)\n\n", argv_new[1]);
-   usage(pc);
-   }
-
lp_set_cmdline("torture:host", host);
lp_set_cmdline("torture:share", share);
-   asprintf(&binding, "ncacn_np:%s", host);
-   lp_set_cmdline("torture:binding", binding);
}
 
if (!strcmp(ui_ops_name, "simple")) {



svn commit: samba r24758 - in branches/SAMBA_4_0: . source/torture/raw source/torture/rpc

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-29 00:56:13 + (Wed, 29 Aug 2007)
New Revision: 24758

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

Log:
More use of torture API.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/torture/raw/acls.c
   branches/SAMBA_4_0/source/torture/rpc/alter_context.c


Changeset:
Sorry, the patch is too large (1001 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24758


svn commit: samba r24759 - in branches: SAMBA_3_2/source/include SAMBA_3_2/source/lib SAMBA_3_2/source/libaddns SAMBA_3_2/source/rpc_parse SAMBA_3_2_0/source/include SAMBA_3_2_0/source/lib SAMBA_3_2_0

2007-08-28 Thread jra
Author: jra
Date: 2007-08-29 01:23:31 + (Wed, 29 Aug 2007)
New Revision: 24759

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

Log:
Comment out the _nonnull calls for 3.2.x, as agreed with tridge.
Leaving the commented out code for now, in case I need to re-test
some stuff.
Jeremy

Modified:
   branches/SAMBA_3_2/source/include/smb_macros.h
   branches/SAMBA_3_2/source/lib/util.c
   branches/SAMBA_3_2/source/libaddns/dns.h
   branches/SAMBA_3_2/source/rpc_parse/parse_prs.c
   branches/SAMBA_3_2_0/source/include/smb_macros.h
   branches/SAMBA_3_2_0/source/lib/util.c
   branches/SAMBA_3_2_0/source/libaddns/dns.h
   branches/SAMBA_3_2_0/source/rpc_parse/parse_prs.c


Changeset:
Modified: branches/SAMBA_3_2/source/include/smb_macros.h
===
--- branches/SAMBA_3_2/source/include/smb_macros.h  2007-08-29 00:56:13 UTC 
(rev 24758)
+++ branches/SAMBA_3_2/source/include/smb_macros.h  2007-08-29 01:23:31 UTC 
(rev 24759)
@@ -275,6 +275,11 @@
 
 /* The new talloc is paranoid malloc checker safe. */
 
+#if 0
+
+Disable these now we've checked all code paths and ensured
+NULL returns on zero request. JRA.
+
 #define TALLOC(ctx, size) talloc_zeronull(ctx, size, __location__)
 #define TALLOC_P(ctx, type) (type *)talloc_zeronull(ctx, sizeof(type), #type)
 #define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array_zeronull(ctx, 
sizeof(type), count, #type)
@@ -282,12 +287,27 @@
 #define TALLOC_ZERO(ctx, size) _talloc_zero_zeronull(ctx, size, __location__)
 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_zeronull(ctx, 
sizeof(type), #type)
 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type 
*)_talloc_zero_array_zeronull(ctx, sizeof(type), count, #type)
+#define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__)
+#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, 
__location__)
+
+#else
+
+#define TALLOC(ctx, size) talloc_named_const(ctx, size, __location__)
+#define TALLOC_P(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), 
#type)
+#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, 
sizeof(type), count, #type)
+#define TALLOC_MEMDUP(ctx, ptr, size) _talloc_memdup(ctx, ptr, size, 
__location__)
+#define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
+#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
+#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, 
sizeof(type), count, #type)
+#define TALLOC_SIZE(ctx, size) talloc(ctx, size, __location__)
+#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
+
+#endif
+
 #define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, 
__location__)
 #define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type 
*)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type)
 #define talloc_destroy(ctx) talloc_free(ctx)
 #define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} 
} while(0)
-#define TALLOC_SIZE(ctx, size) talloc_zeronull(ctx, size, __location__)
-#define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero_zeronull(ctx, size, 
__location__)
 
 /* only define PARANOID_MALLOC_CHECKER with --enable-developer and not 
compiling
the smbmount utils */

Modified: branches/SAMBA_3_2/source/lib/util.c
===
--- branches/SAMBA_3_2/source/lib/util.c2007-08-29 00:56:13 UTC (rev 
24758)
+++ branches/SAMBA_3_2/source/lib/util.c2007-08-29 01:23:31 UTC (rev 
24759)
@@ -3314,6 +3314,11 @@
return IVAL(ptr,off);
 }
 
+#if 0
+
+Disable these now we've checked all code paths and ensured
+NULL returns on zero request. JRA.
+
 /
  talloc wrapper functions that guarentee a null pointer return
  if size == 0.
@@ -3412,3 +3417,4 @@
}
return talloc_named_const(context, size, name);
 }
+#endif

Modified: branches/SAMBA_3_2/source/libaddns/dns.h
===
--- branches/SAMBA_3_2/source/libaddns/dns.h2007-08-29 00:56:13 UTC (rev 
24758)
+++ branches/SAMBA_3_2/source/libaddns/dns.h2007-08-29 01:23:31 UTC (rev 
24759)
@@ -86,6 +86,11 @@
 
 #include 
 
+#if 0
+
+Disable these now we've checked all code paths and ensured
+NULL returns on zero request. JRA.
+
 void *_talloc_zero_zeronull(const void *ctx, size_t size, const char *name);
 void *_talloc_memdup_zeronull(const void *t, const void *p, size_t size, const 
char *name);
 void *_talloc_array_zeronull(const void *ctx, size_t el_size, unsigned count, 
const char *name);
@@ -99,12 +104,27 @@
 #define TALLOC_ZERO(ctx, size) _talloc_zero_zeronull(ctx, size, __location__)
 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero_zeronull(ctx, 
sizeof(type), #type)
 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type 
*)_talloc_zero_array_zeronull(ctx, sizeof(typ

svn commit: samba r24760 - in branches/SAMBA_4_0/source: scripting/libjs setup

2007-08-28 Thread abartlet
Author: abartlet
Date: 2007-08-29 01:37:26 + (Wed, 29 Aug 2007)
New Revision: 24760

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

Log:
Ensure we base64 encode any password being put into LDIF, to avoid
provision failures when some of the random password values are illigal
LDIF.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/scripting/libjs/provision.js
   branches/SAMBA_4_0/source/setup/provision_self_join.ldif
   branches/SAMBA_4_0/source/setup/provision_users.ldif
   branches/SAMBA_4_0/source/setup/secrets.ldif


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/libjs/provision.js
===
--- branches/SAMBA_4_0/source/scripting/libjs/provision.js  2007-08-29 
01:23:31 UTC (rev 24759)
+++ branches/SAMBA_4_0/source/scripting/libjs/provision.js  2007-08-29 
01:37:26 UTC (rev 24760)
@@ -449,6 +449,8 @@
 
 function provision_fix_subobj(subobj, paths)
 {
+   var ldb = ldb_init();
+   
subobj.REALM   = strupper(subobj.REALM);
subobj.HOSTNAME= strlower(subobj.HOSTNAME);
subobj.DOMAIN  = strupper(subobj.DOMAIN);
@@ -465,6 +467,11 @@
subobj.CONFIGDN = "CN=Configuration," + subobj.ROOTDN;
subobj.SCHEMADN = "CN=Schema," + subobj.CONFIGDN;
 
+   subobj.MACHINEPASS_B64 = ldb.encode(subobj.MACHINEPASS);
+   subobj.KRBTGTPASS_B64  = ldb.encode(subobj.KRBTGTPASS);
+   subobj.ADMINPASS_B64   = ldb.encode(subobj.ADMINPASS);
+   subobj.DNSPASS_B64 = ldb.encode(subobj.DNSPASS);
+
var rdns = split(",", subobj.DOMAINDN);
subobj.RDN_DC = substr(rdns[0], strlen("DC="));
 

Modified: branches/SAMBA_4_0/source/setup/provision_self_join.ldif
===
--- branches/SAMBA_4_0/source/setup/provision_self_join.ldif2007-08-29 
01:23:31 UTC (rev 24759)
+++ branches/SAMBA_4_0/source/setup/provision_self_join.ldif2007-08-29 
01:37:26 UTC (rev 24760)
@@ -13,7 +13,7 @@
 operatingSystemVersion: 4.0
 dNSHostName: ${DNSNAME}
 isCriticalSystemObject: TRUE
-sambaPassword: ${MACHINEPASS}
+sambaPassword:: ${MACHINEPASS_B64}
 servicePrincipalName: HOST/${DNSNAME}
 servicePrincipalName: HOST/${NETBIOSNAME}
 servicePrincipalName: HOST/${DNSNAME}/${REALM}

Modified: branches/SAMBA_4_0/source/setup/provision_users.ldif
===
--- branches/SAMBA_4_0/source/setup/provision_users.ldif2007-08-29 
01:23:31 UTC (rev 24759)
+++ branches/SAMBA_4_0/source/setup/provision_users.ldif2007-08-29 
01:37:26 UTC (rev 24760)
@@ -13,7 +13,7 @@
 accountExpires: -1
 sAMAccountName: Administrator
 isCriticalSystemObject: TRUE
-sambaPassword: ${ADMINPASS}
+sambaPassword:: ${ADMINPASS_B64}
 
 dn: CN=Guest,CN=Users,${DOMAINDN}
 objectClass: user
@@ -203,7 +203,7 @@
 sAMAccountType: 805306368
 servicePrincipalName: kadmin/changepw
 isCriticalSystemObject: TRUE
-sambaPassword: ${KRBTGTPASS}
+sambaPassword:: ${KRBTGTPASS_B64}
 
 dn: CN=dns,CN=Users,${DOMAINDN}
 objectClass: top
@@ -219,7 +219,7 @@
 sAMAccountType: 805306368
 servicePrincipalName: DNS/${DNSDOMAIN}
 isCriticalSystemObject: TRUE
-sambaPassword: ${DNSPASS}
+sambaPassword:: ${DNSPASS_B64}
 
 dn: CN=Domain Computers,CN=Users,${DOMAINDN}
 objectClass: top

Modified: branches/SAMBA_4_0/source/setup/secrets.ldif
===
--- branches/SAMBA_4_0/source/setup/secrets.ldif2007-08-29 01:23:31 UTC 
(rev 24759)
+++ branches/SAMBA_4_0/source/setup/secrets.ldif2007-08-29 01:37:26 UTC 
(rev 24760)
@@ -14,7 +14,7 @@
 objectClass: kerberosSecret
 flatname: ${DOMAIN}
 realm: ${REALM}
-secret: ${MACHINEPASS}
+secret:: ${MACHINEPASS_B64}
 secureChannelType: 6
 sAMAccountName: ${NETBIOSNAME}$
 whenCreated: ${LDAPTIME}
@@ -50,5 +50,5 @@
 whenChanged: ${LDAPTIME}
 servicePrincipalName: DNS/${DNSDOMAIN}
 privateKeytab: ${DNS_KEYTAB}
-secret: ${DNSPASS}
+secret:: ${DNSPASS_B64}
 



svn commit: samba r24761 - in branches/SAMBA_4_0: source/dsdb/samdb/ldb_modules source/scripting/libjs testprogs/ejs

2007-08-28 Thread abartlet
Author: abartlet
Date: 2007-08-29 01:40:58 + (Wed, 29 Aug 2007)
New Revision: 24761

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

Log:
Permit subtree renames in Samba4.

The module is scary: On a rename, it does a search for all entries
under that entry (including itself), and fires off a seperate rename
call for each result.  This will fail miserably on an LDAP backend,
but I'll need to work on using hdb for OpenLDAP, and hope Fedora DS
can implement subtree renames at some point.

Andrew Bartlett

Added:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c
Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/config.mk
   branches/SAMBA_4_0/source/scripting/libjs/provision.js
   branches/SAMBA_4_0/testprogs/ejs/ldap.js


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/config.mk
===
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/config.mk  2007-08-29 
01:37:26 UTC (rev 24760)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/config.mk  2007-08-29 
01:40:58 UTC (rev 24761)
@@ -232,3 +232,15 @@
 # End MODULE ldb_objectclass
 
 
+
+# Start MODULE ldb_subtree_rename
+[MODULE::ldb_subtree_rename]
+INIT_FUNCTION = ldb_subtree_rename_init
+CFLAGS = -Ilib/ldb/include
+PRIVATE_DEPENDENCIES = LIBTALLOC
+SUBSYSTEM = LIBLDB
+OBJ_FILES = \
+   subtree_rename.o
+# End MODULE ldb_subtree_rename
+
+

Added: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c
===
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c   
2007-08-29 01:37:26 UTC (rev 24760)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c   
2007-08-29 01:40:58 UTC (rev 24761)
@@ -0,0 +1,290 @@
+/* 
+   ldb database library
+
+   Copyright (C) Andrew Bartlett <[EMAIL PROTECTED]> 2006-2007
+   Copyright (C) Stefan Metzmacher <[EMAIL PROTECTED]> 2007
+
+ ** NOTE! The following LGPL license applies to the ldb
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see .
+*/
+
+/*
+ *  Name: ldb
+ *
+ *  Component: ldb subtree rename module
+ *
+ *  Description: Rename a subtree in LDB
+ *
+ *  Author: Andrew Bartlett
+ */
+
+#include "ldb_includes.h"
+
+struct subtree_rename_context {
+   struct ldb_module *module;
+   struct ldb_handle *handle;
+   struct ldb_request *orig_req;
+
+   struct ldb_request **down_req;
+   int num_requests;
+   int finished_requests;
+};
+
+struct subtree_rename_search_context {
+   struct ldb_module *module;
+   struct ldb_request *orig_req;
+   struct ldb_handle *handle;
+
+   struct ldb_request **down_req;
+   int num_requests;
+   int finished_requests;
+};
+
+static struct subtree_rename_context *subtree_rename_init_handle(struct 
ldb_request *req, 
+struct 
ldb_module *module)
+{
+   struct subtree_rename_context *ac;
+   struct ldb_handle *h;
+
+   h = talloc_zero(req, struct ldb_handle);
+   if (h == NULL) {
+   ldb_set_errstring(module->ldb, "Out of Memory");
+   return NULL;
+   }
+
+   h->module = module;
+
+   ac = talloc_zero(h, struct subtree_rename_context);
+   if (ac == NULL) {
+   ldb_set_errstring(module->ldb, "Out of Memory");
+   talloc_free(h);
+   return NULL;
+   }
+
+   h->private_data = ac;
+
+   ac->module = module;
+   ac->handle = h;
+   ac->orig_req = req;
+
+   req->handle = h;
+
+   return ac;
+}
+
+
+static int subtree_rename_search_callback(struct ldb_context *ldb, void 
*context, struct ldb_reply *ares) 
+{
+   /* OK, we have one of *many* search results here:
+
+  We should also get the entry we tried to rename.  This
+  callback handles this and everything below it.
+*/
+
+   if (ares->type == LDB_REPLY_ENTRY) {
+   /* And it is an actual entry: now create a rename from it */
+   struct su

svn commit: samba r24762 - in branches: SAMBA_3_2/source/include SAMBA_3_2_0/source/include

2007-08-28 Thread jra
Author: jra
Date: 2007-08-29 01:48:46 + (Wed, 29 Aug 2007)
New Revision: 24762

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

Log:
Fix the build, missed TALLOC_SIZE -> talloc_named_const.
Jeremy.

Modified:
   branches/SAMBA_3_2/source/include/smb_macros.h
   branches/SAMBA_3_2_0/source/include/smb_macros.h


Changeset:
Modified: branches/SAMBA_3_2/source/include/smb_macros.h
===
--- branches/SAMBA_3_2/source/include/smb_macros.h  2007-08-29 01:40:58 UTC 
(rev 24761)
+++ branches/SAMBA_3_2/source/include/smb_macros.h  2007-08-29 01:48:46 UTC 
(rev 24762)
@@ -299,7 +299,7 @@
 #define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, 
sizeof(type), count, #type)
-#define TALLOC_SIZE(ctx, size) talloc(ctx, size, __location__)
+#define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__)
 #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
 
 #endif

Modified: branches/SAMBA_3_2_0/source/include/smb_macros.h
===
--- branches/SAMBA_3_2_0/source/include/smb_macros.h2007-08-29 01:40:58 UTC 
(rev 24761)
+++ branches/SAMBA_3_2_0/source/include/smb_macros.h2007-08-29 01:48:46 UTC 
(rev 24762)
@@ -300,7 +300,7 @@
 #define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, 
sizeof(type), count, #type)
-#define TALLOC_SIZE(ctx, size) talloc(ctx, size, __location__)
+#define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__)
 #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
 
 #endif



svn commit: samba r24763 - in branches/SAMBA_4_0: . source/librpc/rpc

2007-08-28 Thread jelmer
Author: jelmer
Date: 2007-08-29 02:01:56 + (Wed, 29 Aug 2007)
New Revision: 24763

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

Log:
Allow users to leave out the transport in DCE/RPC binding strings. If the 
transport is not specified, it will be retrieved from the remote endpoint 
mapper or the IDL file.

This means that 'smbtorture localhost RPC-WINREG' works now.
Modified:
   branches/SAMBA_4_0/
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c


Changeset:

Property changes on: branches/SAMBA_4_0
___
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c
===
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c   2007-08-29 
01:48:46 UTC (rev 24762)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_connect.c   2007-08-29 
02:01:56 UTC (rev 24763)
@@ -733,6 +733,14 @@
dcerpc_connect_timeout_handler, c);

switch (s->binding->transport) {
+   case NCA_UNKNOWN: {
+   struct composite_context *binding_req;
+   binding_req = dcerpc_epm_map_binding_send(c, s->binding, 
s->table,
+ 
s->pipe->conn->event_ctx);
+   composite_continue(c, binding_req, continue_map_binding, c);
+   return c;
+   }
+
case NCACN_NP:
case NCACN_IP_TCP:
case NCALRPC:

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c  2007-08-29 01:48:46 UTC 
(rev 24762)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c  2007-08-29 02:01:56 UTC 
(rev 24763)
@@ -531,7 +531,9 @@
return NULL;
 }
 
-static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx, struct 
epm_floor *epm_floor,  const char *data)
+static NTSTATUS dcerpc_floor_set_rhs_data(TALLOC_CTX *mem_ctx, 
+ struct epm_floor *epm_floor,  
+ const char *data)
 {
switch (epm_floor->lhs.protocol) {
case EPM_PROTOCOL_TCP:
@@ -648,7 +650,9 @@
return (unsigned int)-1;
 }
 
-NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, struct epm_tower 
*tower, struct dcerpc_binding **b_out)
+NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx, 
+  struct epm_tower *tower, 
+  struct dcerpc_binding **b_out)
 {
NTSTATUS status;
struct dcerpc_binding *binding;
@@ -932,7 +936,7 @@
/*
  First, check if there is a default endpoint specified in the IDL
*/
-   if (table) {
+   if (table != NULL) {
struct dcerpc_binding *default_binding;
 
/* Find one of the default pipes for this interface */
@@ -940,7 +944,10 @@
status = dcerpc_parse_binding(mem_ctx, 
table->endpoints->names[i], &default_binding);
 
if (NT_STATUS_IS_OK(status)) {
-   if (default_binding->transport == 
binding->transport && default_binding->endpoint) {
+   if (binding->transport == NCA_UNKNOWN) 
+   binding->transport = 
default_binding->transport;
+   if (default_binding->transport == 
binding->transport && 
+   default_binding->endpoint) {
binding->endpoint = 
talloc_reference(binding, default_binding->endpoint);
talloc_free(default_binding);
 
@@ -967,7 +974,8 @@
epmapper_binding->endpoint  = NULL;
 
/* initiate rpc pipe connection */
-   pipe_connect_req = dcerpc_pipe_connect_b_send(c, epmapper_binding, 
&ndr_table_epmapper,
+   pipe_connect_req = dcerpc_pipe_connect_b_send(c, epmapper_binding, 
+ &ndr_table_epmapper,
  anon_creds, c->event_ctx);
if (composite_nomem(pipe_connect_req, c)) return c;




svn commit: samba r24764 - in branches: SAMBA_3_2/source/libaddns SAMBA_3_2_0/source/libaddns

2007-08-28 Thread jra
Author: jra
Date: 2007-08-29 04:06:09 + (Wed, 29 Aug 2007)
New Revision: 24764

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

Log:
Fix second TALLOC_SIZE definition. Still watching the
build farm to see I didn't stuff this up...
Jeremy.

Modified:
   branches/SAMBA_3_2/source/libaddns/dns.h
   branches/SAMBA_3_2_0/source/libaddns/dns.h


Changeset:
Modified: branches/SAMBA_3_2/source/libaddns/dns.h
===
--- branches/SAMBA_3_2/source/libaddns/dns.h2007-08-29 02:01:56 UTC (rev 
24763)
+++ branches/SAMBA_3_2/source/libaddns/dns.h2007-08-29 04:06:09 UTC (rev 
24764)
@@ -116,7 +116,7 @@
 #define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, 
sizeof(type), count, #type)
-#define TALLOC_SIZE(ctx, size) talloc(ctx, size, __location__)
+#define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__)
 #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
 
 #endif

Modified: branches/SAMBA_3_2_0/source/libaddns/dns.h
===
--- branches/SAMBA_3_2_0/source/libaddns/dns.h  2007-08-29 02:01:56 UTC (rev 
24763)
+++ branches/SAMBA_3_2_0/source/libaddns/dns.h  2007-08-29 04:06:09 UTC (rev 
24764)
@@ -116,7 +116,7 @@
 #define TALLOC_ZERO(ctx, size) _talloc_zero(ctx, size, __location__)
 #define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
 #define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, 
sizeof(type), count, #type)
-#define TALLOC_SIZE(ctx, size) talloc(ctx, size, __location__)
+#define TALLOC_SIZE(ctx, size) talloc_named_const(ctx, size, __location__)
 #define TALLOC_ZERO_SIZE(ctx, size) _talloc_zero(ctx, size, __location__)
 
 #endif



svn commit: samba r24765 - in branches/SAMBA_4_0/source/torture/raw: .

2007-08-28 Thread tridge
Author: tridge
Date: 2007-08-29 04:33:26 + (Wed, 29 Aug 2007)
New Revision: 24765

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

Log:

added a RAW-HOLD-OPLOCK test. This is a manual test, meant to be used
to test the interaction of oplocks with local filesystem or NFS
access. You start it, then manually access the 4 files via another
mechanism (such as a shell) and see what oplock breaks you get

Modified:
   branches/SAMBA_4_0/source/torture/raw/oplock.c
   branches/SAMBA_4_0/source/torture/raw/raw.c


Changeset:
Modified: branches/SAMBA_4_0/source/torture/raw/oplock.c
===
--- branches/SAMBA_4_0/source/torture/raw/oplock.c  2007-08-29 04:06:09 UTC 
(rev 24764)
+++ branches/SAMBA_4_0/source/torture/raw/oplock.c  2007-08-29 04:33:26 UTC 
(rev 24765)
@@ -1388,3 +1388,112 @@
talloc_free(mem_ctx);
return ret;
 }
+
+
+static struct hold_oplock_info {
+   const char *fname;
+   bool close_on_break;
+   uint32_t share_access;
+   uint16_t fnum;
+} hold_info[] = {
+   { BASEDIR "\\notshared_close", True,  
+ NTCREATEX_SHARE_ACCESS_NONE, },
+   { BASEDIR "\\notshared_noclose", False, 
+ NTCREATEX_SHARE_ACCESS_NONE, },
+   { BASEDIR "\\shared_close", True,  
+ 
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
 },
+   { BASEDIR "\\shared_noclose", False,  
+ 
NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE,
 },
+};
+
+static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t 
tid, 
+   uint16_t fnum, uint8_t level, void *private)
+{
+   struct smbcli_tree *tree = private;
+   struct hold_oplock_info *info;
+   int i;
+
+   for (i=0;iclose_on_break) {
+   printf("oplock break on %s - closing\n",
+  info->fname);
+   oplock_handler_close(transport, tid, fnum, level, private);
+   return True;
+   }
+
+   printf("oplock break on %s - acking break\n", info->fname);
+
+   return smbcli_oplock_ack(tree, fnum, OPLOCK_BREAK_TO_NONE);
+}
+
+
+/* 
+   used for manual testing of oplocks - especially interaction with
+   other filesystems (such as NFS and local access)
+*/
+BOOL torture_hold_oplock(struct torture_context *torture, 
+struct smbcli_state *cli)
+{
+   struct event_context *ev = cli->transport->socket->event.ctx;
+   int i;
+
+   printf("Setting up open files with oplocks in %s\n", BASEDIR);
+
+   if (!torture_setup_dir(cli, BASEDIR)) {
+   return False;
+   }
+
+   smbcli_oplock_handler(cli->transport, oplock_handler_hold, cli->tree);
+
+   /* setup the files */
+   for (i=0;itree, cli, &io);
+   if (!NT_STATUS_IS_OK(status)) {
+   printf("Failed to open %s - %s\n", 
+  hold_info[i].fname, nt_errstr(status));
+   return False;
+   }
+
+   if (io.ntcreatex.out.oplock_level != BATCH_OPLOCK_RETURN) {
+   printf("Oplock not granted for %s - expected %d but got 
%d\n", 
+  hold_info[i].fname, BATCH_OPLOCK_RETURN, 
+   io.ntcreatex.out.oplock_level);
+   return False;
+   }
+   hold_info[i].fnum = io.ntcreatex.out.file.fnum;
+   }
+
+   printf("Waiting for oplock events\n");
+   event_loop_wait(ev);
+
+   return True;
+}

Modified: branches/SAMBA_4_0/source/torture/raw/raw.c
===
--- branches/SAMBA_4_0/source/torture/raw/raw.c 2007-08-29 04:06:09 UTC (rev 
24764)
+++ branches/SAMBA_4_0/source/torture/raw/raw.c 2007-08-29 04:33:26 UTC (rev 
24765)
@@ -44,6 +44,7 @@
torture_suite_add_1smb_test(suite, "OPEN", torture_raw_open);
torture_suite_add_1smb_test(suite, "MKDIR", torture_raw_mkdir);
torture_suite_add_suite(suite, torture_raw_oplock(suite));
+   torture_suite_add_1smb_test(suite, "HOLD-OPLOCK", torture_hold_oplock);
torture_suite_add_2smb_test(suite, "NOTIFY", torture_raw_notify);
torture_suite_add_1smb_test(suite, "MUX", torture_raw_mux);
torture_suite_add_1smb_test(suite, "IOCTL", torture_raw_ioctl);



svn commit: samba r24766 - in branches/SAMBA_4_0/source: .

2007-08-28 Thread tridge
Author: tridge
Date: 2007-08-29 05:34:20 + (Wed, 29 Aug 2007)
New Revision: 24766

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

Log:

forgot to commit this before. It is needed as this never terminates.

Modified:
   branches/SAMBA_4_0/source/samba4-skip


Changeset:
Modified: branches/SAMBA_4_0/source/samba4-skip
===
--- branches/SAMBA_4_0/source/samba4-skip   2007-08-29 04:33:26 UTC (rev 
24765)
+++ branches/SAMBA_4_0/source/samba4-skip   2007-08-29 05:34:20 UTC (rev 
24766)
@@ -10,6 +10,7 @@
 BASE-BENCH-HOLDCON
 BASE-SCAN-MAXFID
 RAW-BENCH-OPLOCK
+RAW-HOLD-OPLOCK
 RAW-SAMBA3HIDE
 RAW-SAMBA3CLOSEERR
 RAW-SAMBA3CHECKFSP



svn commit: samba r24767 - in branches/SAMBA_4_0/source: . torture torture/raw

2007-08-28 Thread sahlberg
Author: sahlberg
Date: 2007-08-29 05:45:24 + (Wed, 29 Aug 2007)
New Revision: 24767

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

Log:
add a torture test that performs "ping-pong" that works the same way as
ping-pong.c

this is a manual test and only makes sense to be used in parallell with 
the real ping-pong.c tool


Added:
   branches/SAMBA_4_0/source/torture/raw/pingpong.c
Modified:
   branches/SAMBA_4_0/source/samba4-skip
   branches/SAMBA_4_0/source/torture/config.mk
   branches/SAMBA_4_0/source/torture/raw/raw.c


Changeset:
Modified: branches/SAMBA_4_0/source/samba4-skip
===
--- branches/SAMBA_4_0/source/samba4-skip   2007-08-29 05:34:20 UTC (rev 
24766)
+++ branches/SAMBA_4_0/source/samba4-skip   2007-08-29 05:45:24 UTC (rev 
24767)
@@ -11,6 +11,7 @@
 BASE-SCAN-MAXFID
 RAW-BENCH-OPLOCK
 RAW-HOLD-OPLOCK
+RAW-PING-PONG
 RAW-SAMBA3HIDE
 RAW-SAMBA3CLOSEERR
 RAW-SAMBA3CHECKFSP

Modified: branches/SAMBA_4_0/source/torture/config.mk
===
--- branches/SAMBA_4_0/source/torture/config.mk 2007-08-29 05:34:20 UTC (rev 
24766)
+++ branches/SAMBA_4_0/source/torture/config.mk 2007-08-29 05:45:24 UTC (rev 
24767)
@@ -77,6 +77,7 @@
raw/context.o \
raw/write.o \
raw/lock.o \
+   raw/pingpong.o \
raw/lockbench.o \
raw/openbench.o \
raw/rename.o \

Added: branches/SAMBA_4_0/source/torture/raw/pingpong.c
===
--- branches/SAMBA_4_0/source/torture/raw/pingpong.c2007-08-29 05:34:20 UTC 
(rev 24766)
+++ branches/SAMBA_4_0/source/torture/raw/pingpong.c2007-08-29 05:45:24 UTC 
(rev 24767)
@@ -0,0 +1,377 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   ping pong test
+   filename is specified by
+--option=torture:filename=...
+
+   number of locks is specified by
+--option=torture:num_locks=...
+
+   locktimeout is specified in ms by
+--option=torture:locktimeout=...
+
+   default is 100 seconds
+   if set to 0 pingpong will instead loop trying the lock operation
+   over and over until it completes.
+
+   reading from the file can be enabled with
+--option=torture:read=True
+
+   writing to the file can be enabled with
+--option=torture:write=True
+
+
+   Copyright (C) Ronnie Sahlberg
+
+   Significantly based on and borrowed from lockbench.c by
+   Copyright (C) Andrew Tridgell 2006
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see .
+*/
+
+#include "includes.h"
+#include "torture/torture.h"
+#include "libcli/raw/libcliraw.h"
+#include "system/time.h"
+#include "system/filesys.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
+#include "lib/events/events.h"
+#include "lib/cmdline/popt_common.h"
+#include "libcli/composite/composite.h"
+#include "libcli/smb_composite/smb_composite.h"
+
+
+static BOOL do_reads;
+static BOOL do_writes;
+
+static int lock_failed;
+
+enum lock_stage {LOCK_INITIAL, LOCK_LOCK, LOCK_UNLOCK};
+
+struct pingpong_state {
+   struct event_context *ev;
+   struct smbcli_tree *tree;
+   TALLOC_CTX *mem_ctx;
+   int fnum;
+   enum lock_stage stage;
+   int num_locks;
+   int lock_offset;
+   int unlock_offset;
+   struct smbcli_request *req;
+   int count;
+   int lastcount;
+   int lock_timeout;
+   uint8_t c;
+   uint8_t incr;
+   uint8_t last_incr;
+   uint8_t *val;
+};
+
+
+
+static void lock_completion(struct smbcli_request *);
+
+/*
+  send the next lock request
+*/
+static void lock_send(struct pingpong_state *state, BOOL retry_lock)
+{
+   union smb_lock io;
+   struct smb_lock_entry lock;
+
+
+   /* we have completed one lock/unlock pair */
+   if (state->stage == LOCK_UNLOCK) {
+   if ( (state->count > state->num_locks)
+  &&(state->incr != state->last_incr) ) {
+   state->last_incr = state->incr;
+   printf("data increment = %u\n", state->incr);
+   }
+   }
+
+   switch (state->stage) {
+   case LOCK_INITIAL:
+   io.lockx.in.ulock_cnt = 0;
+   io.lockx.in.lock_cnt = 1;
+   state-

svn commit: samba r24768 - in branches/SAMBA_4_0/source/torture/raw: .

2007-08-28 Thread sahlberg
Author: sahlberg
Date: 2007-08-29 06:58:25 + (Wed, 29 Aug 2007)
New Revision: 24768

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

Log:
redo the pingpong torture using sync functions to make the code simpler


Modified:
   branches/SAMBA_4_0/source/torture/raw/pingpong.c


Changeset:
Sorry, the patch is too large (508 lines) to include; please use WebSVN to see 
it!
WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24768