Message ID | 20210410002248.727974-1-rosenp@gmail.com |
---|---|
State | Changes Requested |
Delegated to: | Paul Spooren |
Headers | show |
Series | base-files: fix zoneinfo support | expand |
On Fri, Apr 9, 2021 at 5:22 PM Rosen Penev <rosenp@gmail.com> wrote: > > The system init script currently sets /tmp/localinfo when zoneinfo is > populated. However, zoneinfo has spaces in it whereas the actual files > have _ instead of spaces. This made the if condition never return true. > > Example failure when removing the if condition: > > /tmp/localtime -> /usr/share/zoneinfo/America/Los Angeles > > This file does not exist. America/Los_Angeles does. > > Signed-off-by: Rosen Penev <rosenp@gmail.com> I'll add that this problem was there since the beginning: https://github.com/openwrt/openwrt/commit/bfbbe5893f92cd572c48c4d37fbd975f148093d6 > --- > this should be backported to 21.02 and 19.07 as the issue is also > present there. This was tested on 19.07. > package/base-files/files/etc/init.d/system | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system > index 08cf86b97f..b1fc154cec 100755 > --- a/package/base-files/files/etc/init.d/system > +++ b/package/base-files/files/etc/init.d/system > @@ -22,9 +22,13 @@ system_config() { > > echo "$hostname" > /proc/sys/kernel/hostname > [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} > - echo "$timezone" > /tmp/TZ > - [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \ > - ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ > + if [ -n "$zonename" ]; then > + local zname=$(echo "$zonename" | tr ' ' _) > + [ -f "/usr/share/zoneinfo/$zname" ] && \ > + ln -sf "/usr/share/zoneinfo/$zname" /tmp/localtime > + else > + echo "$timezone" > /tmp/TZ > + fi > > # apply timezone to kernel > hwclock -u --systz > -- > 2.30.2 >
Hi, if I'm not mistaken this patch doesn't quite do the trick: You removed the removal of /tmp/TZ which seem to be preferred by `hwclock`, meaning even if $zonename (aka $zname) is found, /tmp/TZ is still there. As a result both /tmp/TZ and /tmp/localtime exists both, allowing the user no longer to change the timezone at all, even when typing the "correct" entry (i.e. Pacific/Port_Moresby). Please send a v2 removing the /tmp/TZ file again iff $zonename exists. On 4/9/21 2:22 PM, Rosen Penev wrote: > The system init script currently sets /tmp/localinfo when zoneinfo is > populated. However, zoneinfo has spaces in it whereas the actual files > have _ instead of spaces. This made the if condition never return true. > > Example failure when removing the if condition: > > /tmp/localtime -> /usr/share/zoneinfo/America/Los Angeles > > This file does not exist. America/Los_Angeles does. > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > --- > this should be backported to 21.02 and 19.07 as the issue is also > present there. This was tested on 19.07. > package/base-files/files/etc/init.d/system | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system > index 08cf86b97f..b1fc154cec 100755 > --- a/package/base-files/files/etc/init.d/system > +++ b/package/base-files/files/etc/init.d/system > @@ -22,9 +22,13 @@ system_config() { > > echo "$hostname" > /proc/sys/kernel/hostname > [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} > - echo "$timezone" > /tmp/TZ > - [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \ > - ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ > + if [ -n "$zonename" ]; then > + local zname=$(echo "$zonename" | tr ' ' _) > + [ -f "/usr/share/zoneinfo/$zname" ] && \ > + ln -sf "/usr/share/zoneinfo/$zname" /tmp/localtime > + else > + echo "$timezone" > /tmp/TZ > + fi > > # apply timezone to kernel > hwclock -u --systz
On Wed, Jun 23, 2021 at 3:40 PM Paul Spooren <mail@aparcar.org> wrote: > > Hi, > > if I'm not mistaken this patch doesn't quite do the trick: You removed > the removal of /tmp/TZ which seem to be preferred by `hwclock`, meaning > even if $zonename (aka $zname) is found, /tmp/TZ is still there. As a > result both /tmp/TZ and /tmp/localtime exists both, allowing the user no > longer to change the timezone at all, even when typing the "correct" > entry (i.e. Pacific/Port_Moresby). Ummm. This script is the one that creates /tmp/TZ in the first place. /tmp/TZ is an openwrt hack that is used when there are no zoneinfo files. After this patch, it gets created only if they are missing. > > Please send a v2 removing the /tmp/TZ file again iff $zonename exists. There's no point in removing that which is not present. > > On 4/9/21 2:22 PM, Rosen Penev wrote: > > The system init script currently sets /tmp/localinfo when zoneinfo is > > populated. However, zoneinfo has spaces in it whereas the actual files > > have _ instead of spaces. This made the if condition never return true. > > > > Example failure when removing the if condition: > > > > /tmp/localtime -> /usr/share/zoneinfo/America/Los Angeles > > > > This file does not exist. America/Los_Angeles does. > > > > Signed-off-by: Rosen Penev <rosenp@gmail.com> > > --- > > this should be backported to 21.02 and 19.07 as the issue is also > > present there. This was tested on 19.07. > > package/base-files/files/etc/init.d/system | 10 +++++++--- > > 1 file changed, 7 insertions(+), 3 deletions(-) > > > > diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system > > index 08cf86b97f..b1fc154cec 100755 > > --- a/package/base-files/files/etc/init.d/system > > +++ b/package/base-files/files/etc/init.d/system > > @@ -22,9 +22,13 @@ system_config() { > > > > echo "$hostname" > /proc/sys/kernel/hostname > > [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} > > - echo "$timezone" > /tmp/TZ > > - [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \ > > - ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ > > + if [ -n "$zonename" ]; then > > + local zname=$(echo "$zonename" | tr ' ' _) > > + [ -f "/usr/share/zoneinfo/$zname" ] && \ > > + ln -sf "/usr/share/zoneinfo/$zname" /tmp/localtime > > + else > > + echo "$timezone" > /tmp/TZ > > + fi > > > > # apply timezone to kernel > > hwclock -u --systz
On 6/23/21 1:14 PM, Rosen Penev wrote: > On Wed, Jun 23, 2021 at 3:40 PM Paul Spooren <mail@aparcar.org> wrote: >> Hi, >> >> if I'm not mistaken this patch doesn't quite do the trick: You removed >> the removal of /tmp/TZ which seem to be preferred by `hwclock`, meaning >> even if $zonename (aka $zname) is found, /tmp/TZ is still there. As a >> result both /tmp/TZ and /tmp/localtime exists both, allowing the user no >> longer to change the timezone at all, even when typing the "correct" >> entry (i.e. Pacific/Port_Moresby). > Ummm. This script is the one that creates /tmp/TZ in the first place. > /tmp/TZ is an openwrt hack that is used when there are no zoneinfo > files. After this patch, it gets created only if they are missing. >> Please send a v2 removing the /tmp/TZ file again iff $zonename exists. > There's no point in removing that which is not present. - Firstbooting device creates /tmp/TZ since it defaults to UTC - Change zonename configuration in /etc/config/system - Run /etc/init.d/system restart - Time stays the same since /tmp/TZ isn't removed (just /tmp/localtime appeared next to it) A reboot actually fixes this since /tmp/ is mounted in memory but OpenWrt is all about uptime. Sunshine, Paul >> On 4/9/21 2:22 PM, Rosen Penev wrote: >>> The system init script currently sets /tmp/localinfo when zoneinfo is >>> populated. However, zoneinfo has spaces in it whereas the actual files >>> have _ instead of spaces. This made the if condition never return true. >>> >>> Example failure when removing the if condition: >>> >>> /tmp/localtime -> /usr/share/zoneinfo/America/Los Angeles >>> >>> This file does not exist. America/Los_Angeles does. >>> >>> Signed-off-by: Rosen Penev <rosenp@gmail.com> >>> --- >>> this should be backported to 21.02 and 19.07 as the issue is also >>> present there. This was tested on 19.07. >>> package/base-files/files/etc/init.d/system | 10 +++++++--- >>> 1 file changed, 7 insertions(+), 3 deletions(-) >>> >>> diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system >>> index 08cf86b97f..b1fc154cec 100755 >>> --- a/package/base-files/files/etc/init.d/system >>> +++ b/package/base-files/files/etc/init.d/system >>> @@ -22,9 +22,13 @@ system_config() { >>> >>> echo "$hostname" > /proc/sys/kernel/hostname >>> [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} >>> - echo "$timezone" > /tmp/TZ >>> - [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \ >>> - ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ >>> + if [ -n "$zonename" ]; then >>> + local zname=$(echo "$zonename" | tr ' ' _) >>> + [ -f "/usr/share/zoneinfo/$zname" ] && \ >>> + ln -sf "/usr/share/zoneinfo/$zname" /tmp/localtime >>> + else >>> + echo "$timezone" > /tmp/TZ >>> + fi >>> >>> # apply timezone to kernel >>> hwclock -u --systz
diff --git a/package/base-files/files/etc/init.d/system b/package/base-files/files/etc/init.d/system index 08cf86b97f..b1fc154cec 100755 --- a/package/base-files/files/etc/init.d/system +++ b/package/base-files/files/etc/init.d/system @@ -22,9 +22,13 @@ system_config() { echo "$hostname" > /proc/sys/kernel/hostname [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} - echo "$timezone" > /tmp/TZ - [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && \ - ln -sf "/usr/share/zoneinfo/$zonename" /tmp/localtime && rm -f /tmp/TZ + if [ -n "$zonename" ]; then + local zname=$(echo "$zonename" | tr ' ' _) + [ -f "/usr/share/zoneinfo/$zname" ] && \ + ln -sf "/usr/share/zoneinfo/$zname" /tmp/localtime + else + echo "$timezone" > /tmp/TZ + fi # apply timezone to kernel hwclock -u --systz
The system init script currently sets /tmp/localinfo when zoneinfo is populated. However, zoneinfo has spaces in it whereas the actual files have _ instead of spaces. This made the if condition never return true. Example failure when removing the if condition: /tmp/localtime -> /usr/share/zoneinfo/America/Los Angeles This file does not exist. America/Los_Angeles does. Signed-off-by: Rosen Penev <rosenp@gmail.com> --- this should be backported to 21.02 and 19.07 as the issue is also present there. This was tested on 19.07. package/base-files/files/etc/init.d/system | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)