From owner-svn-src-all@freebsd.org Sat Jul 20 20:56:34 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4EB4EC6D3E; Sat, 20 Jul 2019 20:56:34 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 238048F4BF; Sat, 20 Jul 2019 20:56:34 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C72E418315; Sat, 20 Jul 2019 20:56:33 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x6KKuX7D011178; Sat, 20 Jul 2019 20:56:33 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x6KKuWsF011171; Sat, 20 Jul 2019 20:56:32 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201907202056.x6KKuWsF011171@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Sat, 20 Jul 2019 20:56:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350184 - in head: libexec/rc/rc.d release/picobsd/tinyware/login share/man/man5 usr.bin/login X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head: libexec/rc/rc.d release/picobsd/tinyware/login share/man/man5 usr.bin/login X-SVN-Commit-Revision: 350184 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 238048F4BF X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.98)[-0.983,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Jul 2019 20:56:34 -0000 Author: cem Date: Sat Jul 20 20:56:31 2019 New Revision: 350184 URL: https://svnweb.freebsd.org/changeset/base/350184 Log: motd: Generate from template to /var/run Update login(1), its manual pages, similar utilities, and motd.5 to refer to the new location. Suggested by: delphij@ (re: r349256) Reviewed by: bcr (manpages), delphij Differential Revision: https://reviews.freebsd.org/D20721 Added: head/usr.bin/login/motd.template - copied, changed from r350183, head/usr.bin/login/motd Deleted: head/usr.bin/login/motd Modified: head/libexec/rc/rc.d/motd head/release/picobsd/tinyware/login/pathnames.h head/share/man/man5/motd.5 head/usr.bin/login/Makefile head/usr.bin/login/login.1 head/usr.bin/login/login.conf head/usr.bin/login/pathnames.h Modified: head/libexec/rc/rc.d/motd ============================================================================== --- head/libexec/rc/rc.d/motd Sat Jul 20 20:47:07 2019 (r350183) +++ head/libexec/rc/rc.d/motd Sat Jul 20 20:56:31 2019 (r350184) @@ -4,48 +4,52 @@ # # PROVIDE: motd -# REQUIRE: mountcritremote +# REQUIRE: mountcritremote FILESYSTEMS # BEFORE: LOGIN . /etc/rc.subr name="motd" -desc="Update /etc/motd" +desc="Update /var/run/motd" rcvar="update_motd" start_cmd="motd_start" stop_cmd=":" +COMPAT_MOTD="/etc/motd" +TARGET="/var/run/motd" +TEMPLATE="/etc/motd.template" PERMS="644" motd_start() { - # Update kernel info in /etc/motd + # Update kernel info in /var/run/motd # Must be done *before* interactive logins are possible # to prevent possible race conditions. # check_startmsgs && echo -n 'Updating motd:' - if [ ! -f /etc/motd ]; then - install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd + if [ ! -f "${TEMPLATE}" ]; then + # Create missing template from existing regular motd file, if + # one exists. + if [ -f "${COMPAT_MOTD}" ]; then + sed '1{/^FreeBSD.*/{d;};};' "${COMPAT_MOTD}" > "${TEMPLATE}" + chmod $PERMS "${TEMPLATE}" + rm -f "${COMPAT_MOTD}" + else + # Otherwise, create an empty template file. + install -c -o root -g wheel -m ${PERMS} /dev/null "${TEMPLATE}" + fi + # Provide compatibility symlink: + if [ ! -h "${COMPAT_MOTD}" ]; then + ln -sF "${TARGET}" "${COMPAT_MOTD}" + fi fi - if [ ! -w /etc/motd ]; then - echo ' /etc/motd is not writable, update failed.' - return - fi - T=`mktemp -t motd` uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} - awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T} + cat "${TEMPLATE}" >> ${T} - if ! cmp -s $T /etc/motd; then - mv -f $T /etc/.motd.tmp - fsync /etc/.motd.tmp - mv -f /etc/.motd.tmp /etc/motd - chmod ${PERMS} /etc/motd - fsync /etc - else - rm -f $T - fi + install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}" + rm -f "$T" check_startmsgs && echo '.' } Modified: head/release/picobsd/tinyware/login/pathnames.h ============================================================================== --- head/release/picobsd/tinyware/login/pathnames.h Sat Jul 20 20:47:07 2019 (r350183) +++ head/release/picobsd/tinyware/login/pathnames.h Sat Jul 20 20:56:31 2019 (r350184) @@ -39,7 +39,7 @@ #include #define _PATH_HUSHLOGIN ".hushlogin" -#define _PATH_MOTDFILE "/etc/motd" +#define _PATH_MOTDFILE "/var/run/motd" #define _PATH_LOGACCESS "/etc/login.access" #define _PATH_FBTAB "/etc/fbtab" #define _PATH_LOGINDEVPERM "/etc/logindevperm" Modified: head/share/man/man5/motd.5 ============================================================================== --- head/share/man/man5/motd.5 Sat Jul 20 20:47:07 2019 (r350183) +++ head/share/man/man5/motd.5 Sat Jul 20 20:56:31 2019 (r350184) @@ -3,7 +3,7 @@ .\" This file is in the public domain. .\" $FreeBSD$ .\" -.Dd February 13, 1997 +.Dd July 20, 2019 .Dt MOTD 5 .Os .Sh NAME @@ -11,13 +11,16 @@ .Nd file containing message(s) of the day .Sh DESCRIPTION The file -.Pa /etc/motd +.Pa /var/run/motd is normally displayed by .Xr login 1 after a user has logged in but before the shell is run. It is generally used for important system-wide announcements. During system startup, a line containing the kernel version string is -prepended to this file. +prepended to +.Pa /etc/motd.template +and the contents are written to +.Pa /var/run/motd . .Pp Individual users may suppress the display of this file by creating a file named @@ -26,11 +29,13 @@ in their home directories or through .Xr login.conf 5 . .Sh FILES .Bl -tag -width $HOME/.hushlogin -compact -.It Pa /etc/motd +.It Pa /etc/motd.template +The template file that system administrators can edit. +.It Pa /var/run/motd The message of the day. .It Pa $HOME/.hushlogin Suppresses output of -.Pa /etc/motd . +.Pa /var/run/motd . .El .Sh EXAMPLES .Bd -literal @@ -41,3 +46,9 @@ FreeBSD 2.1.6.1-RELEASE (GENERIC) #0: Sun Dec 29 03:08 .Sh SEE ALSO .Xr login 1 , .Xr login.conf 5 +.Sh HISTORY +Prior to +.Fx 13.0 , +.Nm +lived in +.Pa /etc . Modified: head/usr.bin/login/Makefile ============================================================================== --- head/usr.bin/login/Makefile Sat Jul 20 20:47:07 2019 (r350183) +++ head/usr.bin/login/Makefile Sat Jul 20 20:56:31 2019 (r350184) @@ -3,7 +3,7 @@ .include -CONFS= fbtab login.conf motd login.access +CONFS= fbtab login.conf motd.template login.access PROG= login SRCS= login.c login_fbtab.c CFLAGS+=-DLOGALL Modified: head/usr.bin/login/login.1 ============================================================================== --- head/usr.bin/login/login.1 Sat Jul 20 20:47:07 2019 (r350183) +++ head/usr.bin/login/login.1 Sat Jul 20 20:56:31 2019 (r350184) @@ -28,7 +28,7 @@ .\" @(#)login.1 8.2 (Berkeley) 5/5/94 .\" $FreeBSD$ .\" -.Dd September 13, 2006 +.Dd July 20, 2019 .Dt LOGIN 1 .Os .Sh NAME @@ -131,7 +131,7 @@ result in an error exit from changes device protections .It Pa /etc/login.conf login class capabilities database -.It Pa /etc/motd +.It Pa /var/run/motd message-of-the-day .It Pa /var/mail/user system mailboxes Modified: head/usr.bin/login/login.conf ============================================================================== --- head/usr.bin/login/login.conf Sat Jul 20 20:47:07 2019 (r350183) +++ head/usr.bin/login/login.conf Sat Jul 20 20:56:31 2019 (r350184) @@ -25,7 +25,7 @@ default:\ :passwd_format=sha512:\ :copyright=/etc/COPYRIGHT:\ - :welcome=/etc/motd:\ + :welcome=/var/run/motd:\ :setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\ :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\ :nologin=/var/run/nologin:\ @@ -120,7 +120,7 @@ russian|Russian Users Accounts:\ ## #standard:\ # :copyright=/etc/COPYRIGHT:\ -# :welcome=/etc/motd:\ +# :welcome=/var/run/motd:\ # :setenv=MAIL=/var/mail/$,BLOCKSIZE=K:\ # :path=~/bin /bin /usr/bin /usr/local/bin:\ # :manpath=/usr/share/man /usr/local/man:\ Copied and modified: head/usr.bin/login/motd.template (from r350183, head/usr.bin/login/motd) ============================================================================== --- head/usr.bin/login/motd Sat Jul 20 20:47:07 2019 (r350183, copy source) +++ head/usr.bin/login/motd.template Sat Jul 20 20:56:31 2019 (r350184) @@ -1,4 +1,3 @@ -FreeBSD ?.?.? (UNKNOWN) Welcome to FreeBSD! @@ -18,4 +17,4 @@ Please include that output and any error messages when Introduction to manual pages: man man FreeBSD directory layout: man hier -Edit /etc/motd to change this login announcement. +Edit /etc/motd.template to change this login announcement. Modified: head/usr.bin/login/pathnames.h ============================================================================== --- head/usr.bin/login/pathnames.h Sat Jul 20 20:47:07 2019 (r350183) +++ head/usr.bin/login/pathnames.h Sat Jul 20 20:56:31 2019 (r350184) @@ -35,6 +35,6 @@ #include #define _PATH_HUSHLOGIN ".hushlogin" -#define _PATH_MOTDFILE "/etc/motd" +#define _PATH_MOTDFILE "/var/run/motd" #define _PATH_FBTAB "/etc/fbtab" #define _PATH_LOGINDEVPERM "/etc/logindevperm"