=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/passwd/Attic/yp_passwd.c,v retrieving revision 1.20 retrieving revision 1.21 diff -c -r1.20 -r1.21 *** src/usr.bin/passwd/Attic/yp_passwd.c 2002/02/16 21:27:50 1.20 --- src/usr.bin/passwd/Attic/yp_passwd.c 2002/05/16 11:54:25 1.21 *************** *** 1,4 **** ! /* $OpenBSD: yp_passwd.c,v 1.20 2002/02/16 21:27:50 millert Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. --- 1,4 ---- ! /* $OpenBSD: yp_passwd.c,v 1.21 2002/05/16 11:54:25 fgsch Exp $ */ /* * Copyright (c) 1988 The Regents of the University of California. *************** *** 34,40 **** */ #ifndef lint /*static const char sccsid[] = "from: @(#)yp_passwd.c 1.0 2/2/93";*/ ! static const char rcsid[] = "$OpenBSD: yp_passwd.c,v 1.20 2002/02/16 21:27:50 millert Exp $"; #endif /* not lint */ #ifdef YP --- 34,40 ---- */ #ifndef lint /*static const char sccsid[] = "from: @(#)yp_passwd.c 1.0 2/2/93";*/ ! static const char rcsid[] = "$OpenBSD: yp_passwd.c,v 1.21 2002/05/16 11:54:25 fgsch Exp $"; #endif /* not lint */ #ifdef YP *************** *** 61,73 **** #define _PASSWORD_LEN PASS_MAX #endif ! extern int pwd_gensalt(char *, int, struct passwd *, login_cap_t *, char); ! extern int pwd_check(struct passwd *, login_cap_t *, char *); ! extern int pwd_gettries(struct passwd *, login_cap_t *); ! extern void kbintr(int); ! char *ypgetnewpasswd(struct passwd *, login_cap_t *, char **); ! struct passwd *ypgetpwnam(char *); char *domain; --- 61,73 ---- #define _PASSWORD_LEN PASS_MAX #endif ! extern int pwd_gensalt(char *, int, struct passwd *, login_cap_t *, char); ! extern int pwd_check(struct passwd *, login_cap_t *, char *); ! extern int pwd_gettries(struct passwd *, login_cap_t *); ! extern void kbintr(int); ! char *ypgetnewpasswd(struct passwd *, login_cap_t *, char **); ! struct passwd *ypgetpwnam(char *); char *domain; *************** *** 76,85 **** char *name; int err, eval; { ! if (err) ! warn("%s", name); ! warnx("YP passwd database unchanged."); exit(eval); } --- 76,89 ---- char *name; int err, eval; { ! if (err) { ! if (name) ! warn("%s", name); ! else ! warn(NULL); ! } ! warnx("YP passwd database: unchanged."); exit(eval); } *************** *** 100,107 **** * Get local domain */ if ((r = yp_get_default_domain(&domain)) != 0) { ! warnx("can't get local YP domain. Reason: %s", yperr_string(r)); ! return(1); } /* --- 104,112 ---- * Get local domain */ if ((r = yp_get_default_domain(&domain)) != 0) { ! warnx("can't get local YP domain. Reason: %s", ! yperr_string(r)); ! return (1); } /* *************** *** 111,117 **** if ((r = yp_master(domain, "passwd.byname", &master)) != 0) { warnx("can't find the master YP server. Reason: %s", yperr_string(r)); ! return(1); } /* --- 116,122 ---- if ((r = yp_master(domain, "passwd.byname", &master)) != 0) { warnx("can't find the master YP server. Reason: %s", yperr_string(r)); ! return (1); } /* *************** *** 121,127 **** YPPASSWDPROC_UPDATE, IPPROTO_UDP)) == 0) { warnx("master YP server not running yppasswd daemon."); warnx("Can't change password."); ! return(1); } /* --- 126,132 ---- YPPASSWDPROC_UPDATE, IPPROTO_UDP)) == 0) { warnx("master YP server not running yppasswd daemon."); warnx("Can't change password."); ! return (1); } /* *************** *** 129,151 **** */ if (rpcport >= IPPORT_RESERVED) { warnx("yppasswd daemon is on an invalid port."); ! return(1); } /* Get user's login identity */ if (!(pw = ypgetpwnam(username))) { warnx("unknown user %s.", username); ! return(1); } if ((lc = login_getclass(pw->pw_class)) == NULL) { warnx("unable to get login class for user %s.", username); ! return(1); } ! uid = getuid(); if (uid && uid != pw->pw_uid) { ! warnx("you may only change your own password: %s", strerror(EACCES)); ! return(1); } /* prompt for new password */ --- 134,157 ---- */ if (rpcport >= IPPORT_RESERVED) { warnx("yppasswd daemon is on an invalid port."); ! return (1); } /* Get user's login identity */ if (!(pw = ypgetpwnam(username))) { warnx("unknown user %s.", username); ! return (1); } if ((lc = login_getclass(pw->pw_class)) == NULL) { warnx("unable to get login class for user %s.", username); ! return (1); } ! uid = getuid(); if (uid && uid != pw->pw_uid) { ! warnx("you may only change your own password: %s", ! strerror(EACCES)); ! return (1); } /* prompt for new password */ *************** *** 158,170 **** yppasswd.newpw.pw_gecos = pw->pw_gecos; yppasswd.newpw.pw_dir = pw->pw_dir; yppasswd.newpw.pw_shell = pw->pw_shell; ! client = clnt_create(master, YPPASSWDPROG, YPPASSWDVERS, "udp"); if (client==NULL) { warnx("cannot contact yppasswdd on %s: Reason: %s", master, yperr_string(YPERR_YPBIND)); free(yppasswd.newpw.pw_passwd); ! return(YPERR_YPBIND); } client->cl_auth = authunix_create_default(); tv.tv_sec = 2; --- 164,176 ---- yppasswd.newpw.pw_gecos = pw->pw_gecos; yppasswd.newpw.pw_dir = pw->pw_dir; yppasswd.newpw.pw_shell = pw->pw_shell; ! client = clnt_create(master, YPPASSWDPROG, YPPASSWDVERS, "udp"); if (client==NULL) { warnx("cannot contact yppasswdd on %s: Reason: %s", master, yperr_string(YPERR_YPBIND)); free(yppasswd.newpw.pw_passwd); ! return (YPERR_YPBIND); } client->cl_auth = authunix_create_default(); tv.tv_sec = 2; *************** *** 176,187 **** else if (status) { printf("Couldn't change YP password.\n"); free(yppasswd.newpw.pw_passwd); ! return(1); } ! printf("The YP password has been changed on %s, the master YP passwd server.\n", ! master); free(yppasswd.newpw.pw_passwd); ! return(0); } char * --- 182,193 ---- else if (status) { printf("Couldn't change YP password.\n"); free(yppasswd.newpw.pw_passwd); ! return (1); } ! printf("The YP password has been changed on %s, " ! "the master YP passwd server.\n", master); free(yppasswd.newpw.pw_passwd); ! return (0); } char * *************** *** 198,208 **** saveint = signal(SIGINT, kbintr); savequit = signal(SIGQUIT, kbintr); ! printf("Changing YP password for %s.\n", pw->pw_name); if (old_pass) { *old_pass = NULL; ! if (pw->pw_passwd[0]) { p = getpass("Old password:"); if (strcmp(crypt(p, pw->pw_passwd), pw->pw_passwd)) { --- 204,214 ---- saveint = signal(SIGINT, kbintr); savequit = signal(SIGQUIT, kbintr); ! printf("Changing YP password for %s.\n", pw->pw_name); if (old_pass) { *old_pass = NULL; ! if (pw->pw_passwd[0]) { p = getpass("Old password:"); if (strcmp(crypt(p, pw->pw_passwd), pw->pw_passwd)) { *************** *** 225,234 **** pw_error(NULL, 0, 0); } if (strcmp(p, "s/key") == 0) { ! printf("That password collides with a system feature. Choose another.\n"); continue; } ! if ((tries++ < pwd_tries || pwd_tries == 0) && pwd_check(pw, lc, p) == 0) continue; strncpy(buf, p, sizeof buf-1); --- 231,241 ---- pw_error(NULL, 0, 0); } if (strcmp(p, "s/key") == 0) { ! printf("That password collides with a system feature. " ! "Choose another.\n"); continue; } ! if ((tries++ < pwd_tries || pwd_tries == 0) && pwd_check(pw, lc, p) == 0) continue; strncpy(buf, p, sizeof buf-1); *************** *** 237,246 **** break; (void)printf("Mismatch; try again, EOF to quit.\n"); } ! if( !pwd_gensalt( salt, _PASSWORD_LEN, pw, lc, 'y' )) { ! (void)printf("Couldn't generate salt.\n"); ! pw_error(NULL, 0, 0); ! } p = strdup(crypt(buf, salt)); if (p == NULL) pw_error(NULL, 1, 1); --- 244,253 ---- break; (void)printf("Mismatch; try again, EOF to quit.\n"); } ! if(!pwd_gensalt(salt, _PASSWORD_LEN, pw, lc, 'y')) { ! (void)printf("Couldn't generate salt.\n"); ! pw_error(NULL, 0, 0); ! } p = strdup(crypt(buf, salt)); if (p == NULL) pw_error(NULL, 1, 1); *************** *** 274,283 **** pwent->pw_change = 0; pwent->pw_expire = 0; pwent->pw_class = ""; ! /* line without colon separators is no good, so ignore it */ if(!strchr(p, ':')) ! return(NULL); pwent->pw_name = p; p = pwskip(p); --- 281,290 ---- pwent->pw_change = 0; pwent->pw_expire = 0; pwent->pw_class = ""; ! /* line without colon separators is no good, so ignore it */ if(!strchr(p, ':')) ! return (NULL); pwent->pw_name = p; p = pwskip(p); *************** *** 307,313 **** static struct passwd pwent; char *val; int reason, vallen; ! reason = yp_match(domain, "passwd.byname", nam, strlen(nam), &val, &vallen); switch(reason) { --- 314,320 ---- static struct passwd pwent; char *val; int reason, vallen; ! reason = yp_match(domain, "passwd.byname", nam, strlen(nam), &val, &vallen); switch(reason) { *************** *** 327,333 **** __yplin[vallen] = '\0'; free(val); ! return(interpret(&pwent, __yplin)); } #endif /* YP */ --- 334,340 ---- __yplin[vallen] = '\0'; free(val); ! return (interpret(&pwent, __yplin)); } #endif /* YP */