]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
reference: don't clone file attributes of drift file
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 22 Oct 2019 10:31:03 +0000 (12:31 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 Oct 2019 09:03:47 +0000 (11:03 +0200)
When replacing an existing drift file with the temporary file, don't
change the ownership or permissions of the temporary file to match the
old drift file, as if it didn't exist.

reference.c

index b40ae381a78040291c9a8395654917a509fa7aa1..9507d4e2e3b56e72c97ccf7c2cafa7cc64b3f2d2 100644 (file)
@@ -336,7 +336,6 @@ REF_GetLeapMode(void)
 static void
 update_drift_file(double freq_ppm, double skew)
 {
-  struct stat buf;
   char *temp_drift_file;
   FILE *out;
   int r1, r2;
@@ -370,16 +369,6 @@ update_drift_file(double freq_ppm, double skew)
     return;
   }
 
-  /* Clone the file attributes from the existing file if there is one. */
-
-  if (!stat(drift_file,&buf)) {
-    if (chown(temp_drift_file,buf.st_uid,buf.st_gid) ||
-        chmod(temp_drift_file,buf.st_mode & 0777)) {
-      LOG(LOGS_WARN, "Could not change ownership or permissions of temporary driftfile %s.tmp",
-          drift_file);
-    }
-  }
-
   /* Rename the temporary file to the correct location (see rename(2) for details). */
 
   if (rename(temp_drift_file,drift_file)) {