Re: What's the locale for system files (e.g. /etc/fstab)?
- Reply: Warner Losh : "Re: What's the locale for system files (e.g. /etc/fstab)?"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 24 Mar 2022 15:19:03 UTC
> On 23 Mar 2022, at 11:51, Piotr Pawel Stefaniak wrote:
> > mount: make libxo support more locale-aware
> >
> > "special", "node", and "mounter" are not guaranteed to be encoded
> > with
> > UTF-8. Use the appropriate modifier.
> >
> > - xo_emit("{:special}{L: on }{:node}{L: (}{:fstype}",
> > sfp->f_mntfromname,
> > + xo_emit("{:special/%hs}{L: on }{:node/%hs}{L: (}{:fstype}",
> > sfp->f_mntfromname,
> sfp->f_mntonname, sfp->f_fstypename);
>
> This recent "mount" patch highlights a libxo-related problem for which I
> don't have a solution:
>
> There are several files for which the encoding is not known. Since
> locale is user specific, we don't know how to interpret the contents of
> /etc/fstab. It's assumably been encoded with the format of the user who
> wrote it, but that information is lost.
Since you say "locale is user specific" it makes me want to say that
this should come from the environment set by "default:" in /etc/login.conf,
no need for a new file or anything special.
>
> Put more generally, there's not a system-wide place which declares the
> encoding for system files, which leads to this problem where we
> interpret files from one user's locale using another user's locale.
Well /etc/login.conf *IS* a system wide declaration of this type of
stuff, both lang= and charset= are declared there.
>
> One solution would a symlink in /etc that "points to" the name of the
> current system-wide locale name.
>
> % ls -Fl /etc/locale
> lrwxr-xr-x 1 root wheel 7 Mar 23 15:42 /etc/locale@ -> C.UTF-8
grep lang /etc/login.conf:
:lang=C.UTF-8:
:lang=ru_RU.UTF-8:\
Probably what you want?
>
> (Or "/etc/system.locale" ?)
>
> If the symlink doesn't exist, would "C.UTF-8" be a suitable default
> moving forwards? It certainly would not be backwards compatible, since
> an existing fstab could have non-UTF-8 strings in it, encoded with the
> locale of the user who touched the file. But there's really no
> backwards compatible solution, given that there's no guarantee that (for
> any specific FreeBSD system) all system files were written with the same
> locale. Fun, eh? ;^)
>
> Opinions, thoughts, please?
>
> Thanks,
> Phil
>
>
--
Rod Grimes rgrimes@freebsd.org