|
|
1.1 ! root 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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.