| plan 9 kernel history: overview | file list | diff list |
1992/0507/boot/userpasswd.c (diff list | history)
| 1992/0507/sys/src/9/boot/userpasswd.c:1,73 – 1992/0728/sys/src/9/boot/userpasswd.c:1,72 (short | long | prev | next) | ||
| 1992/0317 | #include <u.h> #include <libc.h> | |
| 1992/0322 | #include <auth.h> | |
| 1992/0317 | #include <../boot/boot.h> char password[NAMELEN]; | |
| 1992/0325 | #ifdef asdf | |
| 1992/0323 | extern char *sauth; | |
| 1992/0325 | #endif asdf | |
| 1992/0317 | /* * get/set user name and password. verify password with auth server. */ void | |
| 1992/0318 | userpasswd(int islocal, Method *mp) | |
| 1992/0317 | { char key[7]; char buf[8 + NAMELEN]; int fd, crfd; | |
| 1992/0323 |
| |
| 1992/0317 | if(*username == 0 || strcmp(username, "none") == 0){ strcpy(username, "none"); outin("user", username, sizeof(username)); } crfd = fd = -1; | |
| 1992/0507 | while(strcmp(username, "none") != 0){ | |
| 1992/0317 | getpasswd(password, sizeof password); | |
| 1992/0322 | passtokey(key, password); | |
| 1992/0317 | fd = open("#c/key", OWRITE); if(fd < 0) fatal("can't open #c/key; please reboot"); if(write(fd, key, 7) != 7) fatal("can't write #c/key; please reboot"); close(fd); crfd = open("#c/crypt", ORDWR); if(crfd < 0) fatal("can't open crypt file"); write(crfd, "E", 1); | |
| 1992/0325 | fd = -1; | |
| 1992/0507 | if(islocal) break; | |
| 1992/0325 | if(mp->auth) fd = (*mp->auth)(); | |
| 1992/0317 | if(fd < 0){ warning("password not checked!"); break; } strncpy(buf+8, username, NAMELEN); if(read(fd, buf, 8) != 8 || write(crfd, buf, 8) != 8 || read(crfd, buf, 8) != 8 || write(fd, buf, 8 + NAMELEN) != 8 + NAMELEN){ warning("password not checked!"); break; } if(read(fd, buf, 2) == 2 && buf[0]=='O' && buf[1]=='K') break; close(fd); outin("user", username, sizeof(username)); } close(fd); close(crfd); /* set user now that we're sure */ fd = open("#c/user", OWRITE|OTRUNC); if(fd >= 0){ if(write(fd, username, strlen(username)) < 0) warning("write user name"); close(fd); }else warning("open #c/user"); } | |