Bug 267107 - [NEW PORT] sysutils/dynamic_motd: Dynamic /var/run/motd
Summary: [NEW PORT] sysutils/dynamic_motd: Dynamic /var/run/motd
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: Matthew Seaman
URL: https://github.com/sstallion/dynamic_...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-10-15 21:41 UTC by Steven Stallion
Modified: 2023-04-18 15:02 UTC (History)
3 users (show)

See Also:


Attachments
Patch submission (3.97 KB, application/mbox)
2022-10-15 21:41 UTC, Steven Stallion
no flags Details
Patch #2 (4.00 KB, patch)
2023-01-11 16:29 UTC, Steven Stallion
fuz: maintainer-approval+
Details | Diff
Patch #3 (4.00 KB, patch)
2023-04-17 19:13 UTC, Steven Stallion
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Stallion 2022-10-15 21:41:24 UTC
Created attachment 237362 [details]
Patch submission

dynamic_motd is a drop-in replacement for generating messages of the day on
FreeBSD 13.0 or later. During system startup, the file /var/run/motd is
replaced with a fifo whose content is generated by a user-configurable shell
script that is executed on each login. All other aspects of motd(5) are
preserved.

WWW: https://github.com/sstallion/dynamic_motd
Comment 1 Steven Stallion 2023-01-11 16:29:41 UTC
Created attachment 239405 [details]
Patch #2

Updated patch posted.
Comment 2 Steven Stallion 2023-03-04 16:37:14 UTC
Ping!
Comment 3 Robert Clausecker freebsd_committer freebsd_triage 2023-04-17 09:03:27 UTC
The reason your patch wasn't looked at is that it doesn't have the "maintainer-approved" flag set.  I'll set this flag for you, which may speed up the process.
Comment 4 Matthew Seaman freebsd_committer freebsd_triage 2023-04-17 09:06:04 UTC
This fails to build under poudriere:
```
=>> Recording filesystem state for prestage... done
=======================<phase: stage          >============================
===== env: DEVELOPER_MODE=yes STRICT_DEPENDS=yes USER=nobody UID=65534 GID=65534
===>  Staging for dynamic_motd-1.2
===>   Generating temporary packing list
installing DIRS CONFETCDIR
install  -d -m 0755 -o root  -g wheel  /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/etc
install: chown 0:0 /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/etc: Operation not permitted
installing DIRS CONFRCDDIR
install  -d -m 0755 -o root  -g wheel  /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/etc/rc.d
install: chown 0:0 /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/etc/rc.d: Operation not permitted
installing DIRS DOCSDIR
install  -d -m 0755 -o root  -g wheel  /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/share/doc/dynamic_motd
install: chown 0:0 /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/share/doc/dynamic_motd: Operation not permitted
installing DIRS EXAMPLESDIR
install  -d -m 0755 -o root  -g wheel  /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/share/examples/dynamic_motd
install: chown 0:0 /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/share/examples/dynamic_motd: Operation not permitted
installing DIRS SCRIPTSDIR
install  -d -m 0755 -o root  -g wheel  /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/libexec
install: chown 0:0 /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/libexec: Operation not permitted
install  -o root  -g wheel -m 555  dynamic_motd  /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/libexec/dynamic_motd
install: /wrkdirs/usr/ports/sysutils/dynamic_motd/work/stage/usr/local/libexec/dynamic_motd: chown/chgrp: Operation not permitted
*** Error code 71

Stop.
make[1]: stopped in /wrkdirs/usr/ports/sysutils/dynamic_motd/work/dynamic_motd-1.2
*** Error code 1

Stop.
make: stopped in /usr/ports/sysutils/dynamic_motd
```

You're requiring root-level access to install the files into staging.  That is a definite no-no -- package building must be possible as a non-root user. Instead of including bsd.prog.mk in the Makefile in your github sources, you'ld be better off just writing an explicit install target which takes account of the ${STAGEDIR} setting from the ports infrastructure.   Just install the files into staging using the current user's UID and GID.
Comment 5 Matthew Seaman freebsd_committer freebsd_triage 2023-04-17 09:12:47 UTC
(In reply to Matthew Seaman from comment #4)

You need to reference ${DESTDIR} which the ports infra will set as part of the do-install target.  Prepend that to all the locations you want to install files.
Comment 6 Matthew Seaman freebsd_committer freebsd_triage 2023-04-17 10:56:50 UTC
(In reply to Matthew Seaman from comment #5)

See: https://github.com/sstallion/dynamic_motd/pull/2
Comment 7 Steven Stallion 2023-04-17 13:46:29 UTC
Thanks all! I really appreciate the PR - it looks like it is failing CI due to a missing dependency in the Makefile. I'll take a look this afternoon, but this looks much better than what I had before.

For what it's worth, I'm more than happy to maintain this port.
Comment 8 Tobias Kortkamp freebsd_committer freebsd_triage 2023-04-17 14:18:36 UTC
(In reply to Matthew Seaman from comment #4)
That's what USES=uidfix is for.
Comment 9 Steven Stallion 2023-04-17 19:13:26 UTC
Created attachment 241547 [details]
Patch #3

Updated patch attached based on Matthew's changes
Comment 10 commit-hook freebsd_committer freebsd_triage 2023-04-18 06:39:46 UTC
A commit in branch main references this bug:

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

commit b5613f6f4f42d9fe4b28704055698b9038b93e81
Author:     Matthew Seaman <matthew@FreeBSD.org>
AuthorDate: 2023-04-18 06:36:55 +0000
Commit:     Matthew Seaman <matthew@FreeBSD.org>
CommitDate: 2023-04-18 06:38:58 +0000

    sysutils/dynamic_motd: -- new port

    dynamic_motd is a drop-in replacement for generating messages of the day on
    FreeBSD 13.0 or later. During system startup, the file /var/run/motd is
    replaced with a fifo whose content is generated by a user-configurable shell
    script that is executed on each login. All other aspects of motd(5) are
    preserved.

    PR:             267107
    Reported by:    Steven Stallion

 sysutils/Makefile                       |  1 +
 sysutils/dynamic_motd/Makefile (new)    | 19 +++++++++++++++++++
 sysutils/dynamic_motd/distinfo (new)    |  3 +++
 sysutils/dynamic_motd/pkg-descr (new)   |  5 +++++
 sysutils/dynamic_motd/pkg-message (new) | 23 +++++++++++++++++++++++
 sysutils/dynamic_motd/pkg-plist (new)   |  7 +++++++
 6 files changed, 58 insertions(+)
Comment 11 Matthew Seaman freebsd_committer freebsd_triage 2023-04-18 06:42:54 UTC
Committed, thanks!

Although I can't see why you've limited this to just FreeBSD 13 or above? 
There's nothing in the port I can see which means it wouldn't work on FreeBSD 12.
Comment 12 Steven Stallion 2023-04-18 15:02:31 UTC
(In reply to Matthew Seaman from comment #11)

Thanks Matthew!

With respect to requiring 13.0, this was due to /etc/motd moving to /var/run/motd in that release. This could certainly be adapted to use /etc/motd, but given some reactions folks had to /etc/motd changing to begin with, I didn't want to muddy the waters.