- run_shell ( tmp, 1, 0, 0); /* exec the shell finally. */
-
- return EXIT_FAILURE;
-}
-
-
-
-static int login_prompt ( char *buf_name )
-{
- char buf [1024];
- char *sp, *ep;
- int i;
-
- for(i=0; i<EMPTY_USERNAME_COUNT; i++) {
- print_login_prompt();
-
- if ( !fgets ( buf, sizeof( buf ) - 1, stdin ))
- return 0;
-
- if ( !strchr ( buf, '\n' ))
- return 0;
-
- for ( sp = buf; isspace ( *sp ); sp++ ) { }
- for ( ep = sp; isgraph ( *ep ); ep++ ) { }
-
- *ep = 0;
- safe_strncpy(buf_name, sp, USERNAME_SIZE);
- if(buf_name[0])
- return 1;
- }
- return 0;
-}
-
-
-static int check_nologin ( int amroot )
-{
- if ( access ( bb_path_nologin_file, F_OK ) == 0 ) {
- FILE *fp;
- int c;
-
- if (( fp = fopen ( bb_path_nologin_file, "r" ))) {
- while (( c = getc ( fp )) != EOF )
- putchar (( c == '\n' ) ? '\r' : c );
-
- fflush ( stdout );
- fclose ( fp );
- } else {
- puts ( "\r\nSystem closed for routine maintenance.\r" );
- }
- if ( !amroot )
- return 1;
-
- puts ( "\r\n[Disconnect bypassed -- root login allowed.]\r" );
- }
- return 0;
-}
-
-#ifdef CONFIG_FEATURE_SECURETTY
-
-static int check_tty ( const char *tty )
-{
- FILE *fp;
- int i;
- char buf[BUFSIZ];
-
- if (( fp = fopen ( bb_path_securetty_file, "r" ))) {
- while ( fgets ( buf, sizeof( buf ) - 1, fp )) {
- for ( i = strlen( buf ) - 1; i >= 0; --i ) {
- if ( !isspace ( buf[i] ))
- break;
- }
- buf[++i] = '\0';
- if (( buf [0] == '\0' ) || ( buf [0] == '#' ))
- continue;
-
- if ( strcmp ( buf, tty ) == 0 ) {
- fclose ( fp );
- return 1;
- }
- }
- fclose(fp);
- return 0;
- }
- /* A missing securetty file is not an error. */
- return 1;
-}
-
-#endif
-
-/* returns 1 if true */
-static int is_my_tty ( const char *tty )
-{
- struct stat by_name, by_fd;
-
- if ( stat ( tty, &by_name ) || fstat ( 0, &by_fd ))
- return 0;
-
- if ( by_name. st_rdev != by_fd. st_rdev )
- return 0;
- else
- return 1;
-}
-
-
-static void motd (void)
-{
- FILE *fp;
- 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();