Bug 289097 - Base upgrades must not lose user customisations in dot files such as /root/.cshrc and /root/.profile
Summary: Base upgrades must not lose user customisations in dot files such as /root/.c...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 14.3-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: Lexi Winter
URL:
Keywords: pkgbase
Depends on:
Blocks:
 
Reported: 2025-08-25 13:49 UTC by devnull
Modified: 2025-10-02 04:01 UTC (History)
3 users (show)

See Also:


Attachments
Screenshot of vt(4) following a minor upgrade (20.81 KB, image/png)
2025-08-25 16:00 UTC, devnull
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description devnull freebsd_committer freebsd_triage 2025-08-25 13:49:44 UTC
A patch level upgrade of 14.2-RELEASE-p⋯ to 14.2-RELEASE-p5 overwrites: 

/root/.cshrc

If it helps: pkgbasify _does_ respect (at least) /root/.cshrc

----

root@pkg:~ # pkg which /root/.cshrc /root/.profile

/root/.cshrc was installed by package FreeBSD-csh-14.2p5
/root/.profile was installed by package FreeBSD-runtime-14.2p5
root@pkg:~ # freebsd-version -kru ; uname -mvKU

14.2-RELEASE-p5
14.2-RELEASE-p2
14.2-RELEASE-p5
FreeBSD 14.2-RELEASE-p2 releng/14.2-n269518-ac2cbb46b5f1 GENERIC amd64 1402000 1402000
root@pkg:~ # 

----

Originally reported by u/vivekkhera for FreeBSD-csh-14.3p2 at <https://www.reddit.com/r/freebsd/comments/1mzlfq0/comment/naku34i/?context=2>.
Comment 1 devnull freebsd_committer freebsd_triage 2025-08-25 16:00:22 UTC
Created attachment 263230 [details]
Screenshot of vt(4) following a minor upgrade

A minor upgrade from 14.2-RELEASE-p2 to 14.3-RELEASE-p2 lost (overwrote) my customisations to both /root/.cshrc and /root/.profile

- prior to the upgrade, both files included a custom line for EDITOR.
Comment 2 devnull freebsd_committer freebsd_triage 2025-08-25 17:46:37 UTC
> both files included a custom line for EDITOR.

More accurately, my customisation of /root/.cshrc was _removal_ of the line for EDITOR.
Comment 3 Lexi Winter freebsd_committer freebsd_triage 2025-08-26 07:31:15 UTC
this is because the hard links /.profile and /.cshrc are missing the config tag, which makes pkg overwrite them instead of attempting to merge changes.

for main, we already removed /.cshrc, so we can just remove /.profile as well: https://reviews.freebsd.org/D52161

for stable/14, adding the config tag to the links in / works around the problem: https://reviews.freebsd.org/D52162
Comment 4 devnull freebsd_committer freebsd_triage 2025-08-26 12:00:07 UTC
Thank you! 

I should have thought of /.cshrc (subscription to <https://reviews.freebsd.org/D45382>, plus I manually removed /.cshrc.pkgsave from one of my test VMs before making this report). 

/etc/csh.cshrc and 
/etc/profile   are already good, customisations do survive an upgrade.

/usr/share/skel/dot.cshrc   and 
/usr/share/skel/dot.profile lose customisation, I treat these as out of scope because there's no etc/ context.

Re: comment 0 I have a question, which I'll not raise in Bugzilla or via email; I might ping you in Mastodon.
Comment 5 commit-hook freebsd_committer freebsd_triage 2025-09-02 08:32:02 UTC
A commit in branch main references this bug:

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

commit aa730a66bc74696df85b21ec2719c75d8eab8c9f
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-09-02 08:22:56 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-09-02 08:22:56 +0000

    sh: Add config tag to /.profile

    The file /.profile is installed as a hard link to /root/.profile. The
    file in /root has the config tag, but the file in / does not, which
    causes it to be overwritten by pkg upgrade. Since they're linked, this
    also overwrites the file in /root.

    Add the config tag to the file in / as well, so pkg treates both links
    as config files and won't overwrite them.

    PR:             289097
    MFC after:      3 days
    Reviewed by:    bapt, emaste
    Differential Revision:  https://reviews.freebsd.org/D52162

 bin/sh/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2025-09-10 20:41:51 UTC
A commit in branch stable/14 references this bug:

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

commit f103de98b855e69f1c0e1e90f7a174ae06acf892
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-09-02 08:22:56 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-09-10 20:41:08 +0000

    sh, csh: Add config tag to /.profile and /.cshrc

    The file /.profile is installed as a hard link to /root/.profile. The
    file in /root has the config tag, but the file in / does not, which
    causes it to be overwritten by pkg upgrade. Since they're linked, this
    also overwrites the file in /root.

    Add the config tag to the file in / as well, so pkg treates both links
    as config files and won't overwrite them.

    For stable/14, also add this to /.cshrc, which is no longer installed
    in 15.0.

    PR:             289097
    MFC after:      3 days
    Reviewed by:    bapt, emaste
    Differential Revision:  https://reviews.freebsd.org/D52162

    (cherry picked from commit aa730a66bc74696df85b21ec2719c75d8eab8c9f)

    sh: Fix non-NO_ROOT installconfig

    When building without NO_ROOT, ${TAG_ARGS} is not set, which means we
    pass ",config" as an install(1) argument.  Only add the config tag if
    ${TAG_ARGS} is defined to begin with.

    Fixes:  aa730a66bc74 ("sh: Add config tag to /.profile")
    Reported by:    bz

    (cherry picked from commit b197d2abcb6895d78bc9df8404e374397aa44748)

 bin/csh/Makefile | 4 ++--
 bin/sh/Makefile  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2025-09-30 06:05:01 UTC
A commit in branch main references this bug:

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

commit d31e342bcc8e22d7eb25c21a711cd4b8a54db6c0
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-09-30 06:02:06 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-09-30 06:02:06 +0000

    sh: Remove /.profile

    root's home directory was moved to /root many years ago, so there's no
    reason to keep this old link.  This brings sh in line with csh, where
    /.cshrc was removed in dcb65c5a94d4.

    Relnotes:       yes
    Approved by:    re (cperciva)
    MFC after:      1 day
    PR:             289097
    Reviewed by:    cperciva, jilles, bapt, emaste
    Differential Revision:  https://reviews.freebsd.org/D52161

 bin/sh/Makefile | 9 ---------
 1 file changed, 9 deletions(-)
Comment 8 devnull freebsd_committer freebsd_triage 2025-09-30 17:53:15 UTC
(In reply to commit-hook from comment #7)

Maybe note this in UPDATING for main, and (after MFC) in a release note for 15.0.
Comment 9 devnull freebsd_committer freebsd_triage 2025-09-30 17:54:28 UTC
Sorry, I didn't see the Relnotes: line.
Comment 10 commit-hook freebsd_committer freebsd_triage 2025-10-01 12:36:45 UTC
A commit in branch stable/15 references this bug:

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

commit b4b91207ab6f38db33f853b2d6b3f1bb806f94f1
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-09-30 06:02:06 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-10-01 10:35:10 +0000

    sh: Remove /.profile

    root's home directory was moved to /root many years ago, so there's no
    reason to keep this old link.  This brings sh in line with csh, where
    /.cshrc was removed in dcb65c5a94d4.

    Relnotes:       yes
    Approved by:    re (cperciva)
    MFC after:      1 day
    PR:             289097
    Reviewed by:    cperciva, jilles, bapt, emaste
    Differential Revision:  https://reviews.freebsd.org/D52161

    (cherry picked from commit d31e342bcc8e22d7eb25c21a711cd4b8a54db6c0)

    bin/sh: Fix the build

    Removing <bsd.prog.mk> was unintentional; put it back.

    Fixes:          d31e342bcc8e ("sh: Remove /.profile")
    MFC after:      1 day

    (cherry picked from commit bb0955ee4db8870bb013cf7d208ad9b2fc27b619)

 bin/sh/Makefile | 7 -------
 1 file changed, 7 deletions(-)
Comment 11 Lexi Winter freebsd_committer freebsd_triage 2025-10-02 04:01:15 UTC
for non-pkgbase users, this doesn't need an UPDATING entry because the final version of the change doesn't remove an existing /.profile, so this doesn't affect updates.  i thought this was preferable to potentially deleting a user's customised profile.

possibly an UPDATING entry would be justified for pkgbase, but i doubt anyone was even aware this file existed except when it broke their pkgbase upgrades.

in any case, the original bug should be fixed for both 14 and 15 now.