summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-08-05 22:03:11 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-08-16 13:30:58 +0200
commit79402313dc0d7f854b4334dd427e03b7baf0b9db (patch)
treef08cf039ee45ae4bb47deb5f19af024eec9e146b /src
parentaf824bac568ebe8a03273f73246ac78b415ea756 (diff)
downloadsssd_unused-79402313dc0d7f854b4334dd427e03b7baf0b9db.tar.gz
sssd_unused-79402313dc0d7f854b4334dd427e03b7baf0b9db.tar.xz
sssd_unused-79402313dc0d7f854b4334dd427e03b7baf0b9db.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/responder/pam/pamsrv_cmd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
index 8c9dd9b5..944845a8 100644
--- a/src/responder/pam/pamsrv_cmd.c
+++ b/src/responder/pam/pamsrv_cmd.c
@@ -366,7 +366,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;
@@ -437,9 +437,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]",