From: Tobias Stoeckmann Date: Sat, 10 Jan 2026 21:56:45 +0000 (+0100) Subject: login: only print regular files for motd X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9acc0ca1c72e218962dc2b176f1ed6f665c6618b;p=thirdparty%2Futil-linux.git login: only print regular files for motd The existing code tries to only print content of non-empty files, but does not check the target of an encountered symbolic link, which could be even something else, e.g. a fifo. Add the missing check to the motddir_filter function. Signed-off-by: Tobias Stoeckmann --- diff --git a/login-utils/login.c b/login-utils/login.c index dd2e87dc9..66f81516a 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -296,6 +296,7 @@ static const char *get_thishost(struct login_context *cxt, const char **domain) #ifdef MOTDDIR_SUPPORT static int motddir_filter(const struct dirent *d) { + struct stat st; size_t namesz; #ifdef _DIRENT_HAVE_D_TYPE @@ -311,6 +312,11 @@ static int motddir_filter(const struct dirent *d) strcmp(d->d_name + (namesz - MOTDDIR_EXTSIZ), MOTDDIR_EXT) != 0) return 0; + if (stat(d->d_name, &st) < 0) + return 0; + if (!S_ISREG(st.st_mode) || st.st_size == 0) + return 0; + return 1; /* accept */ }