Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/distrib/utils/libhack pty.o in libutil.a wants to call getgr...
details: https://anonhg.NetBSD.org/src/rev/d4b0a6392d6d
branches: trunk
changeset: 584370:d4b0a6392d6d
user: he <he%NetBSD.org@localhost>
date: Wed Sep 14 15:31:18 2005 +0000
description:
pty.o in libutil.a wants to call getgrent_r(), so provide a cheesy
non-reentrant version here in order to avoid linker conflicts when
the rest of this file is attempted linked together with libc's
getgrent.o.
Reviewed by christos.
diffstat:
distrib/utils/libhack/getgrent.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diffs (65 lines):
diff -r bac2b69ffe34 -r d4b0a6392d6d distrib/utils/libhack/getgrent.c
--- a/distrib/utils/libhack/getgrent.c Wed Sep 14 15:13:19 2005 +0000
+++ b/distrib/utils/libhack/getgrent.c Wed Sep 14 15:31:18 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: getgrent.c,v 1.10 2005/04/01 13:11:12 he Exp $ */
+/* $NetBSD: getgrent.c,v 1.11 2005/09/14 15:31:18 he Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@@ -67,6 +67,7 @@
#define getgrent _getgrent
#define getgrgid _getgrgid
#define getgrnam _getgrnam
+#define getgrnam_r _getgrnam_r
#define setgrent _setgrent
#define setgroupent _setgroupent
#define getgroupmembership _getgroupmembership
@@ -75,6 +76,7 @@
__weak_alias(getgrent,_getgrent)
__weak_alias(getgrgid,_getgrgid)
__weak_alias(getgrnam,_getgrnam)
+__weak_alias(getgrnam_r,_getgrnam_r)
__weak_alias(setgrent,_setgrent)
__weak_alias(setgroupent,_setgroupent)
__weak_alias(getgroupmembership,_getgroupmembership)
@@ -88,6 +90,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
static FILE *_gr_fp;
static struct group _gr_group;
@@ -113,6 +116,31 @@
return &_gr_group;
}
+int
+getgrnam_r(const char *name, struct group *grp, char *buffer,
+ size_t buflen, struct group **result)
+{
+ struct group *gp, *bgp;
+
+ /*
+ * We blatantly cheat (don't provide reentrancy)
+ * and hope to get away with it
+ */
+
+ *result = NULL;
+ bgp = (struct group*)buffer;
+ if (buflen < sizeof(struct group))
+ return ENOMEM;
+
+ gp = getgrnam(name);
+ if (gp) {
+ *bgp = *gp;
+ *result = bgp;
+ }
+
+ return (gp) ? ENOENT : 0;
+}
+
struct group *
getgrnam(const char *name)
{
Home |
Main Index |
Thread Index |
Old Index