This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

答复: Re: [PATCH]   tzset did not catch changes to localtime  [BZ #21060 ]


> Yes it is. The TZ env overrides the system timezone. If TZ exists then
> tzset should ignore any system wide setting whether something modifies
> it or not. 
Please , think about this situation.

Set Tz=":/mydir/mytime“
Start my application Xapp
Modify /mydir/mytime
use tzset in Xapp

What will I get from tzset?  I do not think it could be something a user want...





------------------原始邮件------------------
发件人: <elseifthen@gmx.com>;
收件人:马江10100629; <libc-alpha@sourceware.org>;
日 期 :2017年11月03日 07:47
主 题 :Re: [PATCH]   tzset did not catch changes to localtime  [BZ #21060 ]


On 11/02/2017 05:03 AM, ma.jiang@zte.com.cn wrote:
> Hi,
> If users modified the local timezone file (usually /etc/localtime)
> while keep the TZ environment variable untouched, tzset will not
> recalculate tzname. This is not right.

Yes it is. The TZ env overrides the system timezone. If TZ exists then
tzset should ignore any system wide setting whether something modifies
it or not. Users should not have permission to modify anything in /etc/
anyway.


> Patch attached should fix this
> problem, is it OK for trunk?

>
>
> diff -Nuarp a/time/tzset.c b/time/tzset.c
> --- a/time/tzset.c    2017-10-31 17:28:58.105026060 +0800
> +++ b/time/tzset.c    2017-10-31 17:28:43.470025216 +0800
> @@ -387,21 +387,18 @@ tzset_internal (int always)
>    if (tz && *tz == ':')
>      ++tz;
>
> -  /* Check whether the value changed since the last run.  */
> -  if (old_tz != NULL && tz != NULL && strcmp (tz, old_tz) == 0)
> -    /* No change, simply return.  */
> -    return;
> -
>    if (tz == NULL)
>      /* No user specification; use the site-wide default.  */
>      tz = TZDEFAULT;
>
> -  tz_rules[0].name = NULL;
> -  tz_rules[1].name = NULL;
> -
> -  /* Save the value of `tz'.  */
> -  free (old_tz);
> -  old_tz = tz ? __strdup (tz) : NULL;
> +  /* Check whether the value changed since the last run.  */
> +  if ((old_tz == NULL)
> +      || (old_tz != NULL && strcmp (tz, old_tz) != 0))
> +    {
> +      /* Save the value of `tz'.  */
> +      free (old_tz);
> +      old_tz = tz ? __strdup (tz) : NULL;
> +    }
>
>    /* Try to read a data file.  */
>    __tzfile_read (tz, 0, NULL);
>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]