Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Mar 2022 08:19:03 -0700 (PDT)
From:      "Rodney W. Grimes" <freebsd-rwg@gndrsh.dnsmgr.net>
To:        Phil Shafer <phil@FreeBSD.org>
Cc:        FreeBSD Hackers <freebsd-hackers@FreeBSD.org>, "Simon J. Gerraty" <sjg@FreeBSD.org>
Subject:   Re: What's the locale for system files (e.g. /etc/fstab)?
Message-ID:  <202203241519.22OFJ3Mk098649@gndrsh.dnsmgr.net>
In-Reply-To: <70B211BB-15BA-47A4-8F9C-C833AA8C1EAA@freebsd.org>

next in thread | previous 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.

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202203241519.22OFJ3Mk098649>