Use getpwnam_r. From john nemeth.

This commit is contained in:
christos 2005-04-09 22:43:51 +00:00
parent 38b7b2fcde
commit 382db3eda9
4 changed files with 21 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kerberos5.c,v 1.12 2003/08/07 16:44:55 agc Exp $ */
/* $NetBSD: kerberos5.c,v 1.13 2005/04/09 22:43:51 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -421,15 +421,16 @@ kerberos5_is(Authenticator * ap, unsigned char *data, int cnt)
break;
case KRB_FORWARD:{
struct passwd *pwd;
struct passwd pws, *pwd;
char pwbuf[1024];
char ccname[1024]; /* XXX */
krb5_data inbuf;
krb5_ccache ccache;
inbuf.data = (char *) data;
inbuf.length = cnt;
pwd = getpwnam(UserNameRequested);
if (pwd == NULL)
if (getpwnam_r(UserNameRequested, &pws, pwbuf,
sizeof(pwbuf), &pwd) != 0)
break;
snprintf(ccname, sizeof(ccname),

View File

@ -1,4 +1,4 @@
/* $NetBSD: krb4encpwd.c,v 1.6 2005/02/06 05:53:07 perry Exp $ */
/* $NetBSD: krb4encpwd.c,v 1.7 2005/04/09 22:43:51 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)krb4encpwd.c 8.3 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: krb4encpwd.c,v 1.6 2005/02/06 05:53:07 perry Exp $");
__RCSID("$NetBSD: krb4encpwd.c,v 1.7 2005/04/09 22:43:51 christos Exp $");
#endif
#endif /* not lint */
@ -418,10 +418,11 @@ char *name, *passwd;
{
char *crypt();
char *salt, *p;
struct passwd *pwd;
struct passwd pws, *pwd;
char pwbuf[1024];
int passwdok_status = 0;
if (pwd = getpwnam(name))
if (getpwnam_r(name, &pws, pwbuf, sizeof(pwbuf), &pwd) == 0)
salt = pwd->pw_passwd;
else salt = "xx";

View File

@ -1,4 +1,4 @@
/* $NetBSD: spx.c,v 1.5 2003/08/07 16:44:56 agc Exp $ */
/* $NetBSD: spx.c,v 1.6 2005/04/09 22:43:51 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -35,7 +35,7 @@
#if 0
static char sccsid[] = "@(#)spx.c 8.2 (Berkeley) 5/30/95";
#else
__RCSID("$NetBSD: spx.c,v 1.5 2003/08/07 16:44:56 agc Exp $");
__RCSID("$NetBSD: spx.c,v 1.6 2005/04/09 22:43:51 christos Exp $");
#endif
#endif /* not lint */
@ -488,7 +488,8 @@ spx_status(ap, name, l, level)
gss_OID fullname_type;
char acl_file[160], fullname[160];
int major_status, status = 0;
struct passwd *pwd;
struct passwd pws, *pwd;
char pwbuf[1024];
/*
* hard code fullname to
@ -496,9 +497,9 @@ spx_status(ap, name, l, level)
* and acl_file to "~kannan/.sphinx"
*/
pwd = getpwnam(UserNameRequested);
if (pwd == NULL) {
return(AUTH_USER); /* not authenticated */
if (getpwnam_r(UserNameRequested, &pws, pwbuf, sizeof(pwbuf), &pwd)
!= 0) {
return(AUTH_USER); /* not authenticated */
}
strlcpy(acl_file, pwd->pw_dir, sizeof(acl_file));

View File

@ -32,7 +32,7 @@
#ifdef notdef
__FBSDID("$FreeBSD: src/contrib/telnet/libtelnet/sra.c,v 1.16 2002/05/06 09:48:02 markm Exp $");
#else
__RCSID("$NetBSD: sra.c,v 1.1 2005/02/19 21:55:52 christos Exp $");
__RCSID("$NetBSD: sra.c,v 1.2 2005/04/09 22:43:51 christos Exp $");
#endif
#ifdef SRA
@ -419,9 +419,10 @@ sra_printsub(unsigned char *data, int cnt, unsigned char *buf, int buflen)
static int
isroot(const char *usr)
{
struct passwd *pwd;
struct passwd pws, *pwd;
char pwbuf[1024];
if ((pwd=getpwnam(usr))==NULL)
if (getpwnam_r(usr, &pws, pwbuf, sizeof(pwbuf), &pwd) != 0)
return 0;
return (!pwd->pw_uid);
}