>From 5eacf73f1d6f4b9c9257fe5b2c0e8fe05df0218a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sun, 5 Aug 2012 22:03:11 +0200 Subject: [PATCH 1/2] Do not try to remove the temp login file if already renamed write_selinux_string() would try to unlink the temporary file even after it was renamed. Failure to unlink the file would not be fatal, but would produce a confusing error message. Also don't use "0" for the default fd number, that's reserved for stdin. Using -1 is safer. --- src/responder/pam/pamsrv_cmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index 92cd734079be76f6c40873c00278f75d5947d686..6df8213f7fea3eef3f05fa71b55ad8b54da93181 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -362,7 +362,7 @@ static errno_t write_selinux_string(const char *username, char *string) char *tmp_path = NULL; ssize_t written; int len; - int fd = 0; + int fd = -1; mode_t oldmask; TALLOC_CTX *tmp_ctx; char *full_string = NULL; @@ -433,9 +433,10 @@ static errno_t write_selinux_string(const char *username, char *string) } else { ret = EOK; } + fd = -1; done: - if (fd > 0) { + if (fd != -1) { close(fd); if (unlink(tmp_path) < 0) { DEBUG(SSSDBG_MINOR_FAILURE, ("Could not remove file [%s]", -- 1.7.11.2