Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webOS] Fix timezone reading #23847

Merged
merged 2 commits into from Oct 3, 2023
Merged

Conversation

sundermann
Copy link
Contributor

@sundermann sundermann commented Sep 30, 2023

Description

Timezone was not set correctly on startup on webOS. Some refactoring is done first to avoid duplicating code. The diff is a bit large because clang format required fixing up the header inclusion order and variable spacing

Motivation and context

The webOS jailer only mounts /etc/localtime which is a symlink to /var/luna/preferences/localtime. /var/luna/preferences/localtime however is another symlink to the actual zone info.

How has this been tested?

webOS22/7

What is the effect on users?

Fixes timezone initialization

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • Student submission (PR was done for educational purposes and will be treated as such)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@sundermann
Copy link
Contributor Author

It seems std::filesystem is not available until macOS 10.15 and fstream is not available until NDK 24.

@sundermann sundermann changed the title [WebOS] Fix timezone reading [webOS] Fix timezone reading Sep 30, 2023
@throwaway96
Copy link
Contributor

Information for webOS 4.1.0 (MStar M3 SoC, using the YouTube jail as an example):

/var/luna/preferences/timezone is present in the jail, but it's Universal instead of the system timezone (America/New_York):

root@lg-m3[m3 4.1.0]:~# cat /var/palm/jail/youtube.leanback.v4/var/luna/preferences/timezone
Universal

/etc/localtime is a symlink to /var/luna/preferences/localtime:

root@lg-m3[m3 4.1.0]:~# readlink /var/palm/jail/youtube.leanback.v4/etc/localtime
/var/luna/preferences/localtime

/var/luna/preferences/localtime (symlink to correct zoneinfo) is present in the jail:

root@lg-m3[m3 4.1.0]:~# readlink /var/palm/jail/youtube.leanback.v4/var/luna/preferences/localtime
/usr/share/zoneinfo/America/New_York

It seems that /usr/share/zoneinfo is available from inside the jail, e.g.:

  File: /var/palm/jail/youtube.leanback.v4/usr/share/zoneinfo/America/New_York
  Size: 3545            Blocks: 7          IO Block: 1024   regular file
Device: b31dh/45853d    Inode: 61542       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-09-17 22:29:54.000000000
Modify: 2018-09-17 22:29:54.000000000
Change: 2018-09-17 22:29:54.000000000

These are the relevant lines in /etc/jail_native.conf (although I'm not sure exactly which configuration file is used, or how it's chosen, these lines seem to be common to all):

# /var/luna/preferences
mkdir /var/luna
mkdir /var/luna/preferences
mount ro /var/luna/preferences

link /var/luna/preferences/localtime /etc/localtime

/usr/share (apparently responsible for the existence of /usr/share/zoneinfo, although they mount /usr/share/fonts explicitly) is also mounted by jail_native.conf:

mount ro /usr/share

These files are the same outside of the jail. It looks like /var/luna/preferences/timezone has the wrong timezone setting. That may be an artifact of the strange way my webOS boards are configured (missed a firstuse step?), but I can look into it on other boards/versions.

@sundermann
Copy link
Contributor Author

Thank you for checking this on different webOS versions. As you suggested I have changed to reading the symlink path from /var/luna/preferences/localtime instead

Copy link
Member

@wsnipex wsnipex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

On webOS /etc/localtime is a symlink to /var/luna/preferences/localtime which in turn is another symlink to the real timezone file. In this case the timezone file must be resolved twice which realpath does
@jenkins4kodi
Copy link
Contributor

I've made some formatting changes to meet the current code style. The diffs are available in the following links:

For more information please see our current code style guidelines.

@sundermann sundermann merged commit e5b177f into xbmc:master Oct 3, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants