summaryrefslogtreecommitdiff
path: root/src/responder
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2012-02-27 06:57:06 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-02-27 11:52:34 -0500
commit26202f8e447b694843d3fb9532673dc280a4c245 (patch)
tree4d4bf3ab72c826dd0c8ba63d53c382d999232629 /src/responder
parent3194ce1c60e766e2a850949427dd99ad09944ddb (diff)
downloadsssd-26202f8e447b694843d3fb9532673dc280a4c245.tar.gz
sssd-26202f8e447b694843d3fb9532673dc280a4c245.tar.bz2
sssd-26202f8e447b694843d3fb9532673dc280a4c245.zip
SSH: Use fchmod instead of chmod on known_hosts file
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/ssh/sshsrv_cmd.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/responder/ssh/sshsrv_cmd.c b/src/responder/ssh/sshsrv_cmd.c
index 40d9c520..33f042a3 100644
--- a/src/responder/ssh/sshsrv_cmd.c
+++ b/src/responder/ssh/sshsrv_cmd.c
@@ -476,6 +476,7 @@ ssh_host_pubkeys_update_known_hosts(struct ssh_cmd_ctx *cmd_ctx)
fd = mkstemp(filename);
if (fd == -1) {
+ filename = NULL;
ret = errno;
goto done;
}
@@ -547,10 +548,7 @@ ssh_host_pubkeys_update_known_hosts(struct ssh_cmd_ctx *cmd_ctx)
dom = dom->next;
}
- close(fd);
- fd = -1;
-
- ret = chmod(filename, 0644);
+ ret = fchmod(fd, 0644);
if (ret == -1) {
ret = errno;
goto done;
@@ -565,10 +563,8 @@ ssh_host_pubkeys_update_known_hosts(struct ssh_cmd_ctx *cmd_ctx)
ret = EOK;
done:
- if (fd != -1) {
- close(fd);
- unlink(filename);
- }
+ if (fd != -1) close(fd);
+ if (ret != EOK && filename) unlink(filename);
talloc_free(tmp_ctx);
return ret;