From 395e5d4d7aa09f944bfe3aa948a39a0f925b2765 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 14 Nov 2014 15:33:57 +0100 Subject: libcsupport: Use POSIX key for getgrent() --- cpukit/libcsupport/src/getgrnam.c | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 cpukit/libcsupport/src/getgrnam.c (limited to 'cpukit/libcsupport/src/getgrnam.c') diff --git a/cpukit/libcsupport/src/getgrnam.c b/cpukit/libcsupport/src/getgrnam.c new file mode 100644 index 0000000000..505a334f75 --- /dev/null +++ b/cpukit/libcsupport/src/getgrnam.c @@ -0,0 +1,53 @@ +/** + * @file + * + * @brief User Database Access Routines + * @ingroup libcsupport + */ + +/* + * Copyright (c) 1999-2009 Ralf Corsepius + * Copyright (c) 1999-2013 Joel Sherrill + * Copyright (c) 2000-2001 Fernando Ruiz Casas + * Copyright (c) 2002 Eric Norum + * Copyright (c) 2003 Till Straumann + * Copyright (c) 2012 Alex Ivanov + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pwdgrp.h" + +/* + * Static, thread-unsafe, buffers + */ +static char grbuf[200]; +static struct group grent; + +struct group *getgrnam( + const char *name +) +{ + struct group *p; + + if(getgrnam_r(name, &grent, grbuf, sizeof grbuf, &p)) + return NULL; + return p; +} + +struct group *getgrgid( + gid_t gid +) +{ + struct group *p; + + if(getgrgid_r(gid, &grent, grbuf, sizeof grbuf, &p)) + return NULL; + return p; +} -- cgit v1.2.3