1
1

Merge branch '2923_sftp_aliases'

* 2923_sftp_aliases:
  src/vfs/sftpfs/vfs_subclass.c: add missing includes.
  Fix: sftp: password ask too often if hostname was bring from ~/.ssh/config file
  Ticket #2923: broken aliases in SFTPFS.
Этот коммит содержится в:
Slava Zanko 2013-06-18 12:53:28 +03:00
родитель 97e37308b9 fc34675093
Коммит a3b96d69f1
6 изменённых файлов: 55 добавлений и 25 удалений

Просмотреть файл

@ -1,11 +1,11 @@
/*
GLIB - Library of useful routines for C programming
Copyright (C) 2009, 2011
Copyright (C) 2009, 2011, 2013
The Free Software Foundation, Inc.
Written by:
Slava Zanko <slavazanko@gmail.com>, 2009.
Slava Zanko <slavazanko@gmail.com>, 2009, 2013.
This file is part of the Midnight Commander.
@ -31,6 +31,7 @@
*/
#include <config.h>
#include <string.h>
#include "global.h"
#include "glibcompat.h"
@ -68,3 +69,30 @@ g_unichar_iszerowidth (gunichar c)
#endif /* ! GLIB_CHECK_VERSION (2, 13, 0) */
/* --------------------------------------------------------------------------------------------- */
#if ! GLIB_CHECK_VERSION (2, 16, 0)
/**
* g_strcmp0:
* @str1: (allow-none): a C string or %NULL
* @str2: (allow-none): another C string or %NULL
*
* Compares @str1 and @str2 like strcmp(). Handles %NULL
* gracefully by sorting it before non-%NULL strings.
* Comparing two %NULL pointers returns 0.
*
* Returns: an integer less than, equal to, or greater than zero, if @str1 is <, == or > than @str2.
*
* Since: 2.16
*/
int
g_strcmp0 (const char *str1, const char *str2)
{
if (!str1)
return -(str1 != str2);
if (!str2)
return str1 != str2;
return strcmp (str1, str2);
}
#endif /* ! GLIB_CHECK_VERSION (2, 16, 0) */
/* --------------------------------------------------------------------------------------------- */

Просмотреть файл

@ -15,6 +15,10 @@
gboolean g_unichar_iszerowidth (gunichar);
#endif /* ! GLIB_CHECK_VERSION (2, 13, 0) */
#if ! GLIB_CHECK_VERSION (2, 16, 0)
int g_strcmp0 (const char *str1, const char *str2);
#endif /* ! GLIB_CHECK_VERSION (2, 16, 0) */
/*** inline functions ****************************************************************************/
#endif /* MC_GLIBCOMPAT_H */

Просмотреть файл

@ -32,6 +32,7 @@
#include "lib/global.h"
#include "lib/search.h"
#include "lib/util.h" /* tilde_expand() */
#include "lib/vfs/utilvfs.h"
#include "internal.h"
@ -120,7 +121,9 @@ sftpfs_correct_file_name (const char *filename)
vfs_path_t *vpath;
char *ret_value;
vpath = vfs_path_from_str (filename);
ret_value = tilde_expand (filename);
vpath = vfs_path_from_str (ret_value);
g_free (ret_value);
ret_value = g_strdup (vfs_path_as_str (vpath));
vfs_path_free (vpath);
return ret_value;

Просмотреть файл

@ -1,12 +1,12 @@
/* Virtual File System: SFTP file system.
The internal functions: connections
Copyright (C) 2011
Copyright (C) 2011, 2013
The Free Software Foundation, Inc.
Written by:
Ilia Maslakov <il.smind@gmail.com>, 2011
Slava Zanko <slavazanko@gmail.com>, 2011, 2012
Slava Zanko <slavazanko@gmail.com>, 2011, 2012, 2013
This file is part of the Midnight Commander.
@ -437,6 +437,7 @@ sftpfs_close_connection (struct vfs_s_super *super, const char *shutdown_message
if (super_data == NULL)
return;
vfs_path_element_free (super_data->original_connection_info);
if (super_data->agent != NULL)
{
libssh2_agent_disconnect (super_data->agent);

Просмотреть файл

@ -43,6 +43,7 @@ typedef struct
int socket_handle;
const char *fingerprint;
vfs_path_element_t *original_connection_info;
} sftpfs_super_data_t;
/*** global variables defined in .c file *********************************************************/

Просмотреть файл

@ -1,12 +1,12 @@
/* Virtual File System: SFTP file system.
The VFS subclass functions
Copyright (C) 2011
Copyright (C) 2011, 2013
The Free Software Foundation, Inc.
Written by:
Ilia Maslakov <il.smind@gmail.com>, 2011
Slava Zanko <slavazanko@gmail.com>, 2011, 2012
Slava Zanko <slavazanko@gmail.com>, 2011, 2012, 2013
This file is part of the Midnight Commander.
@ -26,6 +26,8 @@
#include <config.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h> /* memset() */
#include "lib/global.h"
#include "lib/vfs/utilvfs.h"
@ -58,29 +60,17 @@ static gboolean
sftpfs_cb_is_equal_connection (const vfs_path_element_t * vpath_element, struct vfs_s_super *super,
const vfs_path_t * vpath, void *cookie)
{
int port;
char *user_name;
int result;
vfs_path_element_t *orig_connect_info;
(void) vpath;
(void) cookie;
if (vpath_element->user != NULL)
user_name = vpath_element->user;
else
user_name = vfs_get_local_username ();
orig_connect_info = ((sftpfs_super_data_t *) super->data)->original_connection_info;
if (vpath_element->port != 0)
port = vpath_element->port;
else
port = SFTP_DEFAULT_PORT;
result = ((strcmp (vpath_element->host, super->path_element->host) == 0)
&& (strcmp (user_name, super->path_element->user) == 0)
&& (port == super->path_element->port));
if (user_name != vpath_element->user)
g_free (user_name);
result = ((g_strcmp0 (vpath_element->host, orig_connect_info->host) == 0)
&& (g_strcmp0 (vpath_element->user, orig_connect_info->user) == 0)
&& (vpath_element->port == orig_connect_info->port));
return result;
}
@ -100,6 +90,7 @@ sftpfs_cb_open_connection (struct vfs_s_super *super,
const vfs_path_t * vpath, const vfs_path_element_t * vpath_element)
{
GError *error = NULL;
sftpfs_super_data_t *sftpfs_super_data;
int ret_value;
(void) vpath;
@ -111,7 +102,9 @@ sftpfs_cb_open_connection (struct vfs_s_super *super,
return -1;
}
super->data = g_new0 (sftpfs_super_data_t, 1);
sftpfs_super_data = g_new0 (sftpfs_super_data_t, 1);
sftpfs_super_data->original_connection_info = vfs_path_element_clone (vpath_element);
super->data = sftpfs_super_data;
super->path_element = vfs_path_element_clone (vpath_element);
sftpfs_fill_connection_data_from_config (super, &error);