msm8226-common: init: Modify time_daemon to allow settimeofday() fallback

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.

Change-Id: I8a0e220b724234c26b99a09b7f54af7996129d67
Signed-off-by: D. Andrei Măceș <andrei@unlegacy-android.org>
Signed-off-by: RenanQueiroz <queirozrrq@gmail.com>
This commit is contained in:
D. Andrei Măceș 2018-01-10 18:16:01 +02:00 committed by Francescodario Cuzzocrea
parent f6a6217861
commit 2540653e36

View file

@ -673,9 +673,10 @@ service thermal-engine /vendor/bin/thermal-engine -c /vendor/etc/thermal-engine-
group root
service time_daemon /vendor/bin/time_daemon
capabilities SYS_TIME
class late_start
user root
group root
user system
group net_raw
service wcnss-service /system/bin/wcnss_service
class late_start