2007-10-07 19:44:02 +08:00
|
|
|
/*
|
2021-12-05 23:35:27 +08:00
|
|
|
* SPDX-FileCopyrightText: 1989 - 1991, Julianne Frances Haugh
|
|
|
|
* SPDX-FileCopyrightText: 1996 - 1997, Marek Michałkiewicz
|
|
|
|
* SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
|
|
|
|
* SPDX-FileCopyrightText: 2010 , Nicolas François
|
2007-10-07 19:44:02 +08:00
|
|
|
*
|
2021-12-05 23:35:27 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2007-10-07 19:44:02 +08:00
|
|
|
*/
|
2021-08-19 02:06:02 +08:00
|
|
|
|
2007-10-07 19:44:02 +08:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-11-11 07:46:11 +08:00
|
|
|
#ident "$Id$"
|
2007-10-07 19:47:01 +08:00
|
|
|
|
2007-10-07 19:44:02 +08:00
|
|
|
#include <stdio.h>
|
2023-02-20 03:40:16 +08:00
|
|
|
|
|
|
|
#include "alloc.h"
|
2007-10-07 19:44:02 +08:00
|
|
|
#include "defines.h"
|
|
|
|
#include "getdef.h"
|
2023-02-20 03:40:16 +08:00
|
|
|
#include "prototypes.h"
|
2007-10-07 19:44:02 +08:00
|
|
|
/*
|
|
|
|
* motd -- output the /etc/motd file
|
|
|
|
*
|
|
|
|
* motd() determines the name of a login announcement file and outputs
|
|
|
|
* it to the user's terminal at login time. The MOTD_FILE configuration
|
|
|
|
* option is a colon-delimited list of filenames.
|
|
|
|
*/
|
2007-10-07 19:45:23 +08:00
|
|
|
void motd (void)
|
2007-10-07 19:44:02 +08:00
|
|
|
{
|
2007-10-07 19:45:23 +08:00
|
|
|
FILE *fp;
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
char *motdlist;
|
|
|
|
const char *motdfile;
|
|
|
|
char *mb;
|
2022-08-05 23:40:29 +08:00
|
|
|
int c;
|
2007-10-07 19:44:02 +08:00
|
|
|
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
motdfile = getdef_str ("MOTD_FILE");
|
|
|
|
if (NULL == motdfile) {
|
2007-10-07 19:44:02 +08:00
|
|
|
return;
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
motdlist = xstrdup (motdfile);
|
2007-10-07 19:44:02 +08:00
|
|
|
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
for (mb = motdlist; ;mb = NULL) {
|
|
|
|
motdfile = strtok (mb, ":");
|
|
|
|
if (NULL == motdfile) {
|
|
|
|
break;
|
|
|
|
}
|
2007-10-07 19:44:02 +08:00
|
|
|
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
fp = fopen (motdfile, "r");
|
|
|
|
if (NULL != fp) {
|
|
|
|
while ((c = getc (fp)) != EOF) {
|
2007-10-07 19:44:02 +08:00
|
|
|
putchar (c);
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
}
|
2007-10-07 19:44:02 +08:00
|
|
|
fclose (fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fflush (stdout);
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
|
|
|
|
free (motdlist);
|
2007-10-07 19:44:02 +08:00
|
|
|
}
|
* libmisc/console.c, libmisc/motd.c, libmisc/setupenv.c,
libmisc/sulog.c, libmisc/hushed.c, libmisc/failure.c,
libmisc/loginprompt.c, libmisc/ttytype.c,
libmisc/pam_pass_non_interractive.c, src/userdel.c, src/login.c,
lib/commonio.c, lib/commonio.h: Fix some const issues.
* libmisc/motd.c: Avoid multi-statements lines.
* libmisc/motd.c: Support long MOTD_FILE.
* libmisc/list.c, lib/prototypes.h: Revert previous change.
dup_list and is_on_list are used with members as defined for the
group structure, and thus even if the list is not modified, the
list elements cannot be constant strings.
* libmisc/system.c: Avoid C++ comments.
* src/vipw.c: WITH_TCB cannot be tested inside a gettextized
string. Split the Usage string.
* lib/commonio.h: Re-indent.
2010-08-21 23:32:53 +08:00
|
|
|
|