Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 699530 - openrc-settingsd generates incorrect 02locale
Summary: openrc-settingsd generates incorrect 02locale
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux Gnome Desktop Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-07 14:04 UTC by Pierre Labastie
Modified: 2021-07-23 01:27 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Configuration of "Region and Language" GNOME settings (Screenshot from 2019-11-07 12-08-26.png,43.15 KB, image/png)
2019-11-07 14:04 UTC, Pierre Labastie
Details
Proposed patch (0001-Add-a-separator-before-creating-a-variable.patch,5.13 KB, patch)
2019-11-08 21:43 UTC, Pierre Labastie
Details | Diff
Proposed patch 2 (fix-shellparser.patch,5.64 KB, patch)
2019-11-13 21:22 UTC, Pierre Labastie
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre Labastie 2019-11-07 14:04:49 UTC
Created attachment 595222 [details]
Configuration of "Region and Language" GNOME settings

Using Gnome-3.3O settings app, on the "Region and Language" screen, I've done the following (see attached screenshot): Language set to "English", but Formats set to "French" (I like to get messages in English, so that I can share them with non French-speaking persons, but I dates in French :). Then the /etc/env.d/02locale file contains:
----------
# Configuration file for eselect
# This file has been automatically generated.
LANG='en_US.UTF-8'
LC_NUMERIC='fr_FR.UTF-8'LC_TIME='fr_FR.UTF-8'LC_MONETARY='fr_FR.UTF-8'LC_PAPER='fr_FR.UTF-8'LC_MEASUREMENT='fr_FR.UTF-8'
----------
lacking some separator (newline) between LC_* variable assignments. The reason is the following. In function shell_parser_set_variable of utils.c, if the variable does not exist, the following code is executed:
----------
        if (add_if_unset) {
            found_entry = g_new0 (struct ShellEntry, 1);
            found_entry->type = SHELL_ENTRY_TYPE_ASSIGNMENT;
            found_entry->variable = g_strdup (variable);
            found_entry->string = g_strdup_printf ("%s=%s", variable, quoted_value);
            parser->entry_list = g_list_append (parser->entry_list, found_entry);
            ret = TRUE;
        }
---------
so that if either the file is not terminated by a separator, or 2 variables are added, the separator is missing. Note that I am not sure whether the separator should be added before or after...
Comment 1 Pierre Labastie 2019-11-07 14:06:31 UTC
Portage 2.3.76 (python 3.6.9-final-0, default/linux/amd64/17.1/desktop/gnome, gcc-8.3.0, glibc-2.29-r2, 4.19.72-gentoo-lfs-1 x86_64)
=================================================================
System uname: Linux-4.19.72-gentoo-lfs-1-x86_64-Intel-R-_Core-TM-_i7-4790_CPU_@_3.60GHz-with-gentoo-2.6
KiB Mem:     8981024 total,   8161144 free
KiB Swap:    7340028 total,   7340028 free
Timestamp of repository gentoo: Thu, 07 Nov 2019 09:00:01 +0000
Head commit of repository gentoo: ab16276ebe5163c4e343b343848b702a262c5b49
sh bash 4.4_p23-r1
ld GNU ld (Gentoo 2.32 p2) 2.32.0
app-shells/bash:          4.4_p23-r1::gentoo
dev-lang/perl:            5.28.2-r1::gentoo
dev-lang/python:          2.7.16::gentoo, 3.6.9::gentoo
dev-util/cmake:           3.14.6::gentoo
sys-apps/baselayout:      2.6-r1::gentoo
sys-apps/openrc:          0.41.2::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.16.1-r1::gentoo
sys-devel/binutils:       2.32-r1::gentoo
sys-devel/gcc:            8.3.0-r1::gentoo
sys-devel/gcc-config:     2.0::gentoo
sys-devel/libtool:        2.4.6-r3::gentoo
sys-devel/make:           4.2.1-r4::gentoo
sys-kernel/linux-headers: 4.19::gentoo (virtual/os-headers)
sys-libs/glibc:           2.29-r2::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-max-age: 24

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=native"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe -march=native"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=native"
GENTOO_MIRRORS="http://ftp.free.fr/mirrors/ftp.gentoo.org/"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cdr cli colord crypt cups cxx dbus dri dts dvd dvdr eds egl elogind emboss encode evo exif fam flac fortran gdbm gif gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk iconv icu introspection ipv6 jpeg lcms ldap libnotify libsecret libtirpc mad mng mp3 mp4 mpeg multilib nautilus ncurses networkmanager nls nptl ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio qt5 readline sdl seccomp spell split-usr ssl startup-notification svg tcpd tiff tracker truetype udev udisks unicode upower usb vorbis wayland wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby24 ruby25" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Pierre Labastie 2019-11-08 21:43:38 UTC
Created attachment 595512 [details, diff]
Proposed patch
Comment 3 Pierre Labastie 2019-11-13 21:22:47 UTC
Created attachment 596026 [details, diff]
Proposed patch 2

Do not use the previous patch, it leads to memory corruption (sorry about that)
Comment 4 Luca Weiss 2020-10-30 15:41:22 UTC
@Pierre: 
I also saw this problem with setting new variables with hostnamed and fixed it myself a bit differently (and in my opinion cleaner :P).
Can you try if this patch works for you as well? 
https://git.sr.ht/~z3ntu/openrc-settingsd/commit/64debbaf5bdef93302f29c3f6cd395e3e22d65d8
Comment 5 Pierre Labastie 2020-11-01 10:17:04 UTC
Thanks for looking at this. I need to rebuild a gentoo system for testing, so please do not hold your breath. I'll come back to you when I am able to test your patch. It looks like it does not take into account the fact that a separator may be a comment, which may have been added for whatever reason to the 02locale file. But I agree your solution is cleaner (and I may use the same scheme for the blocaled fork https://github.com/pierre-labastie/blocaled/ :)
Comment 6 Pierre Labastie 2020-11-03 21:10:53 UTC
Looks like the patch fixes the issue. If for some reason, you start with a file which has a comment at the end:
---------
# Configuration file for eselect
# This file has been automatically generated.
LANG='en_US.UTF-8'
# Added comment
---------
Then after changing the Formats to "French", the file looks like this:
---------
# Configuration file for eselect
# This file has been automatically generated.
LANG='en_US.UTF-8'
# Added comment

LC_NUMERIC='fr_FR.UTF-8'
LC_TIME='fr_FR.UTF-8'
LC_MONETARY='fr_FR.UTF-8'
LC_PAPER='fr_FR.UTF-8'
LC_MEASUREMENT='fr_FR.UTF-8'
----------
That is, a blank line is added after the comment. Not a big deal, and nothing that prevents running. In blocaled, I want the localed API to be fully implemented, which involves adding and removing variables, so that removing the separator has to be done. But as far as gnome with openrc is concerned, I think it is not needed.
Comment 7 Larry the Git Cow gentoo-dev 2021-07-23 01:27:24 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a2c1d91747310654188a4c4b693d17751e7c9aeb

commit a2c1d91747310654188a4c4b693d17751e7c9aeb
Author:     Matt Turner <mattst88@gentoo.org>
AuthorDate: 2021-07-23 01:24:27 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2021-07-23 01:24:36 +0000

    app-admin/openrc-settingsd: Version bump to 1.1.0
    
    Many thanks to our friends at postmarketOS for taking over
    maintainership of this project!
    
    Closes: https://bugs.gentoo.org/699530
    Closes: https://bugs.gentoo.org/759616
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 app-admin/openrc-settingsd/Manifest                |  1 +
 .../openrc-settingsd/openrc-settingsd-1.1.0.ebuild | 63 ++++++++++++++++++++++
 2 files changed, 64 insertions(+)