From nobody Thu Mar 24 15:19:03 2022 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0C9971A3A822 for ; Thu, 24 Mar 2022 15:19:12 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4KPTQl0HXqz4Wbd; Thu, 24 Mar 2022 15:19:10 +0000 (UTC) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 22OFJ3ST098650; Thu, 24 Mar 2022 08:19:03 -0700 (PDT) (envelope-from freebsd-rwg@gndrsh.dnsmgr.net) Received: (from freebsd-rwg@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 22OFJ3Mk098649; Thu, 24 Mar 2022 08:19:03 -0700 (PDT) (envelope-from freebsd-rwg) From: "Rodney W. Grimes" Message-Id: <202203241519.22OFJ3Mk098649@gndrsh.dnsmgr.net> Subject: Re: What's the locale for system files (e.g. /etc/fstab)? In-Reply-To: <70B211BB-15BA-47A4-8F9C-C833AA8C1EAA@freebsd.org> To: Phil Shafer Date: Thu, 24 Mar 2022 08:19:03 -0700 (PDT) CC: FreeBSD Hackers , "Simon J. Gerraty" X-Mailer: ELM [version 2.4ME+ PL121h (25)] List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4KPTQl0HXqz4Wbd X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd-rwg@gndrsh.dnsmgr.net has no SPF policy when checking 69.59.192.140) smtp.mailfrom=freebsd-rwg@gndrsh.dnsmgr.net X-Spamd-Result: default: False [-0.14 / 15.00]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.15)[-0.146]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.99)[-0.994]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[dnsmgr.net]; AUTH_NA(1.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.90)[-0.900]; MLMMJ_DEST(0.00)[freebsd-hackers]; R_SPF_NA(0.00)[no SPF record]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:13868, ipnet:69.59.192.0/19, country:US]; SUBJECT_ENDS_QUESTION(1.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N > 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