userpasswd.c
来自「著名操作系统Plan 9的第三版的部分核心源代码。现在很难找到了。Plan 9是」· C语言 代码 · 共 51 行
C
51 行
#include <u.h>#include <libc.h>#include <auth.h>#include <../boot/boot.h>char password[NAMELEN];#ifdef asdfextern char *sauth;#endif asdfchar *homsg = "can't set user name or key; please reboot";/* * get/set user name and password. verify password with auth server. */voiduserpasswd(int islocal, Method *mp){ int fd; char *msg; char hostkey[DESKEYLEN]; if(*username == 0 || strcmp(username, "none") == 0){ strcpy(username, "none"); outin("user", username, sizeof(username)); } fd = -1; while(strcmp(username, "none") != 0){ getpasswd(password, sizeof password); passtokey(hostkey, password); fd = -1; if(islocal) break; msg = checkkey(mp, username, hostkey); if(msg == 0) break; fprint(2, "?%s\n", msg); outin("user", username, sizeof(username)); } if(fd > 0) close(fd); /* set host's key */ if(writefile("#c/key", hostkey, DESKEYLEN) < 0) fatal(homsg); /* set host's owner (and uid of current process) */ if(writefile("#c/hostowner", username, strlen(username)) < 0) fatal(homsg);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?