[chrony-dev] Patch for chown warnings.

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Here is a suggestion re the chown warning-- the program can only chown if the
user is root so there is no point in trying if not. If the old user of those
old drift files no longer exists, then the chown will not work. Not sure if
this should be in WARN or INFO. log


- William G. Unruh | Canadian Institute for| Tel: +1(604)822-3273
Physics&Astronomy  |     Advanced Research  |     Fax: +1(604)822-5324
UBC, Vancouver,BC  |   Program in Cosmology |     unruh@xxxxxxxxxxxxxx
Canada V6T 1Z1     |      and Gravity       |  www.theory.physics.ubc.ca/
diff -Naur chrony-1.24.pre1/reference.c chrony-1.24.pre1.new/reference.c
--- chrony-1.24.pre1/reference.c	2009-12-15 07:07:34.000000000 -0800
+++ chrony-1.24.pre1.new/reference.c	2009-12-19 21:54:41.000000000 -0800
@@ -246,7 +246,10 @@
   /* Clone the file attributes from the existing file if there is one. */
 
   if (!stat(drift_file,&buf)) {
-    chown(temp_drift_file,buf.st_uid,buf.st_gid);
+    if (geteuid() == 0){
+      if (!chown(temp_drift_file,buf.st_uid,buf.st_gid))
+	    LOG(LOG_INFO,LOGF_Reference,"Could not change ownsership of drift file %s",temp_drift_file);
+    }
     chmod(temp_drift_file,buf.st_mode&0777);
   }
 
diff -Naur chrony-1.24.pre1/rtc_linux.c chrony-1.24.pre1.new/rtc_linux.c
--- chrony-1.24.pre1/rtc_linux.c	2009-12-15 07:07:34.000000000 -0800
+++ chrony-1.24.pre1.new/rtc_linux.c	2009-12-19 21:55:53.000000000 -0800
@@ -511,7 +511,10 @@
   /* Clone the file attributes from the existing file if there is one. */
 
   if (!stat(coefs_file_name,&buf)) {
-    chown(temp_coefs_file_name,buf.st_uid,buf.st_gid);
+     if (geteuid() == 0){
+       if (!chown(temp_coefs_file_name,buf.st_uid,buf.st_gid))
+	                   LOG(LOG_INFO,LOGF_RtcLinux,"Could not change ownsership of rtc drift file %s",temp_coefs_file_name);
+     }
     chmod(temp_coefs_file_name,buf.st_mode&0777);
   }
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/