Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
-#include <nss.h>
#include <grp.h>
-#include <ctype.h>
-#include <bits/libc-lock.h>
+#include <nss.h>
+#include <nsswitch.h>
+#include <stdio_lock.h>
#include <string.h>
#include <rpc/types.h>
-#include <nsswitch.h>
+#include <bits/libc-lock.h>
static service_user *ni;
static enum nss_status (*nss_setgrent) (int stayopen);
if (ent->stream == NULL)
{
- ent->stream = fopen ("/etc/group", "r");
+ ent->stream = fopen ("/etc/group", "rm");
if (ent->stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
/* We have to make sure the file is `closed on exec'. */
int result, flags;
- result = flags = fcntl (fileno (ent->stream), F_GETFD, 0);
+ result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
if (result >= 0)
{
flags |= FD_CLOEXEC;
- result = fcntl (fileno (ent->stream), F_SETFD, flags);
+ result = fcntl (fileno_unlocked (ent->stream), F_SETFD, flags);
}
if (result < 0)
{
ent->stream = NULL;
status = NSS_STATUS_UNAVAIL;
}
+ else
+ /* We take care of locking ourself. */
+ __fsetlocking (ent->stream, FSETLOCKING_BYCALLER);
}
}
else
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
return NSS_STATUS_NOTFOUND;
if (p == NULL || buffer[buflen - 1] != '\xff')
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
return NSS_STATUS_NOTFOUND;
if (p == NULL || buffer[buflen - 1] != '\xff')
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
return NSS_STATUS_NOTFOUND;
if (p == NULL || buffer[buflen - 1] != '\xff')
-/* Copyright (C) 1996,1997,1998,1999,2001,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999,2001,2002,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
if (ent->stream == NULL)
{
- ent->stream = fopen ("/etc/passwd", "r");
+ ent->stream = fopen ("/etc/passwd", "rm");
if (ent->stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
/* We have to make sure the file is `closed on exec'. */
int result, flags;
- result = flags = fcntl (fileno (ent->stream), F_GETFD, 0);
+ result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
if (result >= 0)
{
flags |= FD_CLOEXEC;
- result = fcntl (fileno (ent->stream), F_SETFD, flags);
+ result = fcntl (fileno_unlocked (ent->stream), F_SETFD, flags);
}
if (result < 0)
{
ent->stream = NULL;
status = NSS_STATUS_UNAVAIL;
}
+ else
+ /* We take care of locking ourself. */
+ __fsetlocking (ent->stream, FSETLOCKING_BYCALLER);
}
}
else
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
return NSS_STATUS_NOTFOUND;
if (p == NULL || buffer[buflen - 1] != '\xff')
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
{
return NSS_STATUS_NOTFOUND;
}
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
return NSS_STATUS_NOTFOUND;
if (p == NULL || buffer[buflen - 1] != '\xff')
-/* Copyright (C) 1996,1997,1998,1999,2001,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999,2001,2002,2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <nss.h>
-#include <errno.h>
#include <ctype.h>
+#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
+#include <nss.h>
+#include <nsswitch.h>
#include <shadow.h>
+#include <stdio_ext.h>
#include <string.h>
-#include <bits/libc-lock.h>
#include <rpc/types.h>
#include <rpcsvc/ypclnt.h>
-#include <nsswitch.h>
+#include <bits/libc-lock.h>
#include "netgroup.h"
if (ent->stream == NULL)
{
- ent->stream = fopen ("/etc/shadow", "r");
+ ent->stream = fopen ("/etc/shadow", "rm");
if (ent->stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
/* We have to make sure the file is `closed on exec'. */
int result, flags;
- result = flags = fcntl (fileno (ent->stream), F_GETFD, 0);
+ result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
if (result >= 0)
{
flags |= FD_CLOEXEC;
- result = fcntl (fileno (ent->stream), F_SETFD, flags);
+ result = fcntl (fileno_unlocked (ent->stream), F_SETFD, flags);
}
if (result < 0)
{
ent->stream = NULL;
status = NSS_STATUS_UNAVAIL;
}
+ else
+ /* We take care of locking ourself. */
+ __fsetlocking (ent->stream, FSETLOCKING_BYCALLER);
}
}
else
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
return NSS_STATUS_NOTFOUND;
if (p == NULL || buffer[buflen - 1] != '\xff')
{
fgetpos (ent->stream, &pos);
buffer[buflen - 1] = '\xff';
- p = fgets (buffer, buflen, ent->stream);
- if (p == NULL && feof (ent->stream))
+ p = fgets_unlocked (buffer, buflen, ent->stream);
+ if (p == NULL && feof_unlocked (ent->stream))
return NSS_STATUS_NOTFOUND;
if (p == NULL || buffer[buflen - 1] != '\xff')