diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-04-18 14:56:51 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-04-18 14:56:51 +0200 |
commit | cef9b65376a044309f74b77860ccf3c48a4ae315 (patch) | |
tree | c934a9b57903468b9a2754c1cf8f99f2a94c9269 /nis | |
parent | b48061e1a534a2421c65e4258418d41a5335ba32 (diff) | |
download | glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.zip glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.gz glibc-cef9b65376a044309f74b77860ccf3c48a4ae315.tar.bz2 |
Assume that O_CLOEXEC is always defined and works
Diffstat (limited to 'nis')
-rw-r--r-- | nis/nss_compat/compat-grp.c | 52 | ||||
-rw-r--r-- | nis/nss_compat/compat-initgroups.c | 52 | ||||
-rw-r--r-- | nis/nss_compat/compat-pwd.c | 52 | ||||
-rw-r--r-- | nis/nss_compat/compat-spwd.c | 52 |
4 files changed, 8 insertions, 200 deletions
diff --git a/nis/nss_compat/compat-grp.c b/nis/nss_compat/compat-grp.c index e830a2f..0381458 100644 --- a/nis/nss_compat/compat-grp.c +++ b/nis/nss_compat/compat-grp.c @@ -70,19 +70,6 @@ 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 *); @@ -125,43 +112,8 @@ internal_setgrent (ent_t *ent, int stayopen, int needent) 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 = 0; - - if (__compat_have_cloexec <= 0) - { - 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 - failure. */ - fclose (ent->stream); - ent->stream = NULL; - status = NSS_STATUS_UNAVAIL; - } - else - /* We take care of locking ourself. */ - __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); - } + /* We take care of locking ourself. */ + __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); } else rewind (ent->stream); diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c index 1b37e0c..7952134 100644 --- a/nis/nss_compat/compat-initgroups.c +++ b/nis/nss_compat/compat-initgroups.c @@ -77,20 +77,6 @@ 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 *); @@ -141,42 +127,8 @@ internal_setgrent (ent_t *ent) 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 = 0; - - if (__compat_have_cloexec <= 0) - { - 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 - failure. */ - fclose (ent->stream); - ent->stream = NULL; - status = NSS_STATUS_UNAVAIL; - } - else - /* We take care of locking ourself. */ - __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); - } + /* We take care of locking ourself. */ + __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); return status; } diff --git a/nis/nss_compat/compat-pwd.c b/nis/nss_compat/compat-pwd.c index 28ae7fb..0583a10 100644 --- a/nis/nss_compat/compat-pwd.c +++ b/nis/nss_compat/compat-pwd.c @@ -80,19 +80,6 @@ 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 *); @@ -240,43 +227,8 @@ internal_setpwent (ent_t *ent, int stayopen, int needent) 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 = 0; - - if (__compat_have_cloexec <= 0) - { - 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 - failure. */ - fclose (ent->stream); - ent->stream = NULL; - status = NSS_STATUS_UNAVAIL; - } - else - /* We take care of locking ourself. */ - __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); - } + /* We take care of locking ourself. */ + __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); } else rewind (ent->stream); diff --git a/nis/nss_compat/compat-spwd.c b/nis/nss_compat/compat-spwd.c index 550444c..eec3af3 100644 --- a/nis/nss_compat/compat-spwd.c +++ b/nis/nss_compat/compat-spwd.c @@ -77,19 +77,6 @@ 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 *); @@ -196,43 +183,8 @@ internal_setspent (ent_t *ent, int stayopen, int needent) 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 = 0; - - if (__compat_have_cloexec <= 0) - { - 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 - failure. */ - fclose (ent->stream); - ent->stream = NULL; - status = NSS_STATUS_UNAVAIL; - } - else - /* We take care of locking ourself. */ - __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); - } + /* We take care of locking ourself. */ + __fsetlocking (ent->stream, FSETLOCKING_BYCALLER); } else rewind (ent->stream); |