-static void motd (void)
-{
- FILE *fp;
- register int c;
-
- if (( fp = fopen ( bb_path_motd_file, "r" ))) {
- while (( c = getc ( fp )) != EOF )
- putchar ( c );
- fclose ( fp );
- }
-}
-
-
-#ifdef CONFIG_FEATURE_UTMP
-// vv Taken from tinylogin utmp.c vv
-
-#define NO_UTENT \
- "No utmp entry. You must exec \"login\" from the lowest level \"sh\""
-#define NO_TTY \
- "Unable to determine your tty name."
-
-/*
- * checkutmp - see if utmp file is correct for this process
- *
- * System V is very picky about the contents of the utmp file
- * and requires that a slot for the current process exist.
- * The utmp file is scanned for an entry with the same process
- * ID. If no entry exists the process exits with a message.
- *
- * The "picky" flag is for network and other logins that may
- * use special flags. It allows the pid checks to be overridden.
- * This means that getty should never invoke login with any
- * command line flags.
- */
-
-static void checkutmp(int picky)
-{
- char *line;
- struct utmp *ut;
- pid_t pid = getpid();
-
- setutent();
-
- /* First, try to find a valid utmp entry for this process. */
- while ((ut = getutent()))
- if (ut->ut_pid == pid && ut->ut_line[0] && ut->ut_id[0] &&
- (ut->ut_type == LOGIN_PROCESS || ut->ut_type == USER_PROCESS))
- break;
-
- /* If there is one, just use it, otherwise create a new one. */
- if (ut) {
- utent = *ut;
- } else {
- time_t t_tmp;
-
- if (picky) {
- puts(NO_UTENT);
- exit(1);
- }
- line = ttyname(0);
- if (!line) {
- puts(NO_TTY);
- exit(1);
- }
- if (strncmp(line, "/dev/", 5) == 0)
- line += 5;
- memset((void *) &utent, 0, sizeof utent);
- utent.ut_type = LOGIN_PROCESS;
- utent.ut_pid = pid;
- strncpy(utent.ut_line, line, sizeof utent.ut_line);
- /* XXX - assumes /dev/tty?? */
- strncpy(utent.ut_id, utent.ut_line + 3, sizeof utent.ut_id);
- strncpy(utent.ut_user, "LOGIN", sizeof utent.ut_user);
- t_tmp = (time_t)utent.ut_time;
- time(&t_tmp);
- }
-}
-
-/*
- * setutmp - put a USER_PROCESS entry in the utmp file
- *
- * setutmp changes the type of the current utmp entry to
- * USER_PROCESS. the wtmp file will be updated as well.
- */
-
-static void setutmp(const char *name, const char *line ATTRIBUTE_UNUSED)
-{
- time_t t_tmp = (time_t)utent.ut_time;
-
- utent.ut_type = USER_PROCESS;
- strncpy(utent.ut_user, name, sizeof utent.ut_user);
- time(&t_tmp);
- /* other fields already filled in by checkutmp above */
- setutent();
- pututline(&utent);
- endutent();
-#ifdef CONFIG_FEATURE_WTMP
- if (access(bb_path_wtmp_file, R_OK|W_OK) == -1) {
- close(creat(bb_path_wtmp_file, 0664));
- }
- updwtmp(bb_path_wtmp_file, &utent);
-#endif