2011-12-27 04:11:19 +00:00
|
|
|
From 33a59a1905feb5d786e9d457f287dd9e81a9f747 Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez@opensuse.org>
|
|
|
|
Date: Tue, 27 Dec 2011 00:33:28 -0300
|
|
|
|
Subject: [PATCH] Use O_CLOEXEC where needed
|
|
|
|
|
|
|
|
---
|
|
|
|
src/agent.c | 2 +-
|
|
|
|
src/knownhost.c | 4 ++--
|
|
|
|
src/userauth.c | 2 +-
|
|
|
|
3 files changed, 4 insertions(+), 4 deletions(-)
|
|
|
|
|
2011-12-01 02:46:12 +00:00
|
|
|
diff --git a/src/agent.c b/src/agent.c
|
2011-12-27 04:11:19 +00:00
|
|
|
index 5a9e81c..af939a1 100644
|
2011-12-01 02:46:12 +00:00
|
|
|
--- a/src/agent.c
|
|
|
|
+++ b/src/agent.c
|
|
|
|
@@ -152,7 +152,7 @@ agent_connect_unix(LIBSSH2_AGENT *agent)
|
|
|
|
return _libssh2_error(agent->session, LIBSSH2_ERROR_BAD_USE,
|
|
|
|
"no auth sock variable");
|
|
|
|
|
|
|
|
- agent->fd = socket(PF_UNIX, SOCK_STREAM, 0);
|
2011-12-27 04:11:19 +00:00
|
|
|
+ agent->fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
2011-12-01 02:46:12 +00:00
|
|
|
if (agent->fd < 0)
|
|
|
|
return _libssh2_error(agent->session, LIBSSH2_ERROR_BAD_SOCKET,
|
|
|
|
"failed creating socket");
|
|
|
|
diff --git a/src/knownhost.c b/src/knownhost.c
|
2011-12-27 04:11:19 +00:00
|
|
|
index 193bda3..418c08a 100644
|
2011-12-01 02:46:12 +00:00
|
|
|
--- a/src/knownhost.c
|
|
|
|
+++ b/src/knownhost.c
|
2011-12-27 04:11:19 +00:00
|
|
|
@@ -907,7 +907,7 @@ libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts,
|
2011-12-01 02:46:12 +00:00
|
|
|
"Unsupported type of known-host information "
|
|
|
|
"store");
|
|
|
|
|
|
|
|
- file = fopen(filename, "r");
|
|
|
|
+ file = fopen(filename, "re");
|
|
|
|
if(file) {
|
|
|
|
while(fgets(buf, sizeof(buf), file)) {
|
|
|
|
if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type))
|
2011-12-27 04:11:19 +00:00
|
|
|
@@ -1079,7 +1079,7 @@ libssh2_knownhost_writefile(LIBSSH2_KNOWNHOSTS *hosts,
|
2011-12-01 02:46:12 +00:00
|
|
|
"Unsupported type of known-host information "
|
|
|
|
"store");
|
|
|
|
|
|
|
|
- file = fopen(filename, "w");
|
|
|
|
+ file = fopen(filename, "we");
|
|
|
|
if(!file)
|
|
|
|
return _libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
|
|
|
|
"Failed to open file");
|
|
|
|
diff --git a/src/userauth.c b/src/userauth.c
|
2011-12-27 04:11:19 +00:00
|
|
|
index 3fcb200..0f48a1d 100644
|
2011-12-01 02:46:12 +00:00
|
|
|
--- a/src/userauth.c
|
|
|
|
+++ b/src/userauth.c
|
|
|
|
@@ -467,7 +467,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
|
|
|
_libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Loading public key file: %s",
|
|
|
|
pubkeyfile);
|
|
|
|
/* Read Public Key */
|
|
|
|
- fd = fopen(pubkeyfile, "r");
|
|
|
|
+ fd = fopen(pubkeyfile, "re");
|
|
|
|
if (!fd) {
|
|
|
|
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
|
|
|
"Unable to open public key file");
|
2011-12-27 04:11:19 +00:00
|
|
|
--
|
|
|
|
1.7.7
|
|
|
|
|