int dologin(const char *host) { char tmp[80]; char *luser, *pass, *zacct; int n, aflag = 0; luser = pass = zacct = 0; if (xruserpass(host, &luser, &pass, &zacct) < 0) { code = -1; return(0); } while (luser == NULL) { char *myname = getlogin(); if (myname == NULL) { struct passwd *pp = getpwuid(getuid()); if (pp != NULL) myname = pp->pw_name; } if (myname) printf("Name (%s:%s): ", host, myname); else printf("Name (%s): ", host); #ifdef EMBED fflush(stdout); #endif if (fgets(tmp, sizeof(tmp) - 1, stdin)==NULL) { fprintf(stderr, "\nLogin failed.\n"); return 0; } tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') luser = myname; else luser = tmp; } n = command("USER %s", luser); if (n == CONTINUE) { if (pass == NULL) { /* fflush(stdout); */ pass = getpass("Password:"******"PASS %s", pass); } if (n == CONTINUE) { aflag++; /* fflush(stdout); */ zacct = getpass("Account:"); n = command("ACCT %s", zacct); } if (n != COMPLETE) { fprintf(stderr, "Login failed.\n"); return (0); } if (!aflag && zacct != NULL) (void) command("ACCT %s", zacct); if (proxy) return(1); #if 0 for (n = 0; n < macnum; ++n) { if (!strcmp("init", macros[n].mac_name)) { int margc; char **margv; strcpy(line, "$init"); margv = makeargv(&margc, NULL); domacro(margc, margv); break; } } #endif return (1); }
int login(const char *host) { char tmp[80]; char *puser, *ppass, *pacct; const char *user, *pass, *acct; int n, aflag = 0; user = pass = acct = 0; n = ruserpass(host, &puser, &ppass, &pacct); if (n < 0) { code = -1; return(0); } if (0 != n) { user = puser; pass = ppass; acct = pacct; } while (user == NULL) { const char *myname = "none"; // This needs to become the usename env if (myname) printf("Name (%s:%s): ", host, myname); else printf("Name (%s): ", host); (void) fflush(stdout); (void) fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') user = myname; else user = tmp; } n = command("USER %s", user); if (n == CONTINUE) { if (pass == NULL) pass = getpass("Password:"******"PASS %s", pass); fflush(stdin); } if (n == CONTINUE) { aflag++; acct = getpass("Account:"); n = command("ACCT %s", acct); } if (n != COMPLETE) { fprintf(stderr, "Login failed.\n"); return (0); } if (!aflag && acct != NULL) (void) command("ACCT %s", acct); if (proxy) return(1); for (n = 0; n < macnum; ++n) { if (!strcmp("init", macros[n].mac_name)) { (void) strcpy(line, "$init"); makeargv(); domacro(margc, margv); break; } } return (1); }