Annotation of lucent/sys/src/9/boot/f002506, revision 1.1.1.1

1.1       root        1: #include <u.h>
                      2: #include <libc.h>
                      3: #include <auth.h>
                      4: #include <../boot/boot.h>
                      5: 
                      6: char   password[NAMELEN];
                      7: 
                      8: char *homsg = "can't set user name or key; please reboot";
                      9: 
                     10: /*
                     11:  *  get/set user name and password.  verify password with auth server.
                     12:  */
                     13: void
                     14: userpasswd(int islocal, Method *mp)
                     15: {
                     16:        int fd;
                     17:        char *msg;
                     18:        char hostkey[DESKEYLEN];
                     19: 
                     20:        if(*username == 0 || strcmp(username, "none") == 0){
                     21:                strcpy(username, "none");
                     22:                outin(cpuflag, "user", username, sizeof(username));
                     23:        }
                     24:        fd = -1;
                     25:        while(strcmp(username, "none") != 0){
                     26:                getpasswd(password, sizeof password);
                     27:                passtokey(hostkey, password);
                     28:                fd = -1;
                     29:                if(islocal)
                     30:                        break;
                     31:                msg = checkkey(mp, username, hostkey);
                     32:                if(msg == 0)
                     33:                        break;
                     34:                fprint(2, "?%s\n", msg);
                     35:                outin(cpuflag, "user", username, sizeof(username));
                     36:        }
                     37:        if(fd > 0)
                     38:                close(fd);
                     39: 
                     40:        /* set host's key */
                     41:        if(writefile("#c/key", hostkey, DESKEYLEN) < 0)
                     42:                fatal(homsg);
                     43: 
                     44:        /* set host's owner (and uid of current process) */
                     45:        if(writefile("#c/hostowner", username, strlen(username)) < 0)
                     46:                fatal(homsg);
                     47:        close(fd);
                     48: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.