FS#30927 - [initscripts] rc.sysinit does not properly compare $HARDWARECLOCK with the value in /etc/adjtime

Attached to Project: Arch Linux
Opened by James Gordon (drwitherstone) - Monday, 30 July 2012, 18:45 GMT
Last edited by Tom Gundersen (tomegun) - Wednesday, 01 August 2012, 23:39 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Tom Gundersen (tomegun)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
The test "[[ $ADJTIME == 'LOCAL' ]]" at line 144 of rc.sysinit always returns false, because $ADJTIME is always empty.

Replacing the parentheses with curly braces on line 142 would fix the problem.

I.e.
{ read ; read ; read ADJTIME; } < /etc/adjtime
instead of
( read ; read ; read ADJTIME) < /etc/adjtime


Additional info:
* package version(s)
initscripts 2012.07.5-1
This task depends upon

Closed by  Tom Gundersen (tomegun)
Wednesday, 01 August 2012, 23:39 GMT
Reason for closing:  Fixed
Additional comments about closing:  Thanks for reporting. Fixed in git.
Comment by Dave Reisner (falconindy) - Monday, 30 July 2012, 18:57 GMT
Neat. I'd opt for farking around with the IFS and calling instead read only once:

IFS=$'\n' read _ _ clockmode </etc/adjtime
Comment by James Gordon (drwitherstone) - Monday, 30 July 2012, 20:07 GMT
You need to set read's delimiter too: "read -d ''".

Or you could use mapfile/readarray:
mapfile -t adjtime < /etc/adjtime
${ADJTIME[2]} would refer to the relevent line, then.

On the other hand, since ADJTIME is only used once, you could completely remove the line and instead change the test to something like "[[ $(< /etc/adjtime) == *$'\n'UTC ]]".

Loading...