The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/boot/getpasswd.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include <u.h>
    2 #include <libc.h>
    3 #include <../boot/boot.h>
    4 
    5 void
    6 getpasswd(char *p, int len)
    7 {
    8         char c;
    9         int i, n, fd;
   10 
   11         fd = open("#c/consctl", OWRITE);
   12         if(fd < 0)
   13                 fatal("can't open consctl; please reboot");
   14         write(fd, "rawon", 5);
   15  Prompt:                
   16         print("password: ");
   17         n = 0;
   18         for(;;){
   19                 do{
   20                         i = read(0, &c, 1);
   21                         if(i < 0)
   22                                 fatal("can't read cons; please reboot");
   23                 }while(i == 0);
   24                 switch(c){
   25                 case '\n':
   26                         p[n] = '\0';
   27                         close(fd);
   28                         print("\n");
   29                         return;
   30                 case '\b':
   31                         if(n > 0)
   32                                 n--;
   33                         break;
   34                 case 'u' - 'a' + 1:             /* cntrl-u */
   35                         print("\n");
   36                         goto Prompt;
   37                 default:
   38                         if(n < len - 1)
   39                                 p[n++] = c;
   40                         break;
   41                 }
   42         }
   43 }

Cache object: c674f626ac551e2c43cebb6e75c70750


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.