Rev 5363: merge from upstream in http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/

Michael Adam ma at sernet.de
Sun Apr 15 22:50:59 GMT 2007


At http://samba.sernet.de/ma/bzr/SAMBA_3_0-registry.bzr/

------------------------------------------------------------
revno: 5363
revision-id: ma at sernet.de-20070415225054-98f15a01f998d3c6
parent: ma at sernet.de-20070415224610-fc21b5e8b650cff4
parent: vlendec at samba.org-20070414110415-pcc5u5ltrtes11qn
committer: Michael Adam <ma at sernet.de>
branch nick: SAMBA_3_0-registry.bzr
timestamp: Mon 2007-04-16 00:50:54 +0200
message:
  merge from upstream
modified:
  REVISION                       REVISION-20060530022625-68239662668b41c3
  source/lib/debug.c             debug.c-20060530022627-f23cb2ef8f91a8a6
  source/libsmb/clientgen.c      clientgen.c-20060530022627-3aad65ce54001b6b
  source/nsswitch/idmap.c        idmap.c-20061212152801-ke1ub3n5v1jjf8gy-1
  source/nsswitch/winbindd.c     winbindd.c-20060530022627-8bb76c46bd1253ec
  source/nsswitch/winbindd_cache.c winbindd_cache.c-20060530022627-45b83e217d38566d
  source/smbd/process.c          process.c-20060530022627-8fe40017fe0e41ff
    ------------------------------------------------------------
    merged: vlendec at samba.org-20070414110415-pcc5u5ltrtes11qn
    parent: vlendec at samba.org-20070414110156-dy0a166chepd8utj
    committer: vlendec at samba.org
    branch nick: SAMBA_3_0.bzr
    timestamp: Sat 2007-04-14 06:04:15 -0500
    message:
      vlendec at samba.org (r22214)  2007-04-14 01:44:30 -0500 (Sat, 14 Apr 2007)
          
          Fix incompatible pointer type warnings. Simo, please check and merge to 3_0_25
          if appropriate.
          
          Volker
          
    ------------------------------------------------------------
    merged: vlendec at samba.org-20070414110156-dy0a166chepd8utj
    parent: jra at samba.org-20070414050143-8qtyziv9z78jp4i6
    committer: vlendec at samba.org
    branch nick: SAMBA_3_0.bzr
    timestamp: Sat 2007-04-14 06:01:56 -0500
    message:
      vlendec at samba.org (r22213)  2007-04-14 01:40:47 -0500 (Sat, 14 Apr 2007)
          
          We can't use become_root() here, as it does DEBUG()
          itself. become_root_uid_only did not :-)
          
          Revert 21868, we need to find a better way.
          
          Volker
          
    ------------------------------------------------------------
    merged: jra at samba.org-20070414050143-8qtyziv9z78jp4i6
    parent: jra at samba.org-20070413231018-ceqp55p89wao4cb1
    committer: jra at samba.org
    branch nick: SAMBA_3_0.bzr
    timestamp: Sat 2007-04-14 00:01:43 -0500
    message:
      jra at samba.org (r22212)  2007-04-13 19:53:38 -0500 (Fri, 13 Apr 2007)
          
          Cope with signature errors on sessionsetupX logins
          where the server just reflects our signature back
          to us. Allow the upper layer to see the real error.
          Jeremy.
          
    ------------------------------------------------------------
    merged: jra at samba.org-20070413231018-ceqp55p89wao4cb1
    parent: jra at samba.org-20070413230750-83afp6hivtgnwx23
    committer: jra at samba.org
    branch nick: SAMBA_3_0.bzr
    timestamp: Fri 2007-04-13 18:10:18 -0500
    message:
      jra at samba.org (r22211)  2007-04-13 17:56:27 -0500 (Fri, 13 Apr 2007)
          
          Don't return a value from void functions !
          Jeremy.
          
    ------------------------------------------------------------
    merged: jra at samba.org-20070413230750-83afp6hivtgnwx23
    parent: jra at samba.org-20070413230259-01ilq20r9vo86gdy
    committer: jra at samba.org
    branch nick: SAMBA_3_0.bzr
    timestamp: Fri 2007-04-13 18:07:50 -0500
    message:
      jra at samba.org (r22210)  2007-04-13 17:42:21 -0500 (Fri, 13 Apr 2007)
          
          Fix typo in testing for non-centry entries.
          Jeremy.
          
    ------------------------------------------------------------
    merged: jra at samba.org-20070413230259-01ilq20r9vo86gdy
    parent: jra at samba.org-20070413050503-g5oyr7tnheeb3fc3
    committer: jra at samba.org
    branch nick: SAMBA_3_0.bzr
    timestamp: Fri 2007-04-13 18:02:59 -0500
    message:
      jra at samba.org (r22209)  2007-04-13 17:29:50 -0500 (Fri, 13 Apr 2007)
          
          Fix the storage of time_t -> make it 64 bits (use the
          same load/store function as NTTIME). Add a version number
          string to the winbindd cache so we can tell if it needs
          upgrading. THIS WILL DELETE ANY EXISTING winbindd_cache.tdb
          on first startup regardless of offline auth status. Once
          this is done we're in good shape though.
          Jeremy.
          
=== modified file 'REVISION'
--- a/REVISION	2007-04-13 05:05:03 +0000
+++ b/REVISION	2007-04-14 11:04:15 +0000
@@ -2,9 +2,9 @@
 URL: svn+ssh://svn.samba.org/home/svn/samba/branches/SAMBA_3_0
 Repository Root: svn+ssh://svn.samba.org/home/svn/samba
 Repository UUID: 0c0555d6-39d7-0310-84fc-f1cc0bd64818
-Revision: 22207
+Revision: 22214
 Node Kind: directory
-Last Changed Author: jra
-Last Changed Rev: 22207
-Last Changed Date: 2007-04-12 20:46:47 -0500 (Thu, 12 Apr 2007)
+Last Changed Author: vlendec
+Last Changed Rev: 22214
+Last Changed Date: 2007-04-14 01:44:30 -0500 (Sat, 14 Apr 2007)
 

=== modified file 'source/lib/debug.c'
--- a/source/lib/debug.c	2007-04-06 05:01:25 +0000
+++ b/source/lib/debug.c	2007-04-14 11:01:56 +0000
@@ -688,15 +688,20 @@
 	int         maxlog;
 	SMB_STRUCT_STAT st;
 
+	/*
+	 *  We need to be root to check/change log-file, skip this and let the main
+	 *  loop check do a new check as root.
+	 */
+
+	if( geteuid() != 0 )
+		return;
+
 	if(log_overflow || !need_to_check_log_size() )
 		return;
 
 	maxlog = lp_max_log_size() * 1024;
 
 	if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
-
-		become_root();
-
 		(void)reopen_logs();
 		if( dbf && get_file_size( debugf ) > maxlog ) {
 			pstring name;
@@ -709,8 +714,6 @@
 				(void)rename(name, debugf);
 			}
 		}
-
-		unbecome_root();
 	}
 
 	/*

=== modified file 'source/libsmb/clientgen.c'
--- a/source/libsmb/clientgen.c	2007-03-30 15:36:50 +0000
+++ b/source/libsmb/clientgen.c	2007-04-14 05:01:43 +0000
@@ -139,6 +139,26 @@
 	}
 
 	if (!cli_check_sign_mac(cli)) {
+		/*
+		 * If we get a signature failure in sessionsetup, then
+		 * the server sometimes just reflects the sent signature
+		 * back to us. Detect this and allow the upper layer to
+		 * retrieve the correct Windows error message.
+		 */
+		if (CVAL(cli->outbuf,smb_com) == SMBsesssetupX &&
+			(smb_len(cli->inbuf) > (smb_ss_field + 8 - 4)) &&
+			(SVAL(cli->inbuf,smb_flg2) & FLAGS2_SMB_SECURITY_SIGNATURES) &&
+			memcmp(&cli->outbuf[smb_ss_field],&cli->inbuf[smb_ss_field],8) == 0 &&
+			cli_is_error(cli)) {
+
+			/*
+			 * Reflected signature on login error. 
+			 * Set bad sig but don't close fd.
+			 */
+			cli->smb_rw_error = READ_BAD_SIG;
+			return True;
+		}
+
 		DEBUG(0, ("SMB Signature verification failed on incoming packet!\n"));
 		cli->smb_rw_error = READ_BAD_SIG;
 		close(cli->fd);

=== modified file 'source/nsswitch/idmap.c'
--- a/source/nsswitch/idmap.c	2007-04-12 23:04:30 +0000
+++ b/source/nsswitch/idmap.c	2007-04-14 11:04:15 +0000
@@ -828,7 +828,11 @@
 		wbret = winbind_lookup_sid(ctx, map->sid, &domname, &name, &sid_type);
 		winbind_off();
 	} else {
-		wbret = winbindd_lookup_name_by_sid(ctx, map->sid, &domname, &name, &sid_type);
+		char *tmp_dom, *tmp_name;
+		wbret = winbindd_lookup_name_by_sid(ctx, map->sid, &tmp_dom,
+						    &tmp_name, &sid_type);
+		domname = tmp_dom;
+		name = tmp_name;
 	}
 
 	/* check if this is a valid SID and then map it */

=== modified file 'source/nsswitch/winbindd.c'
--- a/source/nsswitch/winbindd.c	2007-04-12 23:04:30 +0000
+++ b/source/nsswitch/winbindd.c	2007-04-13 23:02:59 +0000
@@ -1081,6 +1081,11 @@
 		exit(1);
 	}
 	
+	/* Initialize cache (ensure version is correct). */
+	if (!initialize_winbindd_cache()) {
+		exit(1);
+	}
+
 	/* React on 'smbcontrol winbindd reload-config' in the same way
 	   as to SIGHUP signal */
 	message_register(MSG_SMB_CONF_UPDATED, msg_reload_services, NULL);

=== modified file 'source/nsswitch/winbindd_cache.c'
--- a/source/nsswitch/winbindd_cache.c	2007-04-13 05:05:03 +0000
+++ b/source/nsswitch/winbindd_cache.c	2007-04-13 23:10:18 +0000
@@ -29,12 +29,53 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_WINBIND
 
+#define WINBINDD_CACHE_VERSION 1
+#define WINBINDD_CACHE_VERSION_KEYSTR "WINBINDD_CACHE_VERSION"
+
 extern struct winbindd_methods reconnect_methods;
 extern BOOL opt_nocache;
 #ifdef HAVE_ADS
 extern struct winbindd_methods ads_methods;
 #endif
 
+/*
+ * JRA. KEEP THIS LIST UP TO DATE IF YOU ADD CACHE ENTRIES.
+ * Here are the list of entry types that are *not* stored
+ * as form struct cache_entry in the cache.
+ */
+
+static const char *non_centry_keys[] = {
+	"SEQNUM/",
+	"DR/",
+	"DE/",
+	"WINBINDD_OFFLINE",
+	WINBINDD_CACHE_VERSION_KEYSTR,
+	NULL
+};
+
+/************************************************************************
+ Is this key a non-centry type ?
+************************************************************************/
+
+static BOOL is_non_centry_key(TDB_DATA kbuf)
+{
+	int i;
+
+	if (kbuf.dptr == NULL || kbuf.dsize == 0) {
+		return False;
+	}
+	for (i = 0; non_centry_keys[i] != NULL; i++) {
+		size_t namelen = strlen(non_centry_keys[i]);
+		if (kbuf.dsize < namelen) {
+			continue;
+		}
+		if (strncmp(non_centry_keys[i], (const char *)kbuf.dptr, namelen) == 0) {
+			return True;
+		}
+	}
+	return False;
+}
+
 /* Global online/offline state - False when online. winbindd starts up online
    and sets this to true if the first query fails and there's an entry in
    the cache tdb telling us to stay offline. */
@@ -237,18 +278,11 @@
 }
 
 /*
-  pull a time_t from a cache entry 
+  pull a time_t from a cache entry. time_t stored portably as a 64-bit time.
 */
 static time_t centry_time(struct cache_entry *centry)
 {
-	time_t ret;
-	if (centry_check_bytes(centry, sizeof(time_t))) {
-		smb_panic_fn("centry_time");
-		return (time_t)-1;
-	}
-	ret = IVAL(centry->data, centry->ofs); /* FIXME: correct ? */
-	centry->ofs += sizeof(time_t);
-	return ret;
+	return (time_t)centry_nttime(centry);
 }
 
 /* pull a string from a cache entry, using the supplied
@@ -719,13 +753,13 @@
 }
 
 /*
-  push a time_t into a centry 
+  push a time_t into a centry - use a 64 bit size.
+  NTTIME here is being used as a convenient 64-bit size.
 */
 static void centry_put_time(struct cache_entry *centry, time_t t)
 {
-	centry_expand(centry, sizeof(time_t));
-	SIVAL(centry->data, centry->ofs, t); /* FIXME: is this correct ?? */
-	centry->ofs += sizeof(time_t);
+	NTTIME nt = (NTTIME)t;
+	centry_put_nttime(centry, nt);
 }
 
 /*
@@ -2164,6 +2198,61 @@
 	return True;
 }
 
+/************************************************************************
+ This is called by the parent to initialize the cache file.
+ We don't need sophisticated locking here as we know we're the
+ only opener.
+************************************************************************/
+
+BOOL initialize_winbindd_cache(void)
+{
+	BOOL cache_bad = True;
+	uint32 vers;
+
+	if (!init_wcache()) {
+		DEBUG(0,("initialize_winbindd_cache: init_wcache failed.\n"));
+		return False;
+	}
+
+	/* Check version number. */
+	if (tdb_fetch_uint32(wcache->tdb, WINBINDD_CACHE_VERSION_KEYSTR, &vers) &&
+			vers == WINBINDD_CACHE_VERSION) {
+		cache_bad = False;
+	}
+
+	if (cache_bad) {
+		DEBUG(0,("initialize_winbindd_cache: clearing cache "
+			"and re-creating with version number %d\n",
+			WINBINDD_CACHE_VERSION ));
+
+		tdb_close(wcache->tdb);
+		wcache->tdb = NULL;
+
+		if (unlink(lock_path("winbindd_cache.tdb")) == -1) {
+			DEBUG(0,("initialize_winbindd_cache: unlink %s failed %s ",
+				lock_path("winbindd_cache.tdb"),
+				strerror(errno) ));
+			return False;
+		}
+		if (!init_wcache()) {
+			DEBUG(0,("initialize_winbindd_cache: re-initialization "
+					"init_wcache failed.\n"));
+			return False;
+		}
+
+		/* Write the version. */
+		if (!tdb_store_uint32(wcache->tdb, WINBINDD_CACHE_VERSION_KEYSTR, WINBINDD_CACHE_VERSION)) {
+			DEBUG(0,("initialize_winbindd_cache: version number store failed %s\n",
+				tdb_errorstr(wcache->tdb) ));
+			return False;
+		}
+	}
+
+	tdb_close(wcache->tdb);
+	wcache->tdb = NULL;
+	return True;
+}
+
 void cache_store_response(pid_t pid, struct winbindd_response *response)
 {
 	fstring key_str;
@@ -2360,12 +2449,21 @@
 				sid, type);
 }
 
-/* delete all centries that don't have NT_STATUS_OK set */
+/*
+ * The original idea that this cache only contains centries has
+ * been blurred - now other stuff gets put in here. Ensure we
+ * ignore these things on cleanup.
+ */
+
 static int traverse_fn_cleanup(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, 
 			       TDB_DATA dbuf, void *state)
 {
 	struct cache_entry *centry;
 
+	if (is_non_centry_key(kbuf)) {
+		return 0;
+	}
+
 	centry = wcache_fetch_raw((char *)kbuf.dptr);
 	if (!centry) {
 		return 0;

=== modified file 'source/smbd/process.c'
--- a/source/smbd/process.c	2007-04-09 23:02:01 +0000
+++ b/source/smbd/process.c	2007-04-14 11:01:56 +0000
@@ -1406,6 +1406,13 @@
   
 	update_monitored_printq_cache();
   
+	/*
+	 * Now we are root, check if the log files need pruning.
+	 * Force a log file check.
+	 */
+	force_check_log_size();
+	check_log_size();
+
 	/* Send any queued printer notify message to interested smbd's. */
 
 	print_notify_send_messages(0);



More information about the samba-cvs mailing list