Hi Bob,

I noticed file times in chromium file open dialog (Ctrl-O) are
displayed in UTC instead of the local timezone (same in
firefox). Given that pledge goes out of its way to make localtime work
we might want to fix this.

The problem seems to be due to Chromium doing a readlink (likely at
[1]) on /etc/localtime, which fails. There's a workaround that
happens to work for chromium (and firefox).  Just set TZ in your
environment.

Does it make sense to have special cases in readlink for those who
don't have TZ set?

The problem can be demonstrated by the trivial program below. When
executed two ways it shows that unveil("/etc", "r") is enough to make
the problem go away (confirmed by editing /etc/chromium/unveil.main
too). Naturally it's not a good remedy.

cc test2.c -DMAKE_WORK; ./a.out; cc test2.c; ./a.out
stat 5616
readlink /usr/share/zoneinfo/US/Pacific
stat 5616
readlink: No such file or directory

--------------------------------------------
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>

int
main()
{
struct stat st;
char buf[1024] = {0};

pledge("stdio rpath unveil", NULL);

unveil("/etc/localtime", "r");
#ifdef MAKE_WORK
unveil("/etc", "r");
#endif
unveil(NULL, NULL);

stat("/etc/localtime", &st);

printf("stat %llu\n", st.st_ino);

int e = readlink("/etc/localtime", buf, sizeof(buf));
if (e < 0) {
 perror("readlink");
} else {
 printf("readlink %s\n", buf);
}

return 0;
}
--------------------------------------------

[1]
https://source.chromium.org/chromium/chromium/src/+/master:third_party/icu/source/common/putil.cpp;l=1113?q=%2Fetc%2Flocaltime%20readlink&ss=chromium&originalUrl=https:%2F%2Fcs.chromium.org%2F


-- 
nest.cx is Gmail hosted, use PGP:
https://pgp.key-server.io/0x0B1542BD8DF5A1B0
Fingerprint: 5E2B 2D0E 1E03 2046 BEC3  4D50 0B15 42BD 8DF5 A1B0

Reply via email to