1 /* vi: set sw=4 ts=4: */
3 * issue.c: issue printing code
5 * Copyright (C) 2003 Bastian Blank <waldi@tuxbox.org>
7 * Optimize and correcting OCRNL by Vladimir Oleynik <dzo@simtreas.ru>
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
12 #include <sys/param.h> /* MAXHOSTNAMELEN */
13 #include <sys/utsname.h>
16 #define LOGIN " login: "
18 static const char fmtstr_d[] ALIGN1 = "%A, %d %B %Y";
19 static const char fmtstr_t[] ALIGN1 = "%H:%M:%S";
21 void FAST_FUNC print_login_issue(const char *issue_file, const char *tty)
33 puts("\r"); /* start a new line */
35 fp = fopen_for_read(issue_file);
38 while ((c = fgetc(fp)) != EOF) {
46 if (c == '\\' || c == '%') {
54 outbuf = uts.nodename;
67 outbuf = uts.domainname;
70 strftime(buf, sizeof(buf), fmtstr_d, localtime(&t));
73 strftime(buf, sizeof(buf), fmtstr_t, localtime(&t));
82 fputs(outbuf, stdout);
88 void FAST_FUNC print_login_prompt(void)
90 char *hostname = safe_gethostname();
92 fputs(hostname, stdout);
98 /* Clear dangerous stuff, set PATH */
99 static const char forbid[] ALIGN1 =
105 "LD_LIBRARY_PATH" "\0"
107 "LD_TRACE_LOADED_OBJECTS" "\0"
109 "LD_AOUT_LIBRARY_PATH" "\0"
110 "LD_AOUT_PRELOAD" "\0"
114 int FAST_FUNC sanitize_env_if_suid(void)
118 if (getuid() == geteuid())
126 putenv((char*)bb_PATH_root_path);
128 return 1; /* we indeed were run by different user! */