Date: Wed, 23 Mar 2022 16:31:08 -0400 From: Phil Shafer <phil@freebsd.org> To: FreeBSD Hackers <freebsd-hackers@freebsd.org> Cc: "Simon J. Gerraty" <sjg@freebsd.org> Subject: What's the locale for system files (e.g. /etc/fstab)? Message-ID: <70B211BB-15BA-47A4-8F9C-C833AA8C1EAA@freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?70B211BB-15BA-47A4-8F9C-C833AA8C1EAA>