VFS: ftpfs can now be switched off

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Enrico Weigelt, metux IT service 2010-07-13 15:58:44 +04:00 committed by Andrew Borodin
parent bc1de7cd78
commit 05516fbac8
16 changed files with 80 additions and 52 deletions

View File

@ -29,9 +29,9 @@ UNDELFILES = undelfs.c
NETFILES = \
netutil.c netutil.h \
fish.c fish.h fishdef.h \
ftpfs.c ftpfs.h
fish.c fish.h fishdef.h
FTPFILES = ftpfs.c ftpfs.h
SMBFILES = smbfs.c smbfs.h
libvfs_mc_la_SOURCES = $(BASICFILES)
@ -53,6 +53,9 @@ endif
if ENABLE_VFS_NET
libvfs_mc_la_SOURCES += $(NETFILES)
endif
if ENABLE_VFS_FTP
libvfs_mc_la_SOURCES += $(FTPFILES)
endif
if USE_SAMBA_FS
libvfs_mc_la_SOURCES += $(SMBFILES)
endif
@ -65,6 +68,7 @@ EXTRA_DIST = HACKING README \
$(EXTFSFILES) \
$(UNDELFILES) \
$(NETFILES) \
$(FTPFILES) \
$(SMBFILES)
dist-hook:

View File

@ -91,7 +91,6 @@ What to do with this?
#include "src/main.h" /* print_vfs_message */
#include "src/history.h"
#include "src/setup.h" /* for load_anon_passwd */
#include "lib/mcconfig.h"
#include "utilvfs.h"
#include "xdirentry.h"
@ -146,7 +145,7 @@ int ftpfs_use_unix_list_options = 1;
int ftpfs_first_cd_then_ls = 1;
/* Use the ~/.netrc */
int use_netrc = 1;
int ftpfs_use_netrc = 1;
/* Anonymous setup */
char *ftpfs_anonymous_passwd = NULL;
@ -156,7 +155,9 @@ int ftpfs_directory_timeout = 900;
char *ftpfs_proxy_host = NULL;
/* wether we have to use proxy by default? */
int ftpfs_always_use_proxy;
int ftpfs_always_use_proxy = 0;
int ftpfs_ignore_chattr_errors = 1;
#ifdef FIXME_LATER_ALIGATOR
static struct linklist *connections_list;
@ -260,14 +261,14 @@ ftpfs_split_url (char *path, char **host, char **user, int *port, char **pass)
if (!*user)
{
/* Look up user and password in netrc */
if (use_netrc)
if (ftpfs_use_netrc)
ftpfs_netrc_lookup (*host, user, pass);
if (!*user)
*user = g_strdup ("anonymous");
}
/* Look up password in netrc for known user */
if (use_netrc && *user && pass && !*pass)
if (ftpfs_use_netrc && *user && pass && !*pass)
{
char *new_user;
@ -1816,12 +1817,7 @@ ftpfs_chmod (struct vfs_class *me, const char *path, int mode)
ret = ftpfs_send_command (me, path, buf, OPT_FLUSH);
if (mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION, "ignore_ftp_chattr_errors", TRUE))
{
return 0;
}
return ret;
return ftpfs_ignore_chattr_errors ? 0 : ret;
}
static int

View File

@ -7,10 +7,12 @@
#ifndef MC_VFS_FTPFS_H
#define MC_VFS_FTPFS_H
extern int ftpfs_use_netrc;
extern char *ftpfs_anonymous_passwd;
extern char *ftpfs_proxy_host;
extern int ftpfs_directory_timeout;
extern int ftpfs_always_use_proxy;
extern int ftpfs_ignore_chattr_errors;
extern int ftpfs_retry_seconds;
extern int ftpfs_use_passive_connections;

View File

@ -127,6 +127,9 @@ void init_fish (void);
#ifdef ENABLE_VFS_UNDELFS
void init_undelfs (void);
#endif
#ifdef ENABLE_VFS_FTP
void init_ftpfs (void);
#endif
#endif /* ENABLE_VFS */

View File

@ -65,7 +65,9 @@
#ifdef USE_NETCODE
# include "netutil.h"
#endif
#ifdef ENABLE_VFS_FTP
#include "ftpfs.h"
#endif
#include "smbfs.h"
#include "local.h"
@ -1349,8 +1351,10 @@ vfs_init (void)
init_undelfs ();
#endif /* ENABLE_VFS_UNDELFS */
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
init_ftpfs ();
#endif /* ENABLE_VFS_FTP */
#ifdef USE_NETCODE
init_fish ();
#ifdef ENABLE_VFS_SMB
init_smbfs ();
@ -1405,7 +1409,9 @@ static const struct
} url_table[] =
{
/* *INDENT-OFF* */
#ifdef ENABLE_VFS_FTP
{ "ftp://", 6, "/#ftp:" },
#endif
{ "smb://", 6, "/#smb:" },
{ "sh://", 5, "/#sh:" },
{ "ssh://", 6, "/#sh:" },

View File

@ -66,7 +66,6 @@ AC_DEFUN([AC_MC_VFS_CHECKS],[
AC_MSG_NOTICE([Enabling VFS code])
AC_MC_VFS_FTP
AC_MC_VFS_FISH
AC_MC_VFS_SAMBA
@ -74,7 +73,6 @@ AC_DEFUN([AC_MC_VFS_CHECKS],[
else
vfs_type="Plain OS filesystem"
AM_CONDITIONAL(ENABLE_VFS_FTP, [false])
AM_CONDITIONAL(ENABLE_VFS_FISH, [false])
fi
@ -83,6 +81,7 @@ AC_DEFUN([AC_MC_VFS_CHECKS],[
AC_MC_VFS_SFS
AC_MC_VFS_EXTFS
AC_MC_VFS_UNDELFS
AC_MC_VFS_FTP
AM_CONDITIONAL(ENABLE_VFS, [test x"$enable_vfs" = x"yes"])
])

View File

@ -2,8 +2,8 @@ dnl Enable FTP filesystem (classic)
AC_DEFUN([AC_MC_VFS_FTP],
[
AC_ARG_ENABLE([vfs-ftp],
[ --enable-vfs-ftp Support for FTP vfs [[yes]]])
if test x"$enable_vfs_ftp" != x"no"; then
AC_HELP_STRING([--enable-vfs-ftp], [Support for FTP filesystem [[yes]]]))
if test "$enable_vfs" != "no" -a x"$enable_vfs_ftp" != x"no"; then
enable_vfs_ftp="yes"
AC_MC_VFS_ADDNAME([ftp])
AC_DEFINE([ENABLE_VFS_FTP], [1], [Support for FTP (classic)])

View File

@ -144,13 +144,14 @@ static const GOptionEntry argument_main_table[] = {
#endif
/* debug options */
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
{
"ftplog", 'l', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_STRING,
&mc_args__netfs_logfile,
N_("Log ftp dialog to specified file"),
"<file>"
},
#endif /* ENABLE_VFS_FTP */
#ifdef ENABLE_VFS_SMB
{
"debuglevel", 'D', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_INT,
@ -159,7 +160,6 @@ static const GOptionEntry argument_main_table[] = {
"<integer>"
},
#endif /* ENABLE_VFS_SMB */
#endif
/* single file operations */
{
@ -389,10 +389,11 @@ mc_setup_by_args (int argc, char *argv[])
if (mc_args__nomouse)
use_mouse_p = MOUSE_DISABLED;
#ifdef USE_NETCODE
if (mc_args__netfs_logfile != NULL)
{
#ifdef ENABLE_VFS_FTP
mc_setctl ("/#ftp:", VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile);
#endif /* ENABLE_VFS_FTP */
#ifdef ENABLE_VFS_SMB
smbfs_set_debugf (mc_args__netfs_logfile);
#endif /* ENABLE_VFS_SMB */
@ -402,7 +403,6 @@ mc_setup_by_args (int argc, char *argv[])
if (mc_args__debug_level != 0)
smbfs_set_debug (mc_args__debug_level);
#endif /* ENABLE_VFS_SMB */
#endif /* USE_NETCODE */
base = x_basename (argv[0]);
tmp = (argc > 0) ? argv[1] : NULL;

View File

@ -43,9 +43,11 @@
#include "lib/strutil.h"
#include "lib/vfs/mc-vfs/vfs.h"
#ifdef ENABLE_VFS_FTP
#include "lib/vfs/mc-vfs/ftpfs.h"
#endif /* ENABLE_VFS_FTP */
#ifdef USE_NETCODE
# include "lib/vfs/mc-vfs/ftpfs.h"
# include "lib/vfs/mc-vfs/smbfs.h"
#include "lib/vfs/mc-vfs/smbfs.h"
#endif
#include "dialog.h" /* The nice dialog manager */
@ -733,10 +735,10 @@ tree_box (const char *current_dir)
static char *ret_timeout;
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
static char *ret_ftp_proxy;
static char *ret_passwd;
static char *ret_directory_timeout;
static char *ret_ftp_proxy;
static cb_ret_t
confvfs_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *data)
@ -763,33 +765,33 @@ confvfs_callback (Dlg_head * h, Widget * sender, dlg_msg_t msg, int parm, void *
return default_dlg_callback (h, sender, msg, parm, data);
}
}
#endif
#endif /* ENABLE_VFS_FTP */
void
configure_vfs (void)
{
#define VFSX 56
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
#define VFSY 17
#else
#define VFSY 8
#endif
#endif /* ENABLE_VFS_FTP */
char buffer2[BUF_TINY];
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
char buffer3[BUF_TINY];
#endif
QuickWidget confvfs_widgets[] = {
/* 0 */ QUICK_BUTTON (30, VFSX, VFSY - 3, VFSY, N_("&Cancel"), B_CANCEL, NULL),
/* 1 */ QUICK_BUTTON (12, VFSX, VFSY - 3, VFSY, N_("&OK"), B_ENTER, NULL),
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
/* 2 */ QUICK_CHECKBOX (4, VFSX, 12, VFSY, N_("Use passive mode over pro&xy"),
&ftpfs_use_passive_connections_over_proxy),
/* 3 */ QUICK_CHECKBOX (4, VFSX, 11, VFSY, N_("Use &passive mode"),
&ftpfs_use_passive_connections),
/* 4 */ QUICK_CHECKBOX (4, VFSX, 10, VFSY, N_("&Use ~/.netrc"), &use_netrc),
/* 4 */ QUICK_CHECKBOX (4, VFSX, 10, VFSY, N_("&Use ~/.netrc"), &ftpfs_use_netrc),
/* 5 */ QUICK_INPUT (4, VFSX, 9, VFSY, ftpfs_proxy_host, 48, 0, "input-ftp-proxy",
&ret_ftp_proxy),
/* 6 */ QUICK_CHECKBOX (4, VFSX, 8, VFSY, N_("&Always use ftp proxy"),
@ -801,7 +803,7 @@ configure_vfs (void)
/* 10 */ QUICK_INPUT (4, VFSX, 6, VFSY, ftpfs_anonymous_passwd, 48, 0, "input-passwd",
&ret_passwd),
/* 11 */ QUICK_LABEL (4, VFSX, 5, VFSY, N_("ftp anonymous password:")),
#endif
#endif /* ENABLE_VFS_FTP */
/* 12 */ QUICK_LABEL (49, VFSX, 3, VFSY, N_("sec")),
/* 13 */ QUICK_INPUT (38, VFSX, 3, VFSY, buffer2, 10, 0, "input-timo-vfs", &ret_timeout),
/* 14 */ QUICK_LABEL (4, VFSX, 3, VFSY, N_("Timeout for freeing VFSs:")),
@ -811,7 +813,7 @@ configure_vfs (void)
QuickDialog confvfs_dlg = {
VFSX, VFSY, -1, -1, N_("Virtual File System Setting"),
"[Virtual FS]", confvfs_widgets,
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
confvfs_callback,
#else
NULL,
@ -819,7 +821,7 @@ configure_vfs (void)
FALSE
};
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
g_snprintf (buffer3, sizeof (buffer3), "%i", ftpfs_directory_timeout);
if (!ftpfs_always_use_proxy)
@ -835,7 +837,7 @@ configure_vfs (void)
if (vfs_timeout < 0 || vfs_timeout > 10000)
vfs_timeout = 10;
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
g_free (ftpfs_anonymous_passwd);
ftpfs_anonymous_passwd = ret_passwd;
g_free (ftpfs_proxy_host);

View File

@ -1259,12 +1259,14 @@ nice_cd (const char *text, const char *xtext, const char *help,
static const char *machine_str = N_("Enter machine name (F1 for details):");
#ifdef ENABLE_VFS_FTP
void
ftplink_cmd (void)
{
nice_cd (_("FTP to machine"), _(machine_str),
"[FTP File System]", ":ftplink_cmd: FTP to machine ", "/#ftp:", 1);
}
#endif /* ENABLE_VFS_FTP */
void
fishlink_cmd (void)

View File

@ -17,7 +17,9 @@ typedef enum
LINK_SYMLINK_RELATIVE
} link_type_t;
#ifdef ENABLE_VFS_FTP
void ftplink_cmd (void);
#endif
void fishlink_cmd (void);
void smblink_cmd (void);
void undelete_cmd (void);

View File

@ -351,6 +351,8 @@ static name_keymap_t command_names[] = {
{ "CmdFind", CK_FindCmd },
#ifdef USE_NETCODE
{ "CmdFishlink", CK_FishlinkCmd },
#endif
#ifdef ENABLE_VFS_FTP
{ "CmdFtplink", CK_FtplinkCmd },
#endif
{ "CmdHistory", CK_HistoryCmd },

View File

@ -674,7 +674,9 @@ create_panel_menu (void)
#endif
#ifdef USE_NETCODE
entries = g_list_append (entries, menu_separator_create ());
#ifdef ENABLE_VFS_FTP
entries = g_list_append (entries, menu_entry_create (_("FT&P link..."), CK_FtplinkCmd));
#endif
entries = g_list_append (entries, menu_entry_create (_("S&hell link..."), CK_FishlinkCmd));
#ifdef ENABLE_VFS_SMB
entries = g_list_append (entries, menu_entry_create (_("SM&B link..."), CK_SmblinkCmd));
@ -1261,6 +1263,8 @@ midnight_execute_cmd (Widget * sender, unsigned long command)
case CK_FishlinkCmd:
fishlink_cmd ();
break;
#endif
#ifdef ENABLE_VFS_FTP
case CK_FtplinkCmd:
ftplink_cmd ();
break;

View File

@ -38,8 +38,10 @@
#include "lib/vfs/mc-vfs/vfs.h"
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
#include "lib/vfs/mc-vfs/ftpfs.h"
#endif
#ifdef USE_NETCODE
#include "lib/vfs/mc-vfs/fish.h"
#endif
@ -212,17 +214,19 @@ static const struct
{ "classic_progressbar", &classic_progressbar},
#ifdef ENABLE_VFS
{ "vfs_timeout", &vfs_timeout },
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
{ "ftpfs_directory_timeout", &ftpfs_directory_timeout },
{ "use_netrc", &use_netrc },
{ "use_netrc", &ftpfs_use_netrc },
{ "ftpfs_retry_seconds", &ftpfs_retry_seconds },
{ "ftpfs_always_use_proxy", &ftpfs_always_use_proxy },
{ "ftpfs_use_passive_connections", &ftpfs_use_passive_connections },
{ "ftpfs_use_passive_connections_over_proxy", &ftpfs_use_passive_connections_over_proxy },
{ "ftpfs_use_unix_list_options", &ftpfs_use_unix_list_options },
{ "ftpfs_first_cd_then_ls", &ftpfs_first_cd_then_ls },
#endif /* ENABLE_VFS_FTP */
#ifdef USE_NETCODE
{ "fish_directory_timeout", &fish_directory_timeout },
#endif /* USE_NETCODE */
#endif
#endif /* ENABLE_VFS */
/* option_tab_spacing is used in internal viewer */
{ "editor_tab_spacing", &option_tab_spacing },
@ -790,9 +794,12 @@ load_setup (void)
mc_config_get_string (mc_main_config, "Misc", "timeformat_recent", FMTTIME);
user_old_timeformat = mc_config_get_string (mc_main_config, "Misc", "timeformat_old", FMTYEAR);
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
ftpfs_proxy_host = mc_config_get_string (mc_main_config, "Misc", "ftp_proxy_host", "gate");
#endif
ftpfs_ignore_chattr_errors = mc_config_get_bool (mc_main_config, CONFIG_APP_SECTION,
"ignore_ftp_chattr_errors", TRUE);
ftpfs_init_passwd ();
#endif /* ENABLE_VFS_FTP */
/* The default color and the terminal dependent color */
setup_color_string = mc_config_get_string (mc_main_config, "Colors", "base_color", "");
@ -802,9 +809,6 @@ load_setup (void)
/* Load the directory history */
/* directory_history_load (); */
/* Remove the temporal entries */
#if defined(ENABLE_VFS) && defined (USE_NETCODE)
ftpfs_init_passwd ();
#endif /* ENABLE_VFS && USE_NETCODE */
#ifdef HAVE_CHARSET
if (load_codepages_list () > 0)
@ -855,11 +859,11 @@ save_setup (void)
save_panel_types ();
/* directory_history_save (); */
#if defined(ENABLE_VFS) && defined (USE_NETCODE)
#ifdef ENABLE_VFS_FTP
mc_config_set_string (mc_main_config, "Misc", "ftpfs_password", ftpfs_anonymous_passwd);
if (ftpfs_proxy_host)
mc_config_set_string (mc_main_config, "Misc", "ftp_proxy_host", ftpfs_proxy_host);
#endif /* ENABLE_VFS && USE_NETCODE */
#endif /* ENABLE_VFS_FTP */
#ifdef HAVE_CHARSET
mc_config_set_string (mc_main_config, "Misc", "display_codepage",
@ -975,7 +979,7 @@ load_key_defs (void)
load_keys_from_section (getenv ("TERM"), mc_main_config);
}
#if defined(ENABLE_VFS) && defined (USE_NETCODE)
#ifdef ENABLE_VFS_FTP
char *
load_anon_passwd (void)
{
@ -989,7 +993,7 @@ load_anon_passwd (void)
g_free (buffer);
return NULL;
}
#endif /* ENABLE_VFS && USE_NETCODE */
#endif /* ENABLE_VFS_FTP */
void
load_keymap_defs (void)

View File

@ -39,9 +39,9 @@ void setup_save_config_show_error (const char *filename, GError **error);
void save_layout (void);
void load_key_defs (void);
#if defined(ENABLE_VFS) && defined (USE_NETCODE)
#ifdef ENABLE_VFS_FTP
char *load_anon_passwd (void);
#endif /* ENABLE_VFS && defined USE_NETCODE */
#endif /* ENABLE_VFS_FTP */
void load_keymap_defs (void);
void free_keymap_defs (void);

View File

@ -48,8 +48,10 @@ static const char *const vfs_supported[] = {
#ifdef ENABLE_VFS_UNDELFS
"undelfs",
#endif
#ifdef USE_NETCODE
#ifdef ENABLE_VFS_FTP
"ftpfs",
#endif
#ifdef USE_NETCODE
"fish",
# ifdef ENABLE_VFS_SMB
"smbfs",