From: Greg Hudson Date: Mon, 19 Mar 2018 01:41:02 +0000 (-0400) Subject: Avoid rereading non-regular profile files X-Git-Tag: krb5-1.17-beta1~160 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F748%2Fhead;p=thirdparty%2Fkrb5.git 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 --- diff --git a/src/util/profile/prof_file.c b/src/util/profile/prof_file.c index 907c119bb6..e80a1d7aa0 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 73f7fad47b..b42fd7b491 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