Bug 269497 - sysutils/nut: set group in rc.d script
Summary: sysutils/nut: set group in rc.d script
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Cy Schubert
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-11 15:38 UTC by Dan Langille
Modified: 2023-03-17 18:46 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (cy)


Attachments
add NUT_GROUP=${NUT_GROUP} to SUB_LIST (618 bytes, patch)
2023-02-11 15:38 UTC, Dan Langille
no flags Details | Diff
Seek out and chown/chgrp other nut files hiding in the cracks (2.06 KB, patch)
2023-02-12 03:59 UTC, Cy Schubert
no flags Details | Diff
builds upon your patch (618 bytes, patch)
2023-02-12 17:11 UTC, Dan Langille
no flags Details | Diff
Patch to implement optional ownership fixes. (4.45 KB, patch)
2023-02-13 18:59 UTC, Cy Schubert
no flags Details | Diff
Fixed the last couple of errors (5.27 KB, patch)
2023-02-14 00:27 UTC, Cy Schubert
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Langille freebsd_committer freebsd_triage 2023-02-11 15:38:37 UTC
Created attachment 240092 [details]
add NUT_GROUP=${NUT_GROUP} to SUB_LIST

At present, the rc.d script contains this:

[knew dan ~] % grep GROUP /usr/local/etc/rc.d/nut
		chgrp %%NUT_GROUP%% ${nut_prefix}/etc/nut/upsd.users

The attache patch fixes the issue by adding NUT_GROUP=${NUT_GROUP} to SUB_LIST
Comment 1 Dan Langille freebsd_committer freebsd_triage 2023-02-11 15:39:07 UTC
I'm happy to commit this if you prefer.
Comment 2 Cy Schubert freebsd_committer freebsd_triage 2023-02-11 16:16:15 UTC
Oops. Fixed.
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-02-11 16:16:33 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6b4b52c843c34374e12b0b894129549caf22b276

commit 6b4b52c843c34374e12b0b894129549caf22b276
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-02-11 16:13:05 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-02-11 16:15:46 +0000

    sysutils/nut*: Add missing SUB_LIST

    a4cc1509a9b6 failed to add NUT_GROUP to SUB_LIST. This fixes the error.

    PR:             269497
    Submitted by:   dvl
    Reported by:    dvl
    Fixes:          a4cc1509a9b6

 sysutils/nut-devel/Makefile | 4 ++--
 sysutils/nut/Makefile       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
Comment 4 Dan Langille freebsd_committer freebsd_triage 2023-02-11 19:02:47 UTC
FYI, I have since seen this this:

Feb 11 15:27:34 knew upssched[16604]: Can't open /usr/local/etc/nut/upssched.conf: Permission denied
Feb 11 15:32:39 knew upssched[18217]: Can't open /usr/local/etc/nut/upssched.conf: Permission denied
Feb 11 15:37:39 knew upssched[19798]: Can't open /usr/local/etc/nut/upssched.conf: Permission denied

% ls -l /usr/local/etc/nut/upssched.conf
-rw-r-----  1 root  uucp  417 2022.07.01 14:11 /usr/local/etc/nut/upssched.conf

On a host upon which I had already done this:

sudo chgrp nut     /usr/local/etc/nut/ups.conf
sudo chown nut:nut /usr/local/etc/nut/heartbeat.dev

What uucp files do I have?

[knew dan /usr/local/etc] % sudo find /usr/local -gid uucp
/usr/local/etc/nut/upsd.conf
/usr/local/etc/nut/upssched.conf
/usr/local/etc/nut/nut.conf
/usr/local/etc/nut/pushover.sh
/usr/local/etc/nut/upsmon.conf

[knew dan /usr/local/etc] % ls -l /usr/local/etc/nut | grep uucp
-rw-r-----  1 root  uucp      90 2020.09.05 19:27 nut.conf
-rwxr-x---  1 dan   uucp     492 2022.07.01 14:23 pushover.sh
-rw-r-----  1 root  uucp      81 2023.01.03 15:26 upsd.conf
-rw-r-----  1 root  uucp     235 2020.09.12 14:48 upsmon.conf
-rw-r-----  1 root  uucp     417 2022.07.01 14:11 upssched.conf

Repaired with:

% sudo find /usr/local/etc/nut -gid uucp -exec chgrp nut {} \;
Comment 5 Cy Schubert freebsd_committer freebsd_triage 2023-02-12 03:59:02 UTC
Created attachment 240103 [details]
Seek out and chown/chgrp other nut files hiding in the cracks

(In reply to Dan Langille from comment #4)
Interesting. Mine is:

cwfw# lh /usr/local/etc/nut/upssched.conf
-rw-r--r--  1 root  wheel   4.1K Feb 11 18:43 /usr/local/etc/nut/upssched.conf
cwfw# 

Likely because mine has not been altered while yours has.

Attached is a more thorough patch.

I'm kinda loathed to do a find here but considering the impact it's the only solution. The find should be removed a year or two from now -- what are your thoughts about this?
Comment 6 Dan Langille freebsd_committer freebsd_triage 2023-02-12 17:11:34 UTC
Created attachment 240109 [details]
builds upon your patch

This patch:

* replaces nut with %%NUT_USER|GROUP%% in nut.newsyslog, now renamed to nut.newsyslog.in
* more use of %%NUT_USER%% and %%NUT_GROUP%% in nut.in

I had a more elaborate reply before I lost it and retyped this one.

I had thought about an IF around the chmod/chown stuff in case the user wanted to turn it off. Something like

nut_file_fixup=${nut_file_fixup:-"YES"}

if [ ${nut_file_fixup} == "YES" ]
then
        find ${nut_prefix}/etc/nut -user  uucp -exec chown %%NUT_USER%% {} \;
        find ${nut_prefix}/etc/nut -group uucp -exec chgrp %%NUT_GROUP%% {} \;
        find %%STATEDIR%% -user uucp -exec chown nut {} \;
        find %%STATEDIR%% -group uucp -exec chgrp nut {} \;
fi

etc.

I figure: fixing the file perms is the lesser evil of doing nothing.
Comment 7 Cy Schubert freebsd_committer freebsd_triage 2023-02-13 03:35:00 UTC
(In reply to Dan Langille from comment #6)

I already committed the patch.

I'm not so sure about the if. I think this would confuse more users: more PRs and private emails asking questions about it.

OTOH the "if" would save on cycles. I like that. But, how many people, other than you and me, would use it? Maybe an UPDATING entry to document it?
Comment 8 Dan Langille freebsd_committer freebsd_triage 2023-02-13 14:15:27 UTC
The "if", for me, wasn't to save cycles. It was to allow for users which have non-standard permissions on those files, for whatever reasons.

I think an UPDATING entry is enough.
Comment 9 Cy Schubert freebsd_committer freebsd_triage 2023-02-13 18:59:56 UTC
Created attachment 240132 [details]
Patch to implement optional ownership fixes.

Can you please review and comment?
Comment 10 Dan Langille freebsd_committer freebsd_triage 2023-02-13 23:51:49 UTC
Comment on attachment 240132 [details]
Patch to implement optional ownership fixes.

I see %%NUT_GROUP%% is use but not %%NUT_USER%%. 

Tomorrow I can amend that patch, but not tonight.
Comment 11 Cy Schubert freebsd_committer freebsd_triage 2023-02-14 00:27:28 UTC
Created attachment 240143 [details]
Fixed the last couple of errors

This squashed commit should address all issues discussed here.
Comment 12 Dan Langille freebsd_committer freebsd_triage 2023-02-14 17:50:13 UTC
Comment on attachment 240143 [details]
Fixed the last couple of errors

Looks fine to me.
Comment 13 commit-hook freebsd_committer freebsd_triage 2023-02-14 18:40:59 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6558c25069901328610d155bea362aeb7ab00f17

commit 6558c25069901328610d155bea362aeb7ab00f17
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-02-13 18:57:30 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-02-14 18:40:00 +0000

    sysutils/nut*: Make nut file ownership fixes optional with default enabled

    The nut file ownership fixups due to the UID/GID change from uucp/uucp
    to nut/nut may not be desireable for all users. Some users with custom
    file ownership may wish ownership to remain untouched. This revision
    to the nut family of ports/packages allows users to optionally disable
    automatic fixup of nut file ownership.

    While at it, rather than use a hardcoded string for user/group ownerships,
    use the set parameters in Makefile.

    PR:             269497
    suggested by:   dvl

 UPDATING                        | 10 ++++++++++
 sysutils/nut-devel/Makefile     |  4 ++--
 sysutils/nut-devel/files/nut.in | 11 +++++++----
 sysutils/nut/Makefile           |  4 ++--
 sysutils/nut/files/nut.in       | 11 +++++++----
 5 files changed, 28 insertions(+), 12 deletions(-)
Comment 14 Vladimir Druzenko freebsd_committer freebsd_triage 2023-02-14 20:18:11 UTC
Missed "; then" in line with "if" in sysutils/nut/files/nut.in:
        if [ "${nut_file_fixup}" == "YES" ] <== HERE
                find ${nut_prefix}/etc/nut -user uucp -exec chown nut {} \;
                find ${nut_prefix}/etc/nut -group uucp -exec chgrp nut {} \;
                find /var/db/nut -user uucp -exec chown nut {} \;
                find /var/db/nut -group uucp -exec chgrp nut {} \;
        fi
Comment 15 commit-hook freebsd_committer freebsd_triage 2023-02-14 20:36:28 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e2630f644fcb41ca2f9cba64a2e4416043b59fda

commit e2630f644fcb41ca2f9cba64a2e4416043b59fda
Author:     Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2023-02-14 20:33:59 +0000
Commit:     Cy Schubert <cy@FreeBSD.org>
CommitDate: 2023-02-14 20:33:59 +0000

    sysutils/nut*: Fix syntax error

    Add missing then.

    PR:             269497
    Reported by:    <vvd@unislabs.com>
    Fixes:          6558c2506990

 sysutils/nut-devel/Makefile     | 2 +-
 sysutils/nut-devel/files/nut.in | 2 +-
 sysutils/nut/Makefile           | 2 +-
 sysutils/nut/files/nut.in       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
Comment 16 Cy Schubert freebsd_committer freebsd_triage 2023-02-14 20:37:22 UTC
(In reply to VVD from comment #14)
Thanks. That's the second time today (in 30 minutes). Once at $JOB and another here.
Comment 17 Cy Schubert freebsd_committer freebsd_triage 2023-03-17 18:46:56 UTC
Fixed.