Print this page
3808 sulogin should reset console to text mode
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sulogin/sulogin.c
          +++ new/usr/src/cmd/sulogin/sulogin.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
       21 +
  21   22  /*
       23 + * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
       24 + */
       25 +
       26 +/*
  22   27   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   28   * Use is subject to license terms.
  24   29   */
  25   30  
  26   31  /*
  27   32   *      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
  28   33   *      All rights reserved.
  29   34   *
  30   35   *      Copyright (c) 1987, 1988 Microsoft Corporation.
  31   36   *      All rights reserved.
↓ open down ↓ 36 lines elided ↑ open up ↑
  68   73  #include <strings.h>
  69   74  #include <deflt.h>
  70   75  #include <limits.h>
  71   76  #include <errno.h>
  72   77  #include <crypt.h>
  73   78  #include <auth_attr.h>
  74   79  #include <auth_list.h>
  75   80  #include <nss_dbdefs.h>
  76   81  #include <user_attr.h>
  77   82  #include <sys/vt.h>
       83 +#include <sys/kd.h>
  78   84  
  79   85  /*
  80   86   * Intervals to sleep after failed login
  81   87   */
  82   88  #ifndef SLEEPTIME
  83   89  #define SLEEPTIME       4       /* sleeptime before login incorrect msg */
  84   90  #endif
  85   91  
  86   92  #define SLEEPTIME_MAX   5       /* maximum sleeptime */
  87   93  
↓ open down ↓ 347 lines elided ↑ open up ↑
 435  441          sa.sa_flags = 0;
 436  442          (void) sigemptyset(&sa.sa_mask);
 437  443          (void) sigaction(SIGTERM, &sa, NULL);
 438  444          (void) sigaction(SIGKILL, &sa, NULL);
 439  445          (void) sigaction(SIGHUP, &sa, NULL);
 440  446  }
 441  447  
 442  448  static void
 443  449  main_loop(char *devname, boolean_t cttyflag)
 444  450  {
 445      -        int             fd, i;
      451 +        int             fd, fb, i;
 446  452          char            *user = NULL;           /* authorized user */
 447  453          char            *pass;                  /* password from user */
 448  454          char            *cpass;                 /* crypted password */
 449  455          struct spwd     spwd;
 450  456          struct spwd     *lshpw;                 /* local shadow */
 451  457          char            shadow[NSS_BUFLEN_SHADOW];
 452  458          FILE            *sysmsgfd;
 453  459  
 454  460          for (i = 0; i < 3; i++)
 455  461                  (void) close(i);
↓ open down ↓ 15 lines elided ↑ open up ↑
 471  477  
 472  478          if (fd != 0)
 473  479                  (void) dup2(fd, STDIN_FILENO);
 474  480          if (fd != 1)
 475  481                  (void) dup2(fd, STDOUT_FILENO);
 476  482          if (fd != 2)
 477  483                  (void) dup2(fd, STDERR_FILENO);
 478  484          if (fd > 2)
 479  485                  (void) close(fd);
 480  486  
      487 +        /* Stop progress bar and reset console mode to text */
      488 +        if ((fb = open("/dev/fb", O_RDONLY)) >= 0) {
      489 +                (void) ioctl(fb, KDSETMODE, KD_RESETTEXT);
      490 +                (void) close(fb);
      491 +        }
      492 +
 481  493          sysmsgfd = fopen("/dev/sysmsg", "w");
 482  494  
 483  495          sanitize_tty(fileno(stdin));
 484  496  
 485  497          for (;;) {
 486  498                  do {
 487  499                          (void) printf("\nEnter user name for system "
 488  500                              "maintenance (control-d to bypass): ");
 489  501                          user = sulogin_getinput(devname, ECHOON);
 490  502                          if (user == NULL) {
↓ open down ↓ 313 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX