From 68cfbb7e199230aa12c4afd1dd81f27dab60c470 Mon Sep 17 00:00:00 2001 From: Asanka Herath Date: Tue, 22 Dec 2009 14:03:39 -0500 Subject: [PATCH] Add rk_cloexec_dir() to lib/roken --- lib/hx509/ks_dir.c | 4 +--- lib/krb5/plugin.c | 4 +--- lib/roken/cloexec.c | 8 ++++++++ lib/roken/roken-common.h | 3 +++ lib/roken/roken.h.in | 4 ++++ lib/roken/version-script.map | 1 + 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/hx509/ks_dir.c b/lib/hx509/ks_dir.c index 0d07aa95c..8c8c6e50c 100644 --- a/lib/hx509/ks_dir.c +++ b/lib/hx509/ks_dir.c @@ -113,9 +113,7 @@ dir_iter_start(hx509_context context, free(d); return errno; } -#ifndef _WIN32 - rk_cloexec(dirfd(d->dir)); -#endif + rk_cloexec_dir(d->dir); d->certs = NULL; d->iter = NULL; diff --git a/lib/krb5/plugin.c b/lib/krb5/plugin.c index 9118ade67..aa71e29b3 100644 --- a/lib/krb5/plugin.c +++ b/lib/krb5/plugin.c @@ -205,9 +205,7 @@ load_plugins(krb5_context context) d = opendir(*di); if (d == NULL) continue; -#ifdef HAVE_DIRFD - rk_cloexec(dirfd(d)); -#endif + rk_cloexec_dir(d); while ((entry = readdir(d)) != NULL) { char *n = entry->d_name; diff --git a/lib/roken/cloexec.c b/lib/roken/cloexec.c index 901512a9d..0f2ef2f65 100644 --- a/lib/roken/cloexec.c +++ b/lib/roken/cloexec.c @@ -56,3 +56,11 @@ rk_cloexec_file(FILE *f) rk_cloexec(fileno(f)); #endif } + +void ROKEN_LIB_FUNCTION +rk_cloexec_dir(DIR * d) +{ +#ifdef HAVE_DIRFD + rk_cloexec(dirfd(d)); +#endif +} diff --git a/lib/roken/roken-common.h b/lib/roken/roken-common.h index ac7a92d15..a437d8a34 100644 --- a/lib/roken/roken-common.h +++ b/lib/roken/roken-common.h @@ -480,6 +480,9 @@ rk_cloexec(int); ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL rk_cloexec_file(FILE *); +ROKEN_LIB_FUNCTION void ROKEN_LIB_CALL +rk_cloexec_dir(DIR *); + ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL ct_memcmp(const void *, const void *, size_t); diff --git a/lib/roken/roken.h.in b/lib/roken/roken.h.in index d495b3462..b84e8c1e0 100644 --- a/lib/roken/roken.h.in +++ b/lib/roken/roken.h.in @@ -222,6 +222,10 @@ struct sockaddr_dl; #include #endif +#ifdef HAVE_DIRENT_H +#include +#endif + #ifdef BACKSLASH_PATH_DELIM #define rk_PATH_DELIM '\\' #endif diff --git a/lib/roken/version-script.map b/lib/roken/version-script.map index 9f192ec35..0b2bdbec3 100644 --- a/lib/roken/version-script.map +++ b/lib/roken/version-script.map @@ -42,6 +42,7 @@ HEIMDAL_ROKEN_1.0 { rk_cgetstr; rk_cloexec; rk_cloexec_file; + rk_cloexec_dir; rk_closefrom; rk_copyhostent; rk_dns_free_data;