Index: libexec/rc/rc.d/motd =================================================================== --- libexec/rc/rc.d/motd +++ libexec/rc/rc.d/motd @@ -27,22 +27,19 @@ # to prevent possible race conditions. # check_startmsgs && echo -n 'Updating 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 + # Create 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}" + elif [ ! -f "${TEMPLATE}" ]; then + # If template is missing, create an empty 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 T=`mktemp -t motd` uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T} Index: share/man/man5/motd.5 =================================================================== --- share/man/man5/motd.5 +++ share/man/man5/motd.5 @@ -10,12 +10,13 @@ .Nm motd .Nd file containing message(s) of the day .Sh DESCRIPTION -The file -.Pa /var/run/motd +The +.Nm 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. +.Pp During system startup, a line containing the kernel version string is prepended to .Pa /etc/motd.template @@ -30,6 +31,22 @@ service motd restart .Ed .Pp +If +.Pa /etc/motd +exists and is a regular file, it will be used to overwrite +.Pa /etc/motd.template . +It will then be removed and replaced with a symbolic link to +.Pa /var/run/motd . +.Pp +To use an immutable +.Pa /etc/motd , +create it as a regular file and set +.Va update_motd +to +.Dq Li NO +in +.Xr rc.conf 5 . +.Pp Individual users may suppress the display of this file by creating a file named .Dq Pa .hushlogin @@ -37,13 +54,17 @@ .Xr login.conf 5 . .Sh FILES .Bl -tag -width $HOME/.hushlogin -compact +.It Pa /etc/motd +Symbolic link to actual +.Pa motd +file or regular file with the message of the day. .It Pa /etc/motd.template The template file that system administrators can edit. .It Pa /var/run/motd -The message of the day. +The generated message of the day. .It Pa $HOME/.hushlogin Suppresses output of -.Pa /var/run/motd . +.Pa /etc/motd . .El .Sh EXAMPLES .Bd -literal @@ -58,5 +79,4 @@ Prior to .Fx 13.0 , .Nm -lived in -.Pa /etc . +was a regular file. Index: usr.bin/login/Makefile =================================================================== --- usr.bin/login/Makefile +++ usr.bin/login/Makefile @@ -31,5 +31,6 @@ echo "./etc/login.conf.db type=file mode=0644 uname=root gname=wheel" | \ cat -l >> ${METALOG} .endif + ${INSTALL_SYMLINK} ${TAG_ARGS} ../var/run/motd ${DESTDIR}/etc/motd .include Index: usr.bin/login/login.1 =================================================================== --- usr.bin/login/login.1 +++ usr.bin/login/login.1 @@ -131,7 +131,7 @@ changes device protections .It Pa /etc/login.conf login class capabilities database -.It Pa /var/run/motd +.It Pa /etc/motd message-of-the-day .It Pa /var/mail/user system mailboxes Index: usr.bin/login/login.conf =================================================================== --- usr.bin/login/login.conf +++ usr.bin/login/login.conf @@ -25,7 +25,7 @@ default:\ :passwd_format=sha512:\ :copyright=/etc/COPYRIGHT:\ - :welcome=/var/run/motd:\ + :welcome=/etc/motd:\ :setenv=BLOCKSIZE=K:\ :mail=/var/mail/$:\ :path=/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin ~/bin:\ @@ -128,7 +128,7 @@ ## #standard:\ # :copyright=/etc/COPYRIGHT:\ -# :welcome=/var/run/motd:\ +# :welcome=/etc/motd:\ # :setenv=BLOCKSIZE=K:\ # :mail=/var/mail/$:\ # :path=~/bin /bin /usr/bin /usr/local/bin:\ Index: usr.bin/login/pathnames.h =================================================================== --- usr.bin/login/pathnames.h +++ usr.bin/login/pathnames.h @@ -35,6 +35,6 @@ #include #define _PATH_HUSHLOGIN ".hushlogin" -#define _PATH_MOTDFILE "/var/run/motd" +#define _PATH_MOTDFILE "/etc/motd" #define _PATH_FBTAB "/etc/fbtab" #define _PATH_LOGINDEVPERM "/etc/logindevperm" Index: usr.sbin/mergemaster/mergemaster.sh =================================================================== --- usr.sbin/mergemaster/mergemaster.sh +++ usr.sbin/mergemaster/mergemaster.sh @@ -714,7 +714,9 @@ # Avoid comparing the following user specified files for file in ${IGNORE_FILES}; do - test -e ${TEMPROOT}/${file} && unlink ${TEMPROOT}/${file} + if [ -L ${TEMPROOT}/${file} -o -e ${TEMPROOT}/${file} ]; then + unlink ${TEMPROOT}/${file} + fi done # We really don't want to have to deal with files like login.conf.db, pwd.db,