Skip to content

Commit

Permalink
hammerhead: Modify time_daemon to allow settimeofday() fallback
Browse files Browse the repository at this point in the history
The legacy time_daemon binary relied on the old Android alarm dri-
ver for setting RTC at bootup. Once /dev/alarm support was removed
we found that time cannot be restored properly, unless a data con-
nection was available for NTP sync.

However, the blob already has a fallback mechanism that relies on
settimeofday(), except that it could never work properly. While
time_daemon is started under UID/GID of root, it immediately drops
to system/net_raw, which is required for subsequent socket commu-
ications (e.g., QMI, modem, etc).

The issue was that any UID transition from root triggers the remo-
val of all thread capabilities, including CAP_SYS_TIME, required
for settimeofday() or other RTC adjustments. Thus, time_daemon was
edited to skip the internal set[gu]id() calls altoghether, in order
to use the new capabilities mechanism introduced with Oreo init.

Many thanks to Dániel Járai (@Ziyann) for implementing the two hex
edits required to skip set[gu]id().

Change-Id: I046aebde923e4cfb61bf67eb48e20d6908723376
Signed-off-by: D. Andrei Măceș <[email protected]>
  • Loading branch information
airend authored and razorloves committed Jul 11, 2018
1 parent f378b16 commit 7b892ed
Showing 1 changed file with 0 additions and 0 deletions.
Binary file modified hammerhead/proprietary/bin/time_daemon
Binary file not shown.

0 comments on commit 7b892ed

Please sign in to comment.