=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/chpass/Attic/pw_yp.c,v retrieving revision 1.15 retrieving revision 1.16 diff -c -r1.15 -r1.16 *** src/usr.bin/chpass/Attic/pw_yp.c 2002/06/04 00:09:08 1.15 --- src/usr.bin/chpass/Attic/pw_yp.c 2002/06/27 19:02:40 1.16 *************** *** 1,4 **** ! /* $OpenBSD: pw_yp.c,v 1.15 2002/06/04 00:09:08 deraadt Exp $ */ /* $NetBSD: pw_yp.c,v 1.5 1995/03/26 04:55:33 glass Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: pw_yp.c,v 1.16 2002/06/27 19:02:40 deraadt Exp $ */ /* $NetBSD: pw_yp.c,v 1.5 1995/03/26 04:55:33 glass Exp $ */ /* *************** *** 37,43 **** #if 0 static char sccsid[] = "@(#)pw_yp.c 1.0 2/2/93"; #else ! static char rcsid[] = "$OpenBSD: pw_yp.c,v 1.15 2002/06/04 00:09:08 deraadt Exp $"; #endif #endif /* not lint */ --- 37,43 ---- #if 0 static char sccsid[] = "@(#)pw_yp.c 1.0 2/2/93"; #else ! static char rcsid[] = "$OpenBSD: pw_yp.c,v 1.16 2002/06/27 19:02:40 deraadt Exp $"; #endif #endif /* not lint */ *************** *** 50,55 **** --- 50,56 ---- #include #include #include + #include #include #include #include *************** *** 63,81 **** static char *domain; int ! pw_yp(pw, uid) ! struct passwd *pw; ! uid_t uid; { ! char *master; ! char *p; ! char buf[10]; int r, rpcport, status, alen; struct yppasswd yppasswd; struct timeval tv; CLIENT *client; ! extern char *getpass(); ! /* * Get local domain */ --- 64,77 ---- static char *domain; int ! pw_yp(struct passwd *pw, uid_t uid) { ! char buf[10], *master, *p; int r, rpcport, status, alen; struct yppasswd yppasswd; struct timeval tv; CLIENT *client; ! /* * Get local domain */ *************** *** 126,132 **** (void)fprintf(stderr, "Cancelled.\n"); return(0); } ! for (alen = 0, p = pw->pw_gecos; *p; p++) if (*p == '&') alen = alen + strlen(pw->pw_name) - 1; --- 122,128 ---- (void)fprintf(stderr, "Cancelled.\n"); return(0); } ! for (alen = 0, p = pw->pw_gecos; *p; p++) if (*p == '&') alen = alen + strlen(pw->pw_name) - 1; *************** *** 142,148 **** /* tell rpc.yppasswdd */ yppasswd.newpw.pw_name = pw->pw_name; yppasswd.newpw.pw_passwd= pw->pw_passwd; ! yppasswd.newpw.pw_uid = pw->pw_uid; yppasswd.newpw.pw_gid = pw->pw_gid; yppasswd.newpw.pw_gecos = pw->pw_gecos; yppasswd.newpw.pw_dir = pw->pw_dir; --- 138,144 ---- /* tell rpc.yppasswdd */ yppasswd.newpw.pw_name = pw->pw_name; yppasswd.newpw.pw_passwd= pw->pw_passwd; ! yppasswd.newpw.pw_uid = pw->pw_uid; yppasswd.newpw.pw_gid = pw->pw_gid; yppasswd.newpw.pw_gecos = pw->pw_gecos; yppasswd.newpw.pw_dir = pw->pw_dir; *************** *** 176,183 **** } static char * ! pwskip(p) ! char *p; { while (*p && *p != ':' && *p != '\n') ++p; --- 172,178 ---- } static char * ! pwskip(char *p) { while (*p && *p != ':' && *p != '\n') ++p; *************** *** 187,195 **** } static struct passwd * ! interpret(pwent, line) ! struct passwd *pwent; ! char *line; { char *p = line; --- 182,188 ---- } static struct passwd * ! interpret(struct passwd *pwent, char *line) { char *p = line; *************** *** 202,208 **** 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); --- 195,201 ---- 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); *************** *** 229,241 **** static char *__yplin; struct passwd * ! ypgetpwnam(nam) ! char *nam; { static struct passwd pwent; - char *val; int reason, vallen; ! /* * Get local domain */ --- 222,233 ---- static char *__yplin; struct passwd * ! ypgetpwnam(char *nam) { static struct passwd pwent; int reason, vallen; ! char *val; ! /* * Get local domain */ *************** *** 259,286 **** free(__yplin); if (!(__yplin = (char *)malloc(vallen + 1))) err(1, NULL); ! strcpy(__yplin, val); /* ok */ free(val); return(interpret(&pwent, __yplin)); } struct passwd * ! ypgetpwuid(uid) ! uid_t uid; { static struct passwd pwent; - char *val; int reason, vallen; ! char namebuf[16]; ! if (!domain && (reason = yp_get_default_domain(&domain))) { fprintf(stderr, "%s: can't get local YP domain. Reason: %s\n", __progname, yperr_string(reason)); exit(1); } ! snprintf(namebuf, sizeof namebuf, "%u", uid); reason = yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf), &val, &vallen); switch(reason) { --- 251,276 ---- free(__yplin); if (!(__yplin = (char *)malloc(vallen + 1))) err(1, NULL); ! strlcpy(__yplin, val, vallen + 1); free(val); return(interpret(&pwent, __yplin)); } struct passwd * ! ypgetpwuid(uid_t uid) { static struct passwd pwent; int reason, vallen; ! char namebuf[16], *val; ! if (!domain && (reason = yp_get_default_domain(&domain))) { fprintf(stderr, "%s: can't get local YP domain. Reason: %s\n", __progname, yperr_string(reason)); exit(1); } ! snprintf(namebuf, sizeof namebuf, "%u", (u_int)uid); reason = yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf), &val, &vallen); switch(reason) { *************** *** 295,301 **** free(__yplin); if (!(__yplin = (char *)malloc(vallen + 1))) err(1, NULL); ! strcpy(__yplin, val); /* ok */ free(val); return(interpret(&pwent, __yplin)); --- 285,291 ---- free(__yplin); if (!(__yplin = (char *)malloc(vallen + 1))) err(1, NULL); ! strlcpy(__yplin, val, vallen + 1); free(val); return(interpret(&pwent, __yplin));