=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/passwd/Attic/krb_passwd.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- src/usr.bin/passwd/Attic/krb_passwd.c 1996/06/26 05:37:46 1.4 +++ src/usr.bin/passwd/Attic/krb_passwd.c 1997/03/27 00:30:52 1.5 @@ -1,4 +1,4 @@ -/* $OpenBSD: krb_passwd.c,v 1.4 1996/06/26 05:37:46 deraadt Exp $ */ +/* $OpenBSD: krb_passwd.c,v 1.5 1997/03/27 00:30:52 weingart Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -35,7 +35,7 @@ #ifndef lint /*static char sccsid[] = "from: @(#)krb_passwd.c 5.4 (Berkeley) 3/1/91";*/ -static char rcsid[] = "$OpenBSD: krb_passwd.c,v 1.4 1996/06/26 05:37:46 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: krb_passwd.c,v 1.5 1997/03/27 00:30:52 weingart Exp $"; #endif /* not lint */ #ifdef KERBEROS @@ -50,11 +50,13 @@ #include #include #include +#include #include #include #include "kpasswd_proto.h" #include #include +#include #define PROTO "tcp" @@ -86,36 +88,27 @@ (void)signal(SIGTSTP, SIG_IGN); if (setrlimit(RLIMIT_CORE, &rl) < 0) { - (void)fprintf(stderr, - "passwd: setrlimit: %s\n", strerror(errno)); + warn("setrlimit"); return(1); } if ((se = getservbyname(SERVICE, PROTO)) == NULL) { - (void)fprintf(stderr, - "passwd: couldn't find entry for service %s/%s\n", - SERVICE, PROTO); + warnx("couldn't find entry for service %s/%s", SERVICE, PROTO); return(1); } if ((rval = krb_get_lrealm(realm,1)) != KSUCCESS) { - (void)fprintf(stderr, - "passwd: couldn't get local Kerberos realm: %s\n", - krb_err_txt[rval]); + warnx("couldn't get local Kerberos realm: %s", krb_err_txt[rval]); return(1); } if ((rval = krb_get_krbhst(krbhst, realm, 1)) != KSUCCESS) { - (void)fprintf(stderr, - "passwd: couldn't get Kerberos host: %s\n", - krb_err_txt[rval]); + warnx("couldn't get Kerberos host: %s", krb_err_txt[rval]); return(1); } if ((host = gethostbyname(krbhst)) == NULL) { - (void)fprintf(stderr, - "passwd: couldn't get host entry for krb host %s\n", - krbhst); + warnx("couldn't get host entry for krb host %s", krbhst); return(1); } @@ -124,12 +117,12 @@ sin.sin_port = se->s_port; if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { - (void)fprintf(stderr, "passwd: socket: %s\n", strerror(errno)); + warn("socket"); return(1); } if (connect(sock, (struct sockaddr *) &sin, sizeof(sin)) < 0) { - (void)fprintf(stderr, "passwd: connect: %s\n", strerror(errno)); + warn("connect"); (void)close(sock); return(1); } @@ -151,8 +144,7 @@ ); if (rval != KSUCCESS) { - (void)fprintf(stderr, "passwd: Kerberos sendauth error: %s\n", - krb_err_txt[rval]); + warnx("Kerberos sendauth error: %s", krb_err_txt[rval]); return(1); } @@ -163,8 +155,7 @@ if (des_read_pw_string(pass, sizeof(pass)-1, "Old Kerberos password:", 0)) { - (void)fprintf(stderr, - "passwd: error reading old Kerberos password\n"); + warnx("error reading old Kerberos password"); return(1); } @@ -182,11 +173,11 @@ if ((rval < 1) || !FD_ISSET(sock, &readfds)) { if(rval == 0) { - (void)fprintf(stderr, "passwd: timed out (aborted)\n"); + warnx("timed out (aborted)"); cleanup(); return(1); } - (void)fprintf(stderr, "passwd: select failed (aborted)\n"); + warnx("select failed (aborted)"); cleanup(); return(1); } @@ -195,8 +186,7 @@ if (des_read(sock, &proto_data, sizeof(proto_data)) != sizeof(proto_data)) { - (void)fprintf(stderr, - "passwd: couldn't read verification string (aborted)\n"); + warnx("couldn't read verification string (aborted)"); cleanup(); return(1); } @@ -209,7 +199,7 @@ /* don't complain loud if user just hit return */ if (pass == NULL || (!*pass)) return(0); - (void)fprintf(stderr, "Sorry\n"); + warnx("Sorry"); return(1); } @@ -219,23 +209,20 @@ if (des_read_pw_string(pass, sizeof(pass)-1, "New Kerberos password:", 0)) { - (void)fprintf(stderr, - "passwd: error reading new Kerberos password (aborted)\n"); + warnx("error reading new Kerberos password (aborted)"); cleanup(); return(1); } if (des_read_pw_string(password, sizeof(password)-1, "Retype new Kerberos password:", 0)) { - (void)fprintf(stderr, - "passwd: error reading new Kerberos password (aborted)\n"); + warnx("error reading new Kerberos password (aborted)"); cleanup(); return(1); } if (strcmp(password, pass) != 0) { - (void)fprintf(stderr, - "passwd: password mismatch (aborted)\n"); + warnx("password mismatch (aborted)"); cleanup(); return(1); } @@ -254,12 +241,11 @@ select(sock + 1, &readfds, (fd_set *) 0, (fd_set *) 0, &timeout); if ((rval < 1) || !FD_ISSET(sock, &readfds)) { if(rval == 0) { - (void)fprintf(stderr, - "passwd: timed out reading ACK (aborted)\n"); + warnx("timed out reading ACK (aborted)"); cleanup(); exit(1); } - (void)fprintf(stderr, "passwd: select failed (aborted)\n"); + warnx("select failed (aborted)"); cleanup(); exit(1); } @@ -277,8 +263,7 @@ (void)strncpy(ud.secure_msg, str, _PASSWORD_LEN); (void)strncpy(ud.pw, pwd, sizeof(ud.pw)); if (des_write(dest, &ud, sizeof(ud)) != sizeof(ud)) { - (void)fprintf(stderr, - "passwd: couldn't write pw update (abort)\n"); + warnx("couldn't write pw update (abort)"); bzero((char *)&ud, sizeof(ud)); cleanup(); exit(1); @@ -293,8 +278,7 @@ cc = des_read(remote, buf, sizeof(buf)); if (cc <= 0) { - (void)fprintf(stderr, - "passwd: error reading acknowledgement (aborted)\n"); + warnx("error reading acknowledgement (aborted)"); cleanup(); exit(1); }