]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Avoid rereading non-regular profile files 748/head
authorGreg Hudson <ghudson@mit.edu>
Mon, 19 Mar 2018 01:41:02 +0000 (21:41 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 20 Mar 2018 00:13:40 +0000 (20:13 -0400)
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
src/util/profile/prof_int.h

index 907c119bb67abc510cdb9cbd80fefad28ae88a03..e80a1d7aa05a2403175bd04e9d55127e142a8ec2 100644 (file)
@@ -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);
index 73f7fad47b264cdedd9679c2bb0f9783845d26f4..b42fd7b491df2bfa1451910700bed6a0dcc8d7c3 100644 (file)
@@ -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