webdav.c (davfs2-1.6.1) | : | webdav.c (davfs2-1.7.0) | ||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
but WITHOUT ANY WARRANTY; without even the implied warranty of | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
GNU General Public License for more details. | GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | |||
along with davfs2; if not, write to the Free Software Foundation, | along with davfs2; if not, write to the Free Software Foundation, | |||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ | |||
#include "config.h" | #include "config.h" | |||
#include <errno.h> | ||||
#include <error.h> | ||||
#ifdef HAVE_FCNTL_H | #ifdef HAVE_FCNTL_H | |||
#include <fcntl.h> | #include <fcntl.h> | |||
#endif | #endif | |||
#ifdef HAVE_ICONV_H | #ifdef HAVE_ICONV_H | |||
#include <iconv.h> | #include <iconv.h> | |||
#endif | #endif | |||
#ifdef HAVE_LANGINFO_H | #ifdef HAVE_LANGINFO_H | |||
#include <langinfo.h> | #include <langinfo.h> | |||
#endif | #endif | |||
#ifdef HAVE_LIBINTL_H | #ifdef HAVE_LIBINTL_H | |||
skipping to change at line 75 | skipping to change at line 73 | |||
#include <ne_props.h> | #include <ne_props.h> | |||
#include <ne_redirect.h> | #include <ne_redirect.h> | |||
#include <ne_request.h> | #include <ne_request.h> | |||
#include <ne_session.h> | #include <ne_session.h> | |||
#include <ne_socket.h> | #include <ne_socket.h> | |||
#include <ne_string.h> | #include <ne_string.h> | |||
#include <ne_uri.h> | #include <ne_uri.h> | |||
#include <ne_utils.h> | #include <ne_utils.h> | |||
#include <ne_xml.h> | #include <ne_xml.h> | |||
#include "util.h" | ||||
#include "defaults.h" | #include "defaults.h" | |||
#include "mount_davfs.h" | #include "mount_davfs.h" | |||
#include "webdav.h" | #include "webdav.h" | |||
#ifdef ENABLE_NLS | #ifdef ENABLE_NLS | |||
#define _(String) gettext(String) | #define _(String) gettext(String) | |||
#else | #else | |||
#define _(String) String | #define _(String) String | |||
#endif | #endif | |||
skipping to change at line 362 | skipping to change at line 361 | |||
if (from_server_enc == (iconv_t) -1) | if (from_server_enc == (iconv_t) -1) | |||
from_server_enc = 0; | from_server_enc = 0; | |||
to_server_enc = iconv_open(args->s_charset, lc_charset); | to_server_enc = iconv_open(args->s_charset, lc_charset); | |||
if (to_server_enc == (iconv_t) -1) | if (to_server_enc == (iconv_t) -1) | |||
to_server_enc = 0; | to_server_enc = 0; | |||
} | } | |||
} | } | |||
#endif /* HAVE_ICONV */ | #endif /* HAVE_ICONV */ | |||
if (ne_sock_init() != 0) | if (ne_sock_init() != 0) | |||
error(EXIT_FAILURE, errno, _("socket library initialization failed")); | ERR(_("socket library initialization failed")); | |||
if (args->neon_debug & ~NE_DBG_HTTPPLAIN) { | if (args->neon_debug & ~NE_DBG_HTTPPLAIN) { | |||
char *buf = malloc(log_bufsize); | char *buf = malloc(log_bufsize); | |||
cookie_io_functions_t *log_func = malloc(sizeof(cookie_io_functions_t)); | cookie_io_functions_t *log_func = malloc(sizeof(cookie_io_functions_t)); | |||
if (!log_func) abort(); | if (!log_func) abort(); | |||
log_func->read = NULL; | log_func->read = NULL; | |||
log_func->write = log_writer; | log_func->write = log_writer; | |||
log_func->seek = NULL; | log_func->seek = NULL; | |||
log_func->close = NULL; | log_func->close = NULL; | |||
log_stream = fopencookie(buf, "w", *log_func); | log_stream = fopencookie(buf, "w", *log_func); | |||
if (!log_stream) | if (!log_stream) | |||
error(EXIT_FAILURE, errno, | ERR(_("can't open stream to log neon-messages")); | |||
_("can't open stream to log neon-messages")); | ||||
ne_debug_init(log_stream, args->neon_debug); | ne_debug_init(log_stream, args->neon_debug); | |||
} | } | |||
session = ne_session_create(args->scheme, args->host, args->port); | session = ne_session_create(args->scheme, args->host, args->port); | |||
read_timeout = args->read_timeout; | read_timeout = args->read_timeout; | |||
ne_set_read_timeout(session, read_timeout); | ne_set_read_timeout(session, read_timeout); | |||
connect_timeout = args->connect_timeout; | connect_timeout = args->connect_timeout; | |||
ne_set_connect_timeout(session, connect_timeout); | ne_set_connect_timeout(session, connect_timeout); | |||
skipping to change at line 415 | skipping to change at line 413 | |||
ne_session_proxy(session, args->p_host, args->p_port); | ne_session_proxy(session, args->p_host, args->p_port); | |||
if (args->p_user) | if (args->p_user) | |||
p_username = ne_strdup(args->p_user); | p_username = ne_strdup(args->p_user); | |||
if (args->p_passwd) | if (args->p_passwd) | |||
p_password = ne_strdup(args->p_passwd); | p_password = ne_strdup(args->p_passwd); | |||
ne_add_proxy_auth(session, NE_AUTH_ALL, auth, "proxy"); | ne_add_proxy_auth(session, NE_AUTH_ALL, auth, "proxy"); | |||
} | } | |||
if (strcmp(args->scheme, "https") == 0) { | if (strcmp(args->scheme, "https") == 0) { | |||
if (!ne_has_support(NE_FEATURE_SSL)) | if (!ne_has_support(NE_FEATURE_SSL)) | |||
error(EXIT_FAILURE, 0, _("neon library does not support TLS/SSL")); | ERR(_("neon library does not support TLS/SSL")); | |||
ne_ssl_set_verify(session, ssl_verify, NULL); | ne_ssl_set_verify(session, ssl_verify, NULL); | |||
if (args->trust_server_cert) { | if (args->trust_server_cert) { | |||
server_cert = ne_ssl_cert_read(args->trust_server_cert); | server_cert = ne_ssl_cert_read(args->trust_server_cert); | |||
if (!server_cert) | if (!server_cert) | |||
error(EXIT_FAILURE, 0, _("can't read server certificate %s"), | ERR(_("can't read server certificate %s"), | |||
args->trust_server_cert); | args->trust_server_cert); | |||
} else if (args->trust_ca_cert) { | } else if (args->trust_ca_cert) { | |||
ne_ssl_certificate *ca_cert = ne_ssl_cert_read(args->trust_ca_cert); | ne_ssl_certificate *ca_cert = ne_ssl_cert_read(args->trust_ca_cert); | |||
if (!ca_cert) | if (!ca_cert) | |||
error(EXIT_FAILURE, 0, _("can't read server certificate %s"), | ERR(_("can't read server certificate %s"), | |||
args->trust_ca_cert); | args->trust_ca_cert); | |||
ne_ssl_trust_cert(session, ca_cert); | ne_ssl_trust_cert(session, ca_cert); | |||
} else { | } else { | |||
ne_ssl_trust_default_ca(session); | ne_ssl_trust_default_ca(session); | |||
} | } | |||
if (args->clicert) { | if (args->clicert) { | |||
ne_ssl_client_cert *client_cert | ne_ssl_client_cert *client_cert | |||
= ne_ssl_clicert_read(args->clicert); | = ne_ssl_clicert_read(args->clicert); | |||
if (!client_cert) { | if (!client_cert) { | |||
uid_t orig = geteuid(); | uid_t orig = geteuid(); | |||
if (seteuid(0) != 0) | if (seteuid(0) != 0) | |||
error(EXIT_FAILURE, errno, _("can't change effective user id ")); | ERR(_("can't change effective user id")); | |||
client_cert = ne_ssl_clicert_read(args->clicert); | client_cert = ne_ssl_clicert_read(args->clicert); | |||
if (seteuid(orig) != 0) | if (seteuid(orig) != 0) | |||
error(EXIT_FAILURE, errno, _("can't change effective user id ")); | ERR(_("can't change effective user id")); | |||
} | } | |||
if (!client_cert) | if (!client_cert) | |||
error(EXIT_FAILURE, 0, _("can't read client certificate %s"), | ERR(_("can't read client certificate %s"), | |||
args->clicert); | args->clicert); | |||
if (client_cert && ne_ssl_clicert_encrypted(client_cert)) { | if (client_cert && ne_ssl_clicert_encrypted(client_cert)) { | |||
char *pw = NULL; | char *pw = NULL; | |||
if (!args->clicert_pw && args->askauth) { | if (!args->clicert_pw && args->askauth) { | |||
printf(_("Please enter the password to decrypt client\n" | printf(_("Please enter the password to decrypt client\n" | |||
"certificate %s.\n"), args->clicert); | "certificate %s.\n"), args->clicert); | |||
pw = dav_user_input_hidden(_("Password: ")); | pw = dav_user_input_hidden(_("Password: ")); | |||
} else { | } else { | |||
pw = ne_strdup(args->clicert_pw); | pw = ne_strdup(args->clicert_pw); | |||
} | } | |||
int ret = 1; | int ret = 1; | |||
if (pw) { | if (pw) { | |||
ret = ne_ssl_clicert_decrypt(client_cert, pw); | ret = ne_ssl_clicert_decrypt(client_cert, pw); | |||
memset(pw, '\0', strlen(pw)); | memset(pw, '\0', strlen(pw)); | |||
free(pw); | free(pw); | |||
} | } | |||
if (ret) | if (ret) | |||
error(EXIT_FAILURE, 0, | ERR(_("can't decrypt client certificate %s"), | |||
_("can't decrypt client certificate %s"), | ||||
args->clicert); | args->clicert); | |||
} | } | |||
ne_ssl_set_clicert(session, client_cert); | ne_ssl_set_clicert(session, client_cert); | |||
ne_ssl_clicert_free(client_cert); | ne_ssl_clicert_free(client_cert); | |||
} | } | |||
} | } | |||
have_terminal = args->askauth; | have_terminal = args->askauth; | |||
if (args->locks) { | if (args->locks) { | |||
skipping to change at line 528 | skipping to change at line 525 | |||
dav_init_connection(const char *path) | dav_init_connection(const char *path) | |||
{ | { | |||
char *spath = ne_path_escape(path); | char *spath = ne_path_escape(path); | |||
ne_server_capabilities caps = {0, 0, 0}; | ne_server_capabilities caps = {0, 0, 0}; | |||
int ret = ne_options(session, spath, &caps); | int ret = ne_options(session, spath, &caps); | |||
if (!ret) { | if (!ret) { | |||
initialized = 1; | initialized = 1; | |||
if (!caps.dav_class1 && !ignore_dav_header) { | if (!caps.dav_class1 && !ignore_dav_header) { | |||
if (have_terminal) { | if (have_terminal) { | |||
error(EXIT_FAILURE, 0, | ERR(_("mounting failed; the server does not support WebDAV")); | |||
_("mounting failed; the server does not support WebDAV")); | ||||
} else { | } else { | |||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR), | syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR), | |||
_("mounting failed; the server does not support WebDAV")) ; | _("mounting failed; the server does not support WebDAV")) ; | |||
ret = EINVAL; | ret = EINVAL; | |||
} | } | |||
} | } | |||
if ((caps.dav_class2 || ignore_dav_header) && locks) { | if ((caps.dav_class2 || ignore_dav_header) && locks) { | |||
ne_lockstore_register(locks, session); | ne_lockstore_register(locks, session); | |||
} else if (locks) { | } else if (locks) { | |||
if (have_terminal) | if (have_terminal) | |||
error(0, 0, _("warning: the server does not support locks")); | WARN(_("warning: the server does not support locks")); | |||
ne_lockstore_destroy(locks); | ne_lockstore_destroy(locks); | |||
locks = NULL; | locks = NULL; | |||
} | } | |||
} else { | } else { | |||
ret = get_error(ret, "OPTIONS", session); | ret = get_error(ret, "OPTIONS", session); | |||
} | } | |||
free(spath); | free(spath); | |||
return ret; | return ret; | |||
} | } | |||
skipping to change at line 1949 | skipping to change at line 1945 | |||
cert : the server certificate that could not be verified by neon. | cert : the server certificate that could not be verified by neon. | |||
return value : 0 accept the certificate for this session. | return value : 0 accept the certificate for this session. | |||
-1 don't accept the certificate. */ | -1 don't accept the certificate. */ | |||
static int | static int | |||
ssl_verify(void *userdata, int failures, const ne_ssl_certificate *cert) | ssl_verify(void *userdata, int failures, const ne_ssl_certificate *cert) | |||
{ | { | |||
if (server_cert) { | if (server_cert) { | |||
if (ne_ssl_cert_cmp(cert, server_cert) == 0) | if (ne_ssl_cert_cmp(cert, server_cert) == 0) | |||
return 0; | return 0; | |||
if (have_terminal) | if (have_terminal) | |||
error(0, 0, _("the server certificate is not trusted")); | WARN(_("the server certificate is not trusted")); | |||
return -1; | return -1; | |||
} | } | |||
char *issuer = ne_ssl_readable_dname(ne_ssl_cert_issuer(cert)); | char *issuer = ne_ssl_readable_dname(ne_ssl_cert_issuer(cert)); | |||
char *subject = ne_ssl_readable_dname(ne_ssl_cert_subject(cert)); | char *subject = ne_ssl_readable_dname(ne_ssl_cert_subject(cert)); | |||
char *digest = ne_calloc(NE_SSL_DIGESTLEN); | char *digest = ne_calloc(NE_SSL_DIGESTLEN); | |||
if (!issuer || !subject || ne_ssl_cert_digest(cert, digest) != 0) { | if (!issuer || !subject || ne_ssl_cert_digest(cert, digest) != 0) { | |||
if (have_terminal) { | if (have_terminal) { | |||
error(0, 0, _("error processing server certificate")); | WARN(_("error processing server certificate")); | |||
} else { | } else { | |||
syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR), | syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_ERR), | |||
_("error processing server certificate")); | _("error processing server certificate")); | |||
} | } | |||
if (issuer) free(issuer); | if (issuer) free(issuer); | |||
if (subject) free(subject); | if (subject) free(subject); | |||
if (digest) free(digest); | if (digest) free(digest); | |||
return -1; | return -1; | |||
} | } | |||
int ret = -1; | int ret = -1; | |||
if (have_terminal) { | if (have_terminal) { | |||
if (failures & NE_SSL_NOTYETVALID) | if (failures & NE_SSL_NOTYETVALID) | |||
error(0, 0, _("the server certificate is not yet valid")); | WARN(_("the server certificate is not yet valid")); | |||
if (failures & NE_SSL_EXPIRED) | if (failures & NE_SSL_EXPIRED) | |||
error(0, 0, _("the server certificate has expired")); | WARN(_("the server certificate has expired")); | |||
if (failures & NE_SSL_IDMISMATCH) | if (failures & NE_SSL_IDMISMATCH) | |||
error(0, 0, _("the server certificate does not match the server name ")); | WARN(_("the server certificate does not match the server name")); | |||
if (failures & NE_SSL_UNTRUSTED) | if (failures & NE_SSL_UNTRUSTED) | |||
error(0, 0, _("the server certificate is not trusted")); | WARN(_("the server certificate is not trusted")); | |||
if (failures & ~NE_SSL_FAILMASK) | if (failures & ~NE_SSL_FAILMASK) | |||
error(0, 0, _("unknown certificate error")); | WARN(_("unknown certificate error")); | |||
printf(_(" issuer: %s"), issuer); | printf(_(" issuer: %s"), issuer); | |||
printf("\n"); | printf("\n"); | |||
printf(_(" subject: %s"), subject); | printf(_(" subject: %s"), subject); | |||
printf("\n"); | printf("\n"); | |||
printf(_(" identity: %s"), ne_ssl_cert_identity(cert)); | printf(_(" identity: %s"), ne_ssl_cert_identity(cert)); | |||
printf("\n"); | printf("\n"); | |||
printf(_(" fingerprint: %s"), digest); | printf(_(" fingerprint: %s"), digest); | |||
printf("\n"); | printf("\n"); | |||
printf(_("You only should accept this certificate, if you can\n" | printf(_("You only should accept this certificate, if you can\n" | |||
"verify the fingerprint! The server might be faked\n" | "verify the fingerprint! The server might be faked\n" | |||
End of changes. 20 change blocks. | ||||
23 lines changed or deleted | 19 lines changed or added |