krb5 commit: Avoid rereading non-regular profile files
Greg Hudson
ghudson at mit.edu
Mon Mar 19 20:28:37 EDT 2018
https://github.com/krb5/krb5/commit/2c26419ad7ea4800995180292ce39db863672fa9
commit 2c26419ad7ea4800995180292ce39db863672fa9
Author: Greg Hudson <ghudson at mit.edu>
Date: Sun Mar 18 21:41:02 2018 -0400
Avoid rereading non-regular profile files
If a profile file is a special device such as a pipe, then reloading
it will cause us to discard its contents. Repurpose the first
PROFILE_FILE flag bit to indicate that the file should not be
reloaded. In profile_update_file_data_locked(), set the flag on the
first load if stat() doesn't indicate a regular file, and check the
flag before testing whether we need to perform any subsequent reload.
Later on in profile_update_file_data_locked(), specifically unset the
DIRTY flag rather than unsetting all flags other than SHARED, so that
we don't clear the NO_RELOAD flag.
ticket: 8651
src/util/profile/prof_file.c | 9 ++++++++-
src/util/profile/prof_int.h | 5 +----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c
index 907c119..e80a1d7 100644
--- a/src/util/profile/prof_file.c
+++ b/src/util/profile/prof_file.c
@@ -312,6 +312,9 @@ errcode_t profile_update_file_data_locked(prf_data_t data, char **ret_modspec)
FILE *f;
int isdir = 0;
+ if ((data->flags & PROFILE_FILE_NO_RELOAD) && data->root != NULL)
+ return 0;
+
#ifdef HAVE_STAT
now = time(0);
if (now == data->last_stat && data->root != NULL) {
@@ -339,6 +342,10 @@ errcode_t profile_update_file_data_locked(prf_data_t data, char **ret_modspec)
profile_free_node(data->root);
data->root = 0;
}
+
+ /* Only try to reload regular files, not devices such as pipes. */
+ if ((st.st_mode & S_IFMT) != S_IFREG)
+ data->flags |= PROFILE_FILE_NO_RELOAD;
#else
/*
* If we don't have the stat() call, assume that our in-core
@@ -362,7 +369,7 @@ errcode_t profile_update_file_data_locked(prf_data_t data, char **ret_modspec)
}
data->upd_serial++;
- data->flags &= PROFILE_FILE_SHARED; /* FIXME same as '=' operator */
+ data->flags &= ~PROFILE_FILE_DIRTY;
if (isdir) {
retval = profile_process_directory(data->filespec, &data->root);
diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h
index 73f7fad..b42fd7b 100644
--- a/src/util/profile/prof_int.h
+++ b/src/util/profile/prof_int.h
@@ -72,11 +72,8 @@ typedef struct _prf_file_t *prf_file_t;
/*
* The profile flags
- *
- * Deprecated use of read/write profile flag.
- * Check whether file is writable lazily so we don't call access as often.
*/
-#define PROFILE_FILE_DEPRECATED_RW 0x0001
+#define PROFILE_FILE_NO_RELOAD 0x0001
#define PROFILE_FILE_DIRTY 0x0002
#define PROFILE_FILE_SHARED 0x0004
More information about the cvs-krb5
mailing list