]> andersk Git - moira.git/commitdiff
Userreg main program.
authorwesommer <wesommer>
Thu, 3 Sep 1987 03:05:57 +0000 (03:05 +0000)
committerwesommer <wesommer>
Thu, 3 Sep 1987 03:05:57 +0000 (03:05 +0000)
clients/userreg/userreg.c

index 1209a62f09fc00f1b472910bf08246cb480f0771..3ccaab7053d2d59a06e42fb7b64fd19435e18871 100644 (file)
@@ -50,6 +50,7 @@ main(argc, argv)
        register int    reencrypt;
        char            line[100];
        int status;
+       char tmpfirst[100], tmplast[100], tmpmid[100];
        
        status = ureg_init();
        if (status) {
@@ -64,6 +65,7 @@ main(argc, argv)
        signal(SIGHUP, fix_display);
 
        do {
+               
                setjmp(redo);
                reset();
                ntimes = 0;
@@ -73,8 +75,13 @@ main(argc, argv)
                gfirst();
                gmi();
                glast();
+               strcpy(tmpfirst, user.u_first);
+               strcpy(tmplast, user.u_last);
+               FixName(tmplast, tmpfirst, user.u_last, user.u_first, tmpmid);
+               redisp();
+               
                gmitid();
-
+               
                while (dolook()) {
                        ntimes++;
                        if (ntimes > 3) {
@@ -96,6 +103,10 @@ main(argc, argv)
                                display_text_line(line);
                                if (askyn("Do you want to change it? ") == YES) {
                                        gfirst();
+                                       strcpy(tmpfirst, user.u_first);
+                                       strcpy(tmplast, user.u_last);
+                                       FixName(tmplast, tmpfirst, user.u_last, user.u_first, tmpmid);
+                                       redisp();
                                        reencrypt = 1;
                                }
                                display_text_line(0);
@@ -110,6 +121,10 @@ main(argc, argv)
                                display_text_line(line);
                                if (askyn("Do you want to change it? ") == YES) {
                                        glast();
+                                       strcpy(tmpfirst, user.u_first);
+                                       strcpy(tmplast, user.u_last);
+                                       FixName(tmplast, tmpfirst, user.u_last, user.u_first, tmpmid);
+                                       redisp();
                                        reencrypt = 1;
                                }
                                display_text_line(0);
@@ -148,6 +163,9 @@ main(argc, argv)
                        user.u_login);
                display_text_line(line);
                display_text_line("you typed in earlier.");
+               display_text_line("");
+               display_text_line("Your account should be created within about 12 hours\n");
+               
                display_text_line("");
                display_text_line("You are now finished. Thank you!");
                sleep(5);
@@ -180,8 +198,10 @@ dolook()
        display_text_line(
         "Looking you up in the database.... This may take a few minutes.");
 
+       timer_off();
        result = verify_user(user.u_first, user.u_last,
                             typed_mit_id, user.u_mit_id, db_user.u_login);
+       timer_on();
        switch(result) {
        case 0:
                display_text_line("You have been located in the user registration database.");
@@ -221,7 +241,9 @@ dolook()
                return (0);
        case UREG_USER_NOT_FOUND:
                return (1);
+
        case ECONNREFUSED:
+       case ETIMEDOUT:
                display_text(NETWORK_DOWN);
                return (0);
                
@@ -242,11 +264,19 @@ negotiate_login()
        char            old_login[LOGIN_SIZE];
        char            old_password[PASSWORD_SIZE];
        int             i;
+       char *cp;
        
        display_text(USERNAME_BLURB);
-       user.u_login[0] = user.u_first[0];
-       user.u_login[1] = user.u_mid_init[0];
-       strncpy(user.u_login+2, user.u_last, 6);
+       cp = user.u_login;
+       if (isalpha(user.u_first[0]))
+               *cp++ = user.u_first[0];
+       if (isalpha(user.u_mid_init[0]))
+               *cp++ = user.u_mid_init[0];
+       
+       for (i = 0; user.u_last[i] && cp - user.u_login < 8; i++) {
+               if (isalpha(user.u_last[i])) *cp++ = user.u_last[i];
+       }
+
        for (i=0; user.u_login[i]; i++)
                if (isupper(user.u_login[i]))
                        user.u_login[i]=tolower(user.u_login[i]);
@@ -265,12 +295,14 @@ negotiate_login()
 
                display_text_line(0);
                display_text_line("Looking up that username in the database...  This may take a few minutes.");
+               timer_off();
                /*
                 * Rather than bother SMS with a bunch of different
                 * usernames, all in use, we first try and see if this
                 * guy is known to Kerberos.
                 */
                result = get_in_tkt(user.u_login, "", "ATHENA.MIT.EDU", "krbtgt", "ATHENA.MIT.EDU", "");
+               timer_on();
                if (result != KDC_PR_UNKNOWN) {
                in_use:
                        strcpy(user.u_login, old_login);
@@ -278,12 +310,15 @@ negotiate_login()
                        display_text_line("I'm sorry, but that username is already taken.  Please try again with a different username");
                        continue;
                }
+
                /*
                 * If he isn't, let's try through SMS.
                 */
+               timer_off();
                result = grab_login(user.u_first, user.u_last,
                                    typed_mit_id, user.u_mit_id,
                                    user.u_login);
+               timer_on();
                if (result != 0) {
                        if (result == UREG_LOGIN_USED) goto in_use;
                        display_text(NETWORK_DOWN);
@@ -346,18 +381,6 @@ gpass()
        char            new_password[PASSWORD_SIZE];
        char            new_password_again[PASSWORD_SIZE];
 
-       if (already_registered) {       /* we have to ask for his old
-                                        * password */
-               signal(SIGALRM, restart);
-               input_no_echo("Enter old Password:", old_password,
-                             PASSWORD_SIZE, OLD_PASSWORD_TIMEOUT);
-               if (strcmp(user.u_password, crypt(old_password,
-                                                 user.u_password))) {
-                       display_text_line("Sorry, that does not match your old password.");
-                       display_text_line("In order to get a new one, you have to know the old one.");
-                       return (1);
-               }
-       }
 do_input:
        signal(SIGALRM, restart);
        input_no_echo("Enter password:", new_password,
@@ -374,11 +397,6 @@ do_input:
                display_text_line("Please try again.");
                goto do_input;
        }
-       /*
-        * give him a new password. It looks funny because we are trying to
-        * get a semi_random key without a lot of hair by using the login
-        * name as a seed 
-        */
 
        strcpy(user.u_password, new_password);
        redisp();
@@ -412,7 +430,8 @@ input_login:
        if (i != 0) {
                user.u_login[i] = '\0';
        }
-       if (strlen(user.u_login) < 2) {
+       if (strlen(user.u_login) < 3) {
+               display_text_line("Your username must be 3 or more characters long.\n");
                goto input_login;
        }
 #ifdef notdef
@@ -515,8 +534,10 @@ do_replace()
         * replaces a user in the database. If there is an error, it informs
         * the user and calls qexit(); It returns only if is is successful 
         */
+       timer_off();
        status = set_password(user.u_first, user.u_last, typed_mit_id,
-                    user.u_mit_id, user.u_password);
+                             user.u_mit_id, user.u_password);
+       timer_on();
        if (status) {
                display_text (NETWORK_DOWN);
                return (-1);
This page took 0.052852 seconds and 5 git commands to generate.