summaryrefslogtreecommitdiff
path: root/nis
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-31 17:46:17 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-31 17:46:17 +0000
commit8833066b122427710a9e14a888ce6cfa862332d3 (patch)
tree29591019d695919417b3698618d6a342e97381d6 /nis
parentfedca46896bdb702cb988837a0c2c5447e72ba2b (diff)
Updated to fedora-glibc-20070731T1624cvs/fedora-glibc-2_6_90-1
Diffstat (limited to 'nis')
-rw-r--r--nis/nis_domain_of.c4
-rw-r--r--nis/nis_subr.c2
-rw-r--r--nis/nss_compat/compat-grp.c43
-rw-r--r--nis/nss_compat/compat-initgroups.c42
-rw-r--r--nis/nss_compat/compat-pwd.c43
-rw-r--r--nis/nss_compat/compat-spwd.c43
-rw-r--r--nis/nss_nis/nis-hosts.c2
7 files changed, 147 insertions, 32 deletions
diff --git a/nis/nis_domain_of.c b/nis/nis_domain_of.c
index 4d6b48640e..6f41b92bf7 100644
--- a/nis/nis_domain_of.c
+++ b/nis/nis_domain_of.c
@@ -32,10 +32,10 @@ __nis_domain_of (const_nis_name name)
{
const_nis_name cptr = strchr (name, '.');
- if (cptr++ == NULL)
+ if (cptr == NULL)
return "";
- if (*cptr == '\0')
+ if (*++cptr == '\0')
return ".";
return cptr;
diff --git a/nis/nis_subr.c b/nis/nis_subr.c
index c68189e541..abe51a9996 100644
--- a/nis/nis_subr.c
+++ b/nis/nis_subr.c
@@ -112,7 +112,7 @@ nis_getnames (const_nis_name name)
size_t name_len = strlen (name);
char *path;
int pos = 0;
- char *saveptr;
+ char *saveptr = NULL;
int have_point;
const char *cp;
const char *cp2;
diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c
index 236c84a20f..939102868c 100644
--- a/nis/nss_compat/compat-grp.c
+++ b/nis/nss_compat/compat-grp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1999,2001-2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999, 2001-2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
@@ -27,6 +27,7 @@
#include <string.h>
#include <rpc/types.h>
#include <bits/libc-lock.h>
+#include <kernel-features.h>
static service_user *ni;
static enum nss_status (*nss_setgrent) (int stayopen);
@@ -70,6 +71,19 @@ static ent_t ext_ent = { TRUE, NSS_STATUS_SUCCESS, NULL, { NULL, 0, 0 }};
/* Protect global state against multiple changers. */
__libc_lock_define_initialized (static, lock)
+/* Positive if O_CLOEXEC is supported, negative if it is not supported,
+ zero if it is still undecided. This variable is shared with the
+ other compat functions. */
+#ifdef __ASSUME_O_CLOEXEC
+# define __compat_have_cloexec 1
+#else
+# ifdef O_CLOEXEC
+int __compat_have_cloexec;
+# else
+# define __compat_have_cloexec -1
+# endif
+#endif
+
/* Prototypes for local functions. */
static void blacklist_store_name (const char *, ent_t *);
static int in_blacklist (const char *, int, ent_t *);
@@ -107,21 +121,36 @@ internal_setgrent (ent_t *ent, int stayopen, int needent)
if (ent->stream == NULL)
{
- ent->stream = fopen ("/etc/group", "rm");
+ ent->stream = fopen ("/etc/group", "rme");
if (ent->stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
else
{
/* We have to make sure the file is `closed on exec'. */
- int result, flags;
+ int result = 0;
- result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
- if (result >= 0)
+ if (__compat_have_cloexec <= 0)
{
- flags |= FD_CLOEXEC;
- result = fcntl (fileno_unlocked (ent->stream), F_SETFD, flags);
+ int flags;
+ result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD,
+ 0);
+ if (result >= 0)
+ {
+#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC
+ if (__compat_have_cloexec == 0)
+ __compat_have_cloexec = (flags & FD_CLOEXEC) ? 1 : -1;
+
+ if (__compat_have_cloexec < 0)
+#endif
+ {
+ flags |= FD_CLOEXEC;
+ result = fcntl (fileno_unlocked (ent->stream), F_SETFD,
+ flags);
+ }
+ }
}
+
if (result < 0)
{
/* Something went wrong. Close the stream and return a
diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c
index 70403a0785..fd16475ea9 100644
--- a/nis/nss_compat/compat-initgroups.c
+++ b/nis/nss_compat/compat-initgroups.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998-2003, 2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
@@ -30,6 +30,7 @@
#include <sys/param.h>
#include <nsswitch.h>
#include <bits/libc-lock.h>
+#include <kernel-features.h>
static service_user *ni;
/* Type of the lookup function. */
@@ -74,6 +75,19 @@ struct ent_t
typedef struct ent_t ent_t;
+/* Positive if O_CLOEXEC is supported, negative if it is not supported,
+ zero if it is still undecided. This variable is shared with the
+ other compat functions. */
+#ifdef __ASSUME_O_CLOEXEC
+# define __compat_have_cloexec 1
+#else
+# ifdef O_CLOEXEC
+extern int __compat_have_cloexec;
+# else
+# define __compat_have_cloexec -1
+# endif
+#endif
+
/* Prototypes for local functions. */
static void blacklist_store_name (const char *, ent_t *);
static int in_blacklist (const char *, int, ent_t *);
@@ -117,21 +131,35 @@ internal_setgrent (ent_t *ent)
else
ent->blacklist.current = 0;
- ent->stream = fopen ("/etc/group", "rm");
+ ent->stream = fopen ("/etc/group", "rme");
if (ent->stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
else
{
/* We have to make sure the file is `closed on exec'. */
- int result, flags;
+ int result = 0;
- result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
- if (result >= 0)
+ if (__compat_have_cloexec <= 0)
{
- flags |= FD_CLOEXEC;
- result = fcntl (fileno_unlocked (ent->stream), F_SETFD, flags);
+ int flags;
+ result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
+ if (result >= 0)
+ {
+#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC
+ if (__compat_have_cloexec == 0)
+ __compat_have_cloexec = (flags & FD_CLOEXEC) ? 1 : -1;
+
+ if (__compat_have_cloexec < 0)
+#endif
+ {
+ flags |= FD_CLOEXEC;
+ result = fcntl (fileno_unlocked (ent->stream), F_SETFD,
+ flags);
+ }
+ }
}
+
if (result < 0)
{
/* Something went wrong. Close the stream and return a
diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c
index ac132046da..df8f91eea0 100644
--- a/nis/nss_compat/compat-pwd.c
+++ b/nis/nss_compat/compat-pwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1999,2001-2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999, 2001-2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@@ -29,6 +29,7 @@
#include <rpc/types.h>
#include <rpcsvc/ypclnt.h>
#include <bits/libc-lock.h>
+#include <kernel-features.h>
#include "netgroup.h"
@@ -80,6 +81,19 @@ static ent_t ext_ent = { false, false, true, NSS_STATUS_SUCCESS, NULL,
/* Protect global state against multiple changers. */
__libc_lock_define_initialized (static, lock)
+/* Positive if O_CLOEXEC is supported, negative if it is not supported,
+ zero if it is still undecided. This variable is shared with the
+ other compat functions. */
+#ifdef __ASSUME_O_CLOEXEC
+# define __compat_have_cloexec 1
+#else
+# ifdef O_CLOEXEC
+extern int __compat_have_cloexec;
+# else
+# define __compat_have_cloexec -1
+# endif
+#endif
+
/* Prototypes for local functions. */
static void blacklist_store_name (const char *, ent_t *);
static int in_blacklist (const char *, int, ent_t *);
@@ -227,21 +241,36 @@ internal_setpwent (ent_t *ent, int stayopen, int needent)
if (ent->stream == NULL)
{
- ent->stream = fopen ("/etc/passwd", "rm");
+ ent->stream = fopen ("/etc/passwd", "rme");
if (ent->stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
else
{
/* We have to make sure the file is `closed on exec'. */
- int result, flags;
+ int result = 0;
- result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
- if (result >= 0)
+ if (__compat_have_cloexec <= 0)
{
- flags |= FD_CLOEXEC;
- result = fcntl (fileno_unlocked (ent->stream), F_SETFD, flags);
+ int flags;
+ result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD,
+ 0);
+ if (result >= 0)
+ {
+#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC
+ if (__compat_have_cloexec == 0)
+ __compat_have_cloexec = (flags & FD_CLOEXEC) ? 1 : -1;
+
+ if (__compat_have_cloexec < 0)
+#endif
+ {
+ flags |= FD_CLOEXEC;
+ result = fcntl (fileno_unlocked (ent->stream), F_SETFD,
+ flags);
+ }
+ }
}
+
if (result < 0)
{
/* Something went wrong. Close the stream and return a
diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c
index d1de3f75b0..a5977681f2 100644
--- a/nis/nss_compat/compat-spwd.c
+++ b/nis/nss_compat/compat-spwd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-1999,2001-2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1996-1999, 2001-2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1996.
@@ -29,6 +29,7 @@
#include <rpc/types.h>
#include <rpcsvc/ypclnt.h>
#include <bits/libc-lock.h>
+#include <kernel-features.h>
#include "netgroup.h"
@@ -77,6 +78,19 @@ static ent_t ext_ent = { false, true, false, NSS_STATUS_SUCCESS, NULL,
/* Protect global state against multiple changers. */
__libc_lock_define_initialized (static, lock)
+/* Positive if O_CLOEXEC is supported, negative if it is not supported,
+ zero if it is still undecided. This variable is shared with the
+ other compat functions. */
+#ifdef __ASSUME_O_CLOEXEC
+# define __compat_have_cloexec 1
+#else
+# ifdef O_CLOEXEC
+extern int __compat_have_cloexec;
+# else
+# define __compat_have_cloexec -1
+# endif
+#endif
+
/* Prototypes for local functions. */
static void blacklist_store_name (const char *, ent_t *);
static int in_blacklist (const char *, int, ent_t *);
@@ -180,21 +194,36 @@ internal_setspent (ent_t *ent, int stayopen)
if (ent->stream == NULL)
{
- ent->stream = fopen ("/etc/shadow", "rm");
+ ent->stream = fopen ("/etc/shadow", "rme");
if (ent->stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
else
{
/* We have to make sure the file is `closed on exec'. */
- int result, flags;
+ int result = 0;
- result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD, 0);
- if (result >= 0)
+ if (__compat_have_cloexec <= 0)
{
- flags |= FD_CLOEXEC;
- result = fcntl (fileno_unlocked (ent->stream), F_SETFD, flags);
+ int flags;
+ result = flags = fcntl (fileno_unlocked (ent->stream), F_GETFD,
+ 0);
+ if (result >= 0)
+ {
+#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC
+ if (__compat_have_cloexec == 0)
+ __compat_have_cloexec = (flags & FD_CLOEXEC) ? 1 : -1;
+
+ if (__compat_have_cloexec < 0)
+#endif
+ {
+ flags |= FD_CLOEXEC;
+ result = fcntl (fileno_unlocked (ent->stream), F_SETFD,
+ flags);
+ }
+ }
}
+
if (result < 0)
{
/* Something went wrong. Close the stream and return a
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index bde0a3291f..7bf4af786d 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -88,7 +88,7 @@ LINE_PARSER
return 0;
/* Store a pointer to the address in the expected form. */
- entdata->h_addr_ptrs[0] = entdata->host_addr;
+ entdata->h_addr_ptrs[0] = (char *) entdata->host_addr;
entdata->h_addr_ptrs[1] = NULL;
result->h_addr_list = entdata->h_addr_ptrs;