]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
configure: make default hwclockfile configurable
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 8 Oct 2015 08:44:23 +0000 (10:44 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 8 Oct 2015 13:20:32 +0000 (15:20 +0200)
chrony.texi.in
conf.c
configure
rtc_linux.c

index 95ae47d47307e764ae314261db9d77aaf5ee91e0..c9b7e43a7eac8d7fb2b1cb8662755ef4d250e0cc 100644 (file)
@@ -1595,9 +1595,11 @@ NTP, reference clocks or manual input.
 @node hwclockfile directive
 @subsection hwclockfile
 The @code{hwclockfile} directive sets the location of the adjtime file which is
-used by the @file{/sbin/hwclock} program.  With this directive, @code{chronyd}
-will parse the file to find out if the RTC keeps local time or UTC.  It
-overrides the @code{rtconutc} directive (@pxref{rtconutc directive}).
+used by the @file{/sbin/hwclock} program on Linux.  @code{chronyd} parses the
+file to find out if the RTC keeps local time or UTC.  It overrides the
+@code{rtconutc} directive (@pxref{rtconutc directive}).
+
+The default value is @file{@DEFAULT_HWCLOCK_FILE@}.
 
 An example of the command is
 
diff --git a/conf.c b/conf.c
index 25a5705ecfef837bd2e65969e7a52b324abca3de..5cec3979ea0ed72e6b2ce2071a4a42b50a3f0d4d 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -124,7 +124,7 @@ static int enable_manual=0;
 static int rtc_on_utc = 0;
 
 /* Filename used to read the hwclock(8) LOCAL/UTC setting */
-static char *hwclock_file = NULL;
+static char *hwclock_file;
 
 /* Flag set if the RTC should be automatically synchronised by kernel */
 static int rtc_sync = 0;
@@ -324,6 +324,7 @@ CNF_Initialise(int r)
   bind_cmd_path = Strdup(DEFAULT_COMMAND_SOCKET);
   pidfile = Strdup("/var/run/chronyd.pid");
   rtc_device = Strdup("/dev/rtc");
+  hwclock_file = Strdup(DEFAULT_HWCLOCK_FILE);
   user = Strdup(DEFAULT_USER);
 }
 
index a775a31cfdba2f95bfcf3fd37e8e83074dd5f9e2..c33c2a57912788679d8b3e41a7043d5f302289f1 100755 (executable)
--- a/configure
+++ b/configure
@@ -102,6 +102,7 @@ For better control, use the options below.
   --with-ntp-era=SECONDS Specify earliest assumed NTP time in seconds
                          since 1970-01-01 [50*365 days ago]
   --with-user=USER       Specify default chronyd user [root]
+  --with-hwclockfile=PATH Specify default path to hwclock(8) adjtime file
   --with-sendmail=PATH   Path to sendmail binary [/usr/lib/sendmail]
   --enable-debug         Enable debugging support
 
@@ -214,6 +215,7 @@ feat_asyncdns=1
 feat_forcednsretry=1
 ntp_era_split=""
 default_user="root"
+default_hwclockfile=""
 mail_program="/usr/lib/sendmail"
 
 for option
@@ -321,6 +323,9 @@ do
     --with-user=* )
       default_user=`echo $option | sed -e 's/^.*=//;'`
     ;;
+    --with-hwclockfile=* )
+      default_hwclockfile=`echo $option | sed -e 's/^.*=//;'`
+    ;;
     --with-sendmail=* )
       mail_program=`echo $option | sed -e 's/^.*=//;'`
     ;;
@@ -784,6 +789,7 @@ if [ "x$SETCHRONYVARDIR" != "x" ]; then
 fi
 
 add_def DEFAULT_CONF_FILE "\"$SYSCONFDIR/chrony.conf\""
+add_def DEFAULT_HWCLOCK_FILE "\"$default_hwclockfile\""
 add_def DEFAULT_USER "\"$default_user\""
 add_def DEFAULT_COMMAND_SOCKET "\"$CHRONYSOCKDIR/chronyd.sock\""
 add_def MAIL_PROGRAM "\"$mail_program\""
@@ -824,6 +830,7 @@ do
           s%@LOCALSTATEDIR@%${LOCALSTATEDIR}%;\
           s%@CHRONYSOCKDIR@%${CHRONYSOCKDIR}%;\
           s%@CHRONYVARDIR@%${CHRONYVARDIR}%;\
+          s%@DEFAULT_HWCLOCK_FILE@%${default_hwclockfile}%;\
           s%@DEFAULT_USER@%${default_user}%;"\
           < ${f}.in > $f
 done
index d1c3aab7f31e218ea23eaa08352671c6242e25f0..86d8261aaaef724a1093951d67e0d94a7f9666c6 100644 (file)
@@ -382,7 +382,7 @@ read_hwclock_file(const char *hwclock_file)
   char line[256];
   int i;
 
-  if (!hwclock_file)
+  if (!hwclock_file || !hwclock_file[0])
     return;
 
   in = fopen(hwclock_file, "r");