Repository navigation
Symlink /etc/localtime and decide the hardware clock mode - #10
Conversation
The first-boot setup picked a timezone but copied the zoneinfo file over /etc/localtime. A copy freezes the zone at setup time so tzdata updates never reach the system, and tools that read the zone name from the link target see nothing configured. /var/db/zoneinfo was never written either, which re-opened issue #49 on OEM images. Link it the way tzsetup(8) does and record the zone name. The page also never asked whether the hardware clock keeps UTC or local time, so the system kept whatever the image shipped, which was local time. On a machine whose RTC keeps UTC the clock was then off by one UTC offset. Add a checkbox, checked by default, that adds or removes /etc/wall_cmos_clock and runs adjkerntz -i so the answer applies without a second reboot. The widget takes its initial state from SetupData so the page and the default cannot drift apart. Resolves: ghostbsd/issues#390
Reviewer's GuideThe first-boot setup now configures timezones with a tzsetup-compatible symlink and persisted zone name, and adds a SetupData-backed hardware-clock choice that updates /etc/wall_cmos_clock and applies the setting immediately with adjkerntz. Sequence diagram for timezone and hardware clock setupsequenceDiagram
participant User
participant TimeZone
participant SetupData
participant SystemCalls
participant Filesystem
User->>TimeZone: toggle utc_selection(check_button)
TimeZone->>SetupData: update utc_clock
User->>TimeZone: complete setup
TimeZone->>SystemCalls: apply_timezone()
SystemCalls->>Filesystem: symlink /etc/localtime to zoneinfo
SystemCalls->>Filesystem: write /var/db/zoneinfo
TimeZone->>SystemCalls: apply_utc_clock()
SystemCalls->>Filesystem: add or remove /etc/wall_cmos_clock
SystemCalls->>SystemCalls: run(['adjkerntz', '-i'], check=True)
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="setup_station/system_calls.py" line_range="352-358" />
<code_context>
try:
- run(['cp', zoneinfo_path, localtime_path], check=True)
+ if os.path.lexists(localtime_path):
+ os.remove(localtime_path)
+ os.symlink(zoneinfo_path, localtime_path)
+ # Saved for tzsetup -r and for the login / lock screens
+ with open('/var/db/zoneinfo', 'w') as zoneinfo:
+ zoneinfo.write(f'{timezone}\n')
except Exception as e:
raise RuntimeError(f"Failed to set timezone '{timezone}': {e}") from e
</code_context>
<issue_to_address>
**issue (bug_risk):** The function removes the existing `/etc/localtime` before creating the replacement symlink and writing `/var/db/zoneinfo`; if either `os.symlink` or the zoneinfo file write fails, setup raises while leaving `/etc/localtime` missing or leaving the symlink and `/var/db/zoneinfo` out of sync.
**Triggers:** When the symlink creation or `/var/db/zoneinfo` write fails, such as from a filesystem or permission error.
**Suggested fix:** Build the new configuration atomically or restore the previous `/etc/localtime` and `/var/db/zoneinfo` values on failure.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and this changes persistent system time configuration and immediately adjusts the running clock with adjkerntz; if the timezone or UTC/local-clock choice is wrong, services can observe incorrect time and timestamps or fail time-sensitive operations. Reverting the files does not undo clock adjustments or timestamps already produced, although the system can be corrected by applying the proper configuration again.
Blocking findings: setup_station/system_calls.py:358
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
The first-boot setup picked a timezone but copied the zoneinfo file over /etc/localtime. A copy freezes the zone at setup time so tzdata updates never reach the system, and tools that read the zone name from the link target see nothing configured. /var/db/zoneinfo was never written either, which re-opened issue #49 on OEM images. Link it the way tzsetup(8) does and record the zone name.
The page also never asked whether the hardware clock keeps UTC or local time, so the system kept whatever the image shipped, which was local time. On a machine whose RTC keeps UTC the clock was then off by one UTC offset. Add a checkbox, checked by default, that adds or removes /etc/wall_cmos_clock and runs adjkerntz -i so the answer applies without a second reboot. The widget takes its initial state from SetupData so the page and the default cannot drift apart.
Resolves: ghostbsd/issues#390
Summary by Sourcery
Configure timezone links and hardware clock mode during first-boot setup.
New Features:
Bug Fixes:
Enhancements: