Bug 247947 - Consider trimming values passed to setenv in login.conf
Summary: Consider trimming values passed to setenv in login.conf
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Yuri Pankov
URL: https://reviews.freebsd.org/D25649
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-13 11:29 UTC by Michael Osipov
Modified: 2022-09-30 09:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2020-07-13 11:29:01 UTC
Consider I want to write in login.conf:

default:\
    ...
    :setenv=BLOCKSIZE=K,\
        LSCOLORS=ExGxFxdxCxDxDxhbadExEx,\
        CLICOLOR=YES,\
        LESS=-x4 -R,\
        NCURSES_NO_UTF8_ACS=1,\
        EDITOR=vim:\
    ...

After cap_mkdb is run on /etc/login.conf and a relogin the indented env vars have preceding spaces and are unusable. While one can remove them, this breaks visual formatting and makes the file looks odd.

Consider trimming after splitting at the comma.
Comment 1 Michael Osipov 2020-07-13 21:47:39 UTC
Just applied the patch to 12-STABLE. The patch works for me decently.
Comment 2 Michael Osipov 2020-08-10 10:20:34 UTC
Anything holding off to apply this?
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-04-11 22:05:43 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=eeaf9d562fe137e0c52b8c346742dccfc8bde015

commit eeaf9d562fe137e0c52b8c346742dccfc8bde015
Author:     Yuri Pankov <yuripv@FreeBSD.org>
AuthorDate: 2021-04-11 22:02:12 +0000
Commit:     Yuri Pankov <yuripv@FreeBSD.org>
CommitDate: 2021-04-11 22:05:10 +0000

    setclassenvironment: trim leading spaces in variable names

    Trim leading spaces in variable names when the list is e.g.
    pretty-formatted in /etc/login.conf or ~/.login_conf.

    PR:             247947
    Reviewed by:    allanjude
    Differential Revision:  https://reviews.freebsd.org/D25649

 lib/libutil/login_class.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Comment 4 Michael Osipov 2021-04-12 06:31:07 UTC
Awesame, thank you. Can This be MFC'ed down to 13 and 12?
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-04-15 19:18:35 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c6dcae2dfa3b96edc1fd8bbb6254c48fafbc8cd3

commit c6dcae2dfa3b96edc1fd8bbb6254c48fafbc8cd3
Author:     Yuri Pankov <yuripv@FreeBSD.org>
AuthorDate: 2021-04-11 22:02:12 +0000
Commit:     Yuri Pankov <yuripv@FreeBSD.org>
CommitDate: 2021-04-15 19:15:51 +0000

    setclassenvironment: trim leading spaces in variable names

    Trim leading spaces in variable names when the list is e.g.
    pretty-formatted in /etc/login.conf or ~/.login_conf.

    PR:             247947
    Reviewed by:    allanjude
    Differential Revision:  https://reviews.freebsd.org/D25649

    (cherry picked from commit eeaf9d562fe137e0c52b8c346742dccfc8bde015)

 lib/libutil/login_class.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2021-04-15 19:22:36 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=913a9cc33ea55538f2c3366016f79f4b2a79e3d0

commit 913a9cc33ea55538f2c3366016f79f4b2a79e3d0
Author:     Yuri Pankov <yuripv@FreeBSD.org>
AuthorDate: 2021-04-11 22:02:12 +0000
Commit:     Yuri Pankov <yuripv@FreeBSD.org>
CommitDate: 2021-04-15 19:19:43 +0000

    setclassenvironment: trim leading spaces in variable names

    Trim leading spaces in variable names when the list is e.g.
    pretty-formatted in /etc/login.conf or ~/.login_conf.

    PR:             247947
    Reviewed by:    allanjude
    Differential Revision:  https://reviews.freebsd.org/D25649

    (cherry picked from commit eeaf9d562fe137e0c52b8c346742dccfc8bde015)

 lib/libutil/login_class.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Comment 7 Michael Osipov 2021-04-15 21:54:15 UTC
Спасибо, Юра!
Comment 8 Michael Osipov 2022-09-30 09:39:54 UTC
Confimed to work on 12-STABLE (53bc9be1c) and 12.3-RELEASE-p7 in a jail. Thanks, guys!