[apparmor] PATCH [2/2] force update of stale cache

John Johansen john.johansen at canonical.com
Tue Sep 14 11:53:06 BST 2010


This patch forces a cache update in the case that There is a cache file
that is present and invalid, and the features of the kernel and cache match.  This is done even if the-W flag is not specified.

Nominated for 2.5.1

 ---
 parser/parser_main.c |   20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

--- master-new.orig/parser/parser_main.c
+++ master-new/parser/parser_main.c
@@ -842,12 +842,20 @@
 		}
 		/* Load a binary cache if it exists and is newest */
 		if (!skip_read_cache &&
-		    stat(cachename, &stat_bin) == 0 &&
-		    stat_bin.st_size > 0 && (mru_t_cmp(stat_bin.st_mtim))) {
-			if (show_cache)
-				PERROR("Cache hit: %s\n", cachename);
-			retval = process_binary(option, cachename);
-			goto out;
+		    stat(cachename, &stat_bin) == 0 && stat_bin.st_size > 0) {
+			if ((mru_t_cmp(stat_bin.st_mtim))) {
+				if (show_cache)
+					PERROR("Cache hit: %s\n", cachename);
+				retval = process_binary(option, cachename);
+				goto out;
+			} else {
+				/* features match, cache file exists and is
+				 * out of date, force update of cache
+				 */
+				if (show_cache)
+					PERROR("Cache stale forcing update: %s\n", cachename);
+				write_cache = 1;
+			}
 		}
 		if (write_cache) {
 			/* Otherwise, set up to save a cached copy */



More information about the AppArmor mailing list