diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2013-03-08 14:26:42 +0100 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2013-03-13 14:41:33 -0400 |
commit | 22d381367c27910fe82f476a76b9f4ede555e35a (patch) | |
tree | 4c9c2d12bae688e4f94a9864f3069018bf171ca1 /src/sss_client | |
parent | 8359bf07a2e6c0181251ce8d5d9160dc57546c55 (diff) | |
download | sssd-22d381367c27910fe82f476a76b9f4ede555e35a.tar.gz sssd-22d381367c27910fe82f476a76b9f4ede555e35a.tar.bz2 sssd-22d381367c27910fe82f476a76b9f4ede555e35a.zip |
Reuse sss_open_cloexec at other places in code.
Functions open_cloexec and openat_cloexec were renamed with prefix
"sss_" and moved to separete file. Replacing duplicated code of
function sss_open_cloexec everywhere in the source code.
https://fedorahosted.org/sssd/ticket/1794
Diffstat (limited to 'src/sss_client')
-rw-r--r-- | src/sss_client/nss_mc_common.c | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/src/sss_client/nss_mc_common.c b/src/sss_client/nss_mc_common.c index 78490bef..66442b71 100644 --- a/src/sss_client/nss_mc_common.c +++ b/src/sss_client/nss_mc_common.c @@ -31,6 +31,7 @@ #include <string.h> #include <stdlib.h> #include "nss_mc.h" +#include "util/util.h" /* FIXME: hook up to library destructor to avoid leaks */ /* FIXME: temporarily open passwd file on our own, later we will probably @@ -100,12 +101,6 @@ errno_t sss_nss_check_header(struct sss_cli_mc_ctx *ctx) return 0; } -#ifdef O_CLOEXEC -#define SSS_MC_OPEN_FLAGS O_RDONLY|O_CLOEXEC -#else -#define SSS_MC_OPEN_FLAGS O_RDONLY -#endif - errno_t sss_nss_mc_get_ctx(const char *name, struct sss_cli_mc_ctx *ctx) { struct stat fdstat; @@ -129,19 +124,9 @@ errno_t sss_nss_mc_get_ctx(const char *name, struct sss_cli_mc_ctx *ctx) goto done; } - ctx->fd = open(file, SSS_MC_OPEN_FLAGS); + ctx->fd = sss_open_cloexec(file, O_RDONLY, &ret); if (ctx->fd == -1) { - ret = EIO; goto done; -#ifndef O_CLOEXEC - } else { - int v; - - v = fcntl(ctx->fd, F_GETFD, 0); - /* we ignore an error, it's not fatal and there is nothing we - * can do about it anyways */ - (void)fcntl(ctx->fd, F_SETFD, v | FD_CLOEXEC); -#endif } ret = fstat(ctx->fd, &fdstat); |