Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libutil Use the re-entrant getgr*_r functions. From John...
details: https://anonhg.NetBSD.org/src/rev/699a5dac049f
branches: trunk
changeset: 584351:699a5dac049f
user: christos <christos%NetBSD.org@localhost>
date: Wed Sep 14 02:12:34 2005 +0000
description:
Use the re-entrant getgr*_r functions. From John Nemeth.
diffstat:
lib/libutil/passwd.c | 13 ++++++++-----
lib/libutil/pty.c | 12 +++++++-----
2 files changed, 15 insertions(+), 10 deletions(-)
diffs (79 lines):
diff -r 7f4c46d473f3 -r 699a5dac049f lib/libutil/passwd.c
--- a/lib/libutil/passwd.c Wed Sep 14 00:38:39 2005 +0000
+++ b/lib/libutil/passwd.c Wed Sep 14 02:12:34 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: passwd.c,v 1.41 2005/08/19 10:10:08 elad Exp $ */
+/* $NetBSD: passwd.c,v 1.42 2005/09/14 02:12:34 christos Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: passwd.c,v 1.41 2005/08/19 10:10:08 elad Exp $");
+__RCSID("$NetBSD: passwd.c,v 1.42 2005/09/14 02:12:34 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -599,14 +599,17 @@
const char *option)
{
char grpkey[LINE_MAX];
- struct group *grp;
+ struct group grs, *grp;
+ char grbuf[1024];
pw_getconf(data, max, pwd->pw_name, option);
/* Try to find an entry for the group */
if (*data == '\0') {
- if ((grp = getgrgid(pwd->pw_gid)) != NULL) {
- snprintf(grpkey, sizeof(grpkey), ":%s", grp->gr_name);
+ (void)getgrgid_r(pwd->pw_gid, &grs, grbuf, sizeof(grbuf), &grp);
+ if (grp != NULL) {
+ (void)snprintf(grpkey, sizeof(grpkey), ":%s",
+ grp->gr_name);
pw_getconf(data, max, grpkey, option);
}
if (*data == '\0')
diff -r 7f4c46d473f3 -r 699a5dac049f lib/libutil/pty.c
--- a/lib/libutil/pty.c Wed Sep 14 00:38:39 2005 +0000
+++ b/lib/libutil/pty.c Wed Sep 14 02:12:34 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pty.c,v 1.28 2005/01/19 01:54:09 mycroft Exp $ */
+/* $NetBSD: pty.c,v 1.29 2005/09/14 02:12:34 christos Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pty.c 8.3 (Berkeley) 5/16/94";
#else
-__RCSID("$NetBSD: pty.c,v 1.28 2005/01/19 01:54:09 mycroft Exp $");
+__RCSID("$NetBSD: pty.c,v 1.29 2005/09/14 02:12:34 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -68,7 +68,8 @@
int master, slave;
gid_t ttygid;
mode_t mode;
- struct group *gr;
+ struct group grs, *grp;
+ char grbuf[1024];
_DIAGASSERT(amaster != NULL);
_DIAGASSERT(aslave != NULL);
@@ -88,8 +89,9 @@
(void)close(master);
}
- if ((gr = getgrnam("tty")) != NULL) {
- ttygid = gr->gr_gid;
+ (void)getgrnam_r("tty", &grs, grbuf, sizeof(grbuf), &grp);
+ if (grp != NULL) {
+ ttygid = grp->gr_gid;
mode = S_IRUSR|S_IWUSR|S_IWGRP;
} else {
ttygid = getgid();
Home |
Main Index |
Thread Index |
Old Index