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

rtc_linux.c

index d4d9bd085ef319af256b886f714f97b5ffe9f773..ae9a3fa85e11c5811a1c72cf60f9742b72e09b3d 100644 (file)
@@ -466,7 +466,6 @@ read_coefs_from_file(void)
 static int
 write_coefs_to_file(int valid,time_t ref_time,double offset,double rate)
 {
-  struct stat buf;
   char *temp_coefs_file_name;
   FILE *out;
   int r1, r2;
@@ -501,17 +500,6 @@ write_coefs_to_file(int valid,time_t ref_time,double offset,double rate)
     return RTC_ST_BADFILE;
   }
 
-  /* Clone the file attributes from the existing file if there is one. */
-
-  if (!stat(coefs_file_name,&buf)) {
-    if (chown(temp_coefs_file_name,buf.st_uid,buf.st_gid) ||
-        chmod(temp_coefs_file_name,buf.st_mode & 0777)) {
-      LOG(LOGS_WARN,
-          "Could not change ownership or permissions of temporary RTC file %s.tmp",
-          coefs_file_name);
-    }
-  }
-
   /* Rename the temporary file to the correct location (see rename(2) for details). */
 
   if (rename(temp_coefs_file_name,coefs_file_name)) {