What's the locale for system files (e.g. /etc/fstab)?
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 23 Mar 2022 20:31:08 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.
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.
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
(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