account for aborting registration
authorKevin Fall <kfall@ucbvax.Berkeley.EDU>
Thu, 18 May 1989 13:42:28 +0000 (05:42 -0800)
committerKevin Fall <kfall@ucbvax.Berkeley.EDU>
Thu, 18 May 1989 13:42:28 +0000 (05:42 -0800)
SCCS-vsn: local/kerberosIV/register/register.c 1.5
SCCS-vsn: old/athena/register/register.c 1.5

usr/src/local/kerberosIV/register/register.c
usr/src/old/athena/register/register.c

index 65e567a..cc3c8ae 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)register.c 1.5 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -40,29 +61,29 @@ char        **argv;
 
        signal(SIGPIPE, die);
 
 
        signal(SIGPIPE, die);
 
-       if(setrlimit(RLIMIT_CORE, &rl) < 0) {
+       if (setrlimit(RLIMIT_CORE, &rl) < 0) {
                perror("rlimit");
                exit(1);
        }
 
                perror("rlimit");
                exit(1);
        }
 
-       if((se = getservbyname(SERVICE, PROTO)) == NULL) {
+       if ((se = getservbyname(SERVICE, PROTO)) == NULL) {
                fprintf(stderr, "couldn't find entry for service %s\n",
                        SERVICE);
                exit(1);
        }
                fprintf(stderr, "couldn't find entry for service %s\n",
                        SERVICE);
                exit(1);
        }
-       if((rval = krb_get_lrealm(realm,1)) != KSUCCESS) {
+       if ((rval = krb_get_lrealm(realm,1)) != KSUCCESS) {
                fprintf(stderr, "couldn't get local Kerberos realm: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
                fprintf(stderr, "couldn't get local Kerberos realm: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
-       if((rval = krb_get_krbhst(krbhst, realm, 1)) != KSUCCESS) {
+       if ((rval = krb_get_krbhst(krbhst, realm, 1)) != KSUCCESS) {
                fprintf(stderr, "couldn't get Kerberos host: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
                fprintf(stderr, "couldn't get Kerberos host: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
-       if((host = gethostbyname(krbhst)) == NULL) {
+       if ((host = gethostbyname(krbhst)) == NULL) {
                fprintf(stderr, "couldn't get host entry for host %s\n",
                        krbhst);
                exit(1);
                fprintf(stderr, "couldn't get host entry for host %s\n",
                        krbhst);
                exit(1);
@@ -72,19 +93,19 @@ char        **argv;
        bcopy(host->h_addr, (char *) &sin.sin_addr, host->h_length);
        sin.sin_port = se->s_port;
 
        bcopy(host->h_addr, (char *) &sin.sin_addr, host->h_length);
        sin.sin_port = se->s_port;
 
-       if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
+       if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
                perror("socket");
                exit(1);
        }
 
                perror("socket");
                exit(1);
        }
 
-       if(connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
+       if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
                perror("connect");
                close(sock);
                exit(1);
        }
 
        llen = sizeof(local);
                perror("connect");
                close(sock);
                exit(1);
        }
 
        llen = sizeof(local);
-       if(getsockname(sock, (struct sockaddr *) &local, &llen) < 0) {
+       if (getsockname(sock, (struct sockaddr *) &local, &llen) < 0) {
                perror("getsockname");
                close(sock);
                exit(1);
                perror("getsockname");
                close(sock);
                exit(1);
@@ -93,7 +114,13 @@ char        **argv;
        setup_key(local);
 
        type_info();
        setup_key(local);
 
        type_info();
-       get_user_info();
+
+       if (!get_user_info()) {
+               code = ABORT;
+               (void)des_write(sock, &code, 1);
+               cleanup();
+               exit(1);
+       }
 
        code = APPEND_DB;
        if(des_write(sock, &code, 1) != 1) {
 
        code = APPEND_DB;
        if(des_write(sock, &code, 1) != 1) {
@@ -132,7 +159,7 @@ char        **argv;
                        cleanup();
                        exit(1);
                }
                        cleanup();
                        exit(1);
                }
-               if (strncmp(msgbuf, "GOTKEY", 6) != 0) {
+               if (strncmp(msgbuf, GOTKEY_MSG, 6) != 0) {
                        fprintf(stderr, "%s: %s", krbhst, msgbuf);
                        cleanup();
                        exit(1);
                        fprintf(stderr, "%s: %s", krbhst, msgbuf);
                        cleanup();
                        exit(1);
@@ -161,6 +188,8 @@ cleanup()
 
 extern char    *crypt();
 extern char    *getpass();
 
 extern char    *crypt();
 extern char    *getpass();
+
+int
 get_user_info()
 {
        int     uid = getuid();
 get_user_info()
 {
        int     uid = getuid();
@@ -170,7 +199,7 @@ get_user_info()
 
        if((pw = getpwuid(uid)) == NULL) {
                fprintf(stderr, "Who are you?\n");
 
        if((pw = getpwuid(uid)) == NULL) {
                fprintf(stderr, "Who are you?\n");
-               exit(1);
+               return(0);
        }
        seteuid(uid);
        strcpy(pname, pw->pw_name);     /* principal name */
        }
        seteuid(uid);
        strcpy(pname, pw->pw_name);     /* principal name */
@@ -186,7 +215,7 @@ get_user_info()
                }
        }
        if(!valid)
                }
        }
        if(!valid)
-               exit(1);
+               return(0);
        pas = getpass("Kerberos password (may be the same):");
        while(*pas == NULL) {
                printf("<NULL> password not allowed\n");
        pas = getpass("Kerberos password (may be the same):");
        while(*pas == NULL) {
                printf("<NULL> password not allowed\n");
@@ -196,11 +225,11 @@ get_user_info()
        pas = getpass("Retype Kerberos password:");
        if(strcmp(password, pas)) {
                fprintf(stderr, "Password mismatch -- aborted\n");
        pas = getpass("Retype Kerberos password:");
        if(strcmp(password, pas)) {
                fprintf(stderr, "Password mismatch -- aborted\n");
-               cleanup();
-               exit(1);
+               return(0);
        }
 
        iname[0] = NULL;        /* null instance name */
        }
 
        iname[0] = NULL;        /* null instance name */
+       return(1);
 }
 
 setup_key(local)
 }
 
 setup_key(local)
index 65e567a..cc3c8ae 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)register.c 1.5 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/resource.h>
@@ -40,29 +61,29 @@ char        **argv;
 
        signal(SIGPIPE, die);
 
 
        signal(SIGPIPE, die);
 
-       if(setrlimit(RLIMIT_CORE, &rl) < 0) {
+       if (setrlimit(RLIMIT_CORE, &rl) < 0) {
                perror("rlimit");
                exit(1);
        }
 
                perror("rlimit");
                exit(1);
        }
 
-       if((se = getservbyname(SERVICE, PROTO)) == NULL) {
+       if ((se = getservbyname(SERVICE, PROTO)) == NULL) {
                fprintf(stderr, "couldn't find entry for service %s\n",
                        SERVICE);
                exit(1);
        }
                fprintf(stderr, "couldn't find entry for service %s\n",
                        SERVICE);
                exit(1);
        }
-       if((rval = krb_get_lrealm(realm,1)) != KSUCCESS) {
+       if ((rval = krb_get_lrealm(realm,1)) != KSUCCESS) {
                fprintf(stderr, "couldn't get local Kerberos realm: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
                fprintf(stderr, "couldn't get local Kerberos realm: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
-       if((rval = krb_get_krbhst(krbhst, realm, 1)) != KSUCCESS) {
+       if ((rval = krb_get_krbhst(krbhst, realm, 1)) != KSUCCESS) {
                fprintf(stderr, "couldn't get Kerberos host: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
                fprintf(stderr, "couldn't get Kerberos host: %s\n",
                        krb_err_txt[rval]);
                exit(1);
        }
 
-       if((host = gethostbyname(krbhst)) == NULL) {
+       if ((host = gethostbyname(krbhst)) == NULL) {
                fprintf(stderr, "couldn't get host entry for host %s\n",
                        krbhst);
                exit(1);
                fprintf(stderr, "couldn't get host entry for host %s\n",
                        krbhst);
                exit(1);
@@ -72,19 +93,19 @@ char        **argv;
        bcopy(host->h_addr, (char *) &sin.sin_addr, host->h_length);
        sin.sin_port = se->s_port;
 
        bcopy(host->h_addr, (char *) &sin.sin_addr, host->h_length);
        sin.sin_port = se->s_port;
 
-       if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
+       if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
                perror("socket");
                exit(1);
        }
 
                perror("socket");
                exit(1);
        }
 
-       if(connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
+       if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
                perror("connect");
                close(sock);
                exit(1);
        }
 
        llen = sizeof(local);
                perror("connect");
                close(sock);
                exit(1);
        }
 
        llen = sizeof(local);
-       if(getsockname(sock, (struct sockaddr *) &local, &llen) < 0) {
+       if (getsockname(sock, (struct sockaddr *) &local, &llen) < 0) {
                perror("getsockname");
                close(sock);
                exit(1);
                perror("getsockname");
                close(sock);
                exit(1);
@@ -93,7 +114,13 @@ char        **argv;
        setup_key(local);
 
        type_info();
        setup_key(local);
 
        type_info();
-       get_user_info();
+
+       if (!get_user_info()) {
+               code = ABORT;
+               (void)des_write(sock, &code, 1);
+               cleanup();
+               exit(1);
+       }
 
        code = APPEND_DB;
        if(des_write(sock, &code, 1) != 1) {
 
        code = APPEND_DB;
        if(des_write(sock, &code, 1) != 1) {
@@ -132,7 +159,7 @@ char        **argv;
                        cleanup();
                        exit(1);
                }
                        cleanup();
                        exit(1);
                }
-               if (strncmp(msgbuf, "GOTKEY", 6) != 0) {
+               if (strncmp(msgbuf, GOTKEY_MSG, 6) != 0) {
                        fprintf(stderr, "%s: %s", krbhst, msgbuf);
                        cleanup();
                        exit(1);
                        fprintf(stderr, "%s: %s", krbhst, msgbuf);
                        cleanup();
                        exit(1);
@@ -161,6 +188,8 @@ cleanup()
 
 extern char    *crypt();
 extern char    *getpass();
 
 extern char    *crypt();
 extern char    *getpass();
+
+int
 get_user_info()
 {
        int     uid = getuid();
 get_user_info()
 {
        int     uid = getuid();
@@ -170,7 +199,7 @@ get_user_info()
 
        if((pw = getpwuid(uid)) == NULL) {
                fprintf(stderr, "Who are you?\n");
 
        if((pw = getpwuid(uid)) == NULL) {
                fprintf(stderr, "Who are you?\n");
-               exit(1);
+               return(0);
        }
        seteuid(uid);
        strcpy(pname, pw->pw_name);     /* principal name */
        }
        seteuid(uid);
        strcpy(pname, pw->pw_name);     /* principal name */
@@ -186,7 +215,7 @@ get_user_info()
                }
        }
        if(!valid)
                }
        }
        if(!valid)
-               exit(1);
+               return(0);
        pas = getpass("Kerberos password (may be the same):");
        while(*pas == NULL) {
                printf("<NULL> password not allowed\n");
        pas = getpass("Kerberos password (may be the same):");
        while(*pas == NULL) {
                printf("<NULL> password not allowed\n");
@@ -196,11 +225,11 @@ get_user_info()
        pas = getpass("Retype Kerberos password:");
        if(strcmp(password, pas)) {
                fprintf(stderr, "Password mismatch -- aborted\n");
        pas = getpass("Retype Kerberos password:");
        if(strcmp(password, pas)) {
                fprintf(stderr, "Password mismatch -- aborted\n");
-               cleanup();
-               exit(1);
+               return(0);
        }
 
        iname[0] = NULL;        /* null instance name */
        }
 
        iname[0] = NULL;        /* null instance name */
+       return(1);
 }
 
 setup_key(local)
 }
 
 setup_key(local)