configure: make default hwclockfile configurable

This commit is contained in:
Miroslav Lichvar 2015-10-08 10:44:23 +02:00
parent 00a6394b48
commit 32f8bec92d
4 changed files with 15 additions and 5 deletions

View file

@ -1595,9 +1595,11 @@ NTP, reference clocks or manual input.
@node hwclockfile directive @node hwclockfile directive
@subsection hwclockfile @subsection hwclockfile
The @code{hwclockfile} directive sets the location of the adjtime file which is 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} used by the @file{/sbin/hwclock} program on Linux. @code{chronyd} parses the
will parse the file to find out if the RTC keeps local time or UTC. It file to find out if the RTC keeps local time or UTC. It overrides the
overrides the @code{rtconutc} directive (@pxref{rtconutc directive}). @code{rtconutc} directive (@pxref{rtconutc directive}).
The default value is @file{@DEFAULT_HWCLOCK_FILE@}.
An example of the command is An example of the command is

3
conf.c
View file

@ -124,7 +124,7 @@ static int enable_manual=0;
static int rtc_on_utc = 0; static int rtc_on_utc = 0;
/* Filename used to read the hwclock(8) LOCAL/UTC setting */ /* 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 */ /* Flag set if the RTC should be automatically synchronised by kernel */
static int rtc_sync = 0; static int rtc_sync = 0;
@ -324,6 +324,7 @@ CNF_Initialise(int r)
bind_cmd_path = Strdup(DEFAULT_COMMAND_SOCKET); bind_cmd_path = Strdup(DEFAULT_COMMAND_SOCKET);
pidfile = Strdup("/var/run/chronyd.pid"); pidfile = Strdup("/var/run/chronyd.pid");
rtc_device = Strdup("/dev/rtc"); rtc_device = Strdup("/dev/rtc");
hwclock_file = Strdup(DEFAULT_HWCLOCK_FILE);
user = Strdup(DEFAULT_USER); user = Strdup(DEFAULT_USER);
} }

7
configure vendored
View file

@ -102,6 +102,7 @@ For better control, use the options below.
--with-ntp-era=SECONDS Specify earliest assumed NTP time in seconds --with-ntp-era=SECONDS Specify earliest assumed NTP time in seconds
since 1970-01-01 [50*365 days ago] since 1970-01-01 [50*365 days ago]
--with-user=USER Specify default chronyd user [root] --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] --with-sendmail=PATH Path to sendmail binary [/usr/lib/sendmail]
--enable-debug Enable debugging support --enable-debug Enable debugging support
@ -214,6 +215,7 @@ feat_asyncdns=1
feat_forcednsretry=1 feat_forcednsretry=1
ntp_era_split="" ntp_era_split=""
default_user="root" default_user="root"
default_hwclockfile=""
mail_program="/usr/lib/sendmail" mail_program="/usr/lib/sendmail"
for option for option
@ -321,6 +323,9 @@ do
--with-user=* ) --with-user=* )
default_user=`echo $option | sed -e 's/^.*=//;'` default_user=`echo $option | sed -e 's/^.*=//;'`
;; ;;
--with-hwclockfile=* )
default_hwclockfile=`echo $option | sed -e 's/^.*=//;'`
;;
--with-sendmail=* ) --with-sendmail=* )
mail_program=`echo $option | sed -e 's/^.*=//;'` mail_program=`echo $option | sed -e 's/^.*=//;'`
;; ;;
@ -784,6 +789,7 @@ if [ "x$SETCHRONYVARDIR" != "x" ]; then
fi fi
add_def DEFAULT_CONF_FILE "\"$SYSCONFDIR/chrony.conf\"" add_def DEFAULT_CONF_FILE "\"$SYSCONFDIR/chrony.conf\""
add_def DEFAULT_HWCLOCK_FILE "\"$default_hwclockfile\""
add_def DEFAULT_USER "\"$default_user\"" add_def DEFAULT_USER "\"$default_user\""
add_def DEFAULT_COMMAND_SOCKET "\"$CHRONYSOCKDIR/chronyd.sock\"" add_def DEFAULT_COMMAND_SOCKET "\"$CHRONYSOCKDIR/chronyd.sock\""
add_def MAIL_PROGRAM "\"$mail_program\"" add_def MAIL_PROGRAM "\"$mail_program\""
@ -824,6 +830,7 @@ do
s%@LOCALSTATEDIR@%${LOCALSTATEDIR}%;\ s%@LOCALSTATEDIR@%${LOCALSTATEDIR}%;\
s%@CHRONYSOCKDIR@%${CHRONYSOCKDIR}%;\ s%@CHRONYSOCKDIR@%${CHRONYSOCKDIR}%;\
s%@CHRONYVARDIR@%${CHRONYVARDIR}%;\ s%@CHRONYVARDIR@%${CHRONYVARDIR}%;\
s%@DEFAULT_HWCLOCK_FILE@%${default_hwclockfile}%;\
s%@DEFAULT_USER@%${default_user}%;"\ s%@DEFAULT_USER@%${default_user}%;"\
< ${f}.in > $f < ${f}.in > $f
done done

View file

@ -382,7 +382,7 @@ read_hwclock_file(const char *hwclock_file)
char line[256]; char line[256];
int i; int i;
if (!hwclock_file) if (!hwclock_file || !hwclock_file[0])
return; return;
in = fopen(hwclock_file, "r"); in = fopen(hwclock_file, "r");