-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 12/16/2010 04:25 PM, Simo Sorce wrote: >> Patch 0002: https://fedorahosted.org/sssd/ticket/713 > > NACK, failing to set non-blocking should probably be a fatal failure, > as any operation would get us stuck on the socket blocking everything > else (signal processing and all).
Excellent point. I've modified the patch to reflect this. (And also fixed a related issue in close-on-exec that I found nearby) Please re-review. - -- Stephen Gallagher RHCE 804006346421761 Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk0LVscACgkQeiVVYja6o6PX2QCdE4dvxtjdMWBmgma0Qx55q8uH 7skAniwnKK3qnmyltxpadnRQd6NtI1Io =2rPr -----END PGP SIGNATURE-----
From 4c82ae30c2b27b9d1b0772f4f9cde0a90a1b5453 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher <[email protected]> Date: Thu, 16 Dec 2010 14:44:22 -0500 Subject: [PATCH] Fix unchecked return value in set_nonblocking Also fixes the same problem with set_close_on_exec https://fedorahosted.org/sssd/ticket/713 --- src/responder/common/responder_common.c | 63 ++++++++++++++++++++++++++----- 1 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 231d828064f32335c85b618d97c6316191365585..2a4a5d20c171ff7c7a8be3dfafaef17844c96c08 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -45,18 +45,46 @@ #include "monitor/monitor_interfaces.h" #include "sbus/sbus_client.h" -static void set_nonblocking(int fd) +static errno_t set_nonblocking(int fd) { - unsigned v; + int v; + int ferr; + errno_t error; + + /* Get the current flags for this file descriptor */ v = fcntl(fd, F_GETFL, 0); - fcntl(fd, F_SETFL, v | O_NONBLOCK); + + errno = 0; + /* Set the non-blocking flag on this fd */ + ferr = fcntl(fd, F_SETFL, v | O_NONBLOCK); + if (ferr < 0) { + error = errno; + DEBUG(0, ("Unable to set fd non-blocking: [%d][%s]\n", + error, strerror(error))); + return error; + } + return EOK; } -static void set_close_on_exec(int fd) +static errno_t set_close_on_exec(int fd) { - unsigned v; + int v; + int ferr; + errno_t error; + + /* Get the current flags for this file descriptor */ v = fcntl(fd, F_GETFD, 0); - fcntl(fd, F_SETFD, v | FD_CLOEXEC); + + errno = 0; + /* Set the close-on-exec flags on this fd */ + ferr = fcntl(fd, F_SETFD, v | FD_CLOEXEC); + if (ferr < 0) { + error = errno; + DEBUG(0, ("Unable to set fd close-on-exec: [%d][%s]\n", + error, strerror(error))); + return error; + } + return EOK; } static int client_destructor(struct cli_ctx *ctx) @@ -415,6 +443,7 @@ static int sss_dp_init(struct resp_ctx *rctx, static int set_unix_socket(struct resp_ctx *rctx) { struct sockaddr_un addr; + errno_t ret; /* for future use */ #if 0 @@ -462,8 +491,15 @@ static int set_unix_socket(struct resp_ctx *rctx) * It must be readable and writable by anybody on the system. */ umask(0111); - set_nonblocking(rctx->lfd); - set_close_on_exec(rctx->lfd); + ret = set_nonblocking(rctx->lfd); + if (ret != EOK) { + goto failed; + } + + ret = set_close_on_exec(rctx->lfd); + if (ret != EOK) { + goto failed; + } memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; @@ -500,8 +536,15 @@ static int set_unix_socket(struct resp_ctx *rctx) umask(0177); - set_nonblocking(rctx->priv_lfd); - set_close_on_exec(rctx->priv_lfd); + ret = set_nonblocking(rctx->priv_lfd); + if (ret != EOK) { + goto failed; + } + + ret = set_close_on_exec(rctx->priv_lfd); + if (ret != EOK) { + goto failed; + } memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; -- 1.7.3.3
0001-Fix-unchecked-return-value-in-set_nonblocking.patch.sig
Description: PGP signature
_______________________________________________ sssd-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/sssd-devel
