Properly parse %h hostname token, which is widely used in HostName directive within
~/.ssh/config:
Host testing*
HostName %h.eu.example.com
Host staging*
HostName %h.us.example.net
# this host will be expanded to `testing-1.eu.example.com`
% mc sftp://username@testing-1
ClosesMidnightCommander/mc#197.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (vfs_dirent_assign): set d_len up.
* (mc_readdir): sync with new vfs_dirent: use d_len member.
* (filename_completion_function): likewise.
* (handle_dirent): likewise.
* (find_ignore_dir_search): add 2nd argument to use length of
directory name if it's known.
* (do_search): sync with modified vfs_dirent and find_ignore_dir_search().
* (NLENGTH): remove.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(panel_load_setup): if user's format of file list and status line
are undefined in the ini file, set them to NULL instead of
DEFAULT_USER_FORMAT.
Move definition of DEFAULT_USER_FORMAT macro from panel.h to panel.c.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(edit_user_menu): fix misinterpretation of return value of
edit_block_delete_cmd(). The bug was introduced in
e2e34d82ab.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When xorriso is installed, iso9660 listing was done with `xorriso .. -lsl ..`
per dir recursively. It was unbearably slow on iso images with lots of subdirs.
For example, it took my machine 2 minutes to open debian-12.5.0-amd64-DVD-1.iso
which contains 2627 dirs. This commit makes use of `xorriso .. -find / -exec
lsdl ..` instead to list the whole directory tree in a single pass.
Also, parsing of xorriso output has been reworked and as a result such
previously missing items became visible in the listing:
- symlinks
- the boot catalog file
ClosesMidnightCommander/mc#196.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (mc_tmpdir): use g_mkdtemp() to create temporary directory.
Make it name unique to avoid conflicts with other software such as
Distrobox container.
* (main): temporary directory has unique name from now. Remove it at exit.
If EOF has been read, don't attempt to seek past it.
Sync with GNU tar 21318f385627a30da5d92811dd80f70abbe80ee7.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
src/filemanager/ioblksize.h: Add updated test results and increase value
from 128KiB to 256KiB.
This was previously 128KiB and increasing to 256KiB was seen to increase
throughput by 10-20% when reading cached files on modern systems.
Sync with GNU coreutils fcfba90d0d27a1bacf2020bac4dbec74ed181028.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (mcedit_arg_t): rename to edit_arg_t and move to src/editor/edit.h.
* (mcedit_arg_free): rename to edit_arg_free() and move to src/editor/edit.c.
* (mcedit_arg_vpath_new): rename to edit_arg_vpath_new(), move to src/editor/edit.c
and make public.
* (mcedit_arg_new): rename to edit_arg_new(), move to src/editor/edit.c
and make public.
* src/editor/editwidget.c: sync with new editor APIs.
* src/main.c: likewise.
* src/args.c: likewise.
* (mc_args_parse): show error in case of run MC as "mc -e" if MC is built
without builtin editor.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
mcedit: fix losing column position when navigating up/down.
Regression from 49bc0ddebf.
ClosesMidnightCommander/mc#194.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...from \a to \e\\. Various standards (at least ECMA-48 and DEC STD 070)
agree that an OSC is to be terminated by an ST, i.e. \e\\. Using BEL \a
is a nonstandard solution introduced and popularized by xterm.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Some of the "service" commands generated by the mc "leak" into the fish
subshell history available to the user. An example to reproduce:
* set user shell to fish and start mc (SHELL=/usr/bin/fish mc)
* navigate to any directory
* press Ctrl+o
* press \u2191 button (UP, go back in history)
* observe " cd (printf '%b' ... " command
This commit avoids the " cd (printf '%b' ... " commands in the fish
history.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (edit_search): do not call edit_search_fix_search_start_if_selection()
since it called in edit_search_init().
* (edit_replace_cmd): likewise; join two ifs.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The bug was introduced in 21feb38a8d.
* (edit_search_init): call edit_get_search_line_type().
* (edit_search): do mot call edit_get_search_line_type() since it is
called in edit_search_init().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If mark column (Shitf+F3) and select the column from left to right, from
up to down, it can be properly deleted later with F8.
But if select it from right to left, from up to down, erasing with F8
keeps the first line of the selected block.
Solution: don't call eval_marks() several times while deleting vertical
block.
* (edit_block_delete_cmd): calculate mark positions here and pass them...
* (edit_block_delete): ...through here...
* (edit_delete_column_of_text): ...to here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (edit_search_cmd): use mc_config_history_get_recent_item().
* (mcview_continue_search_cmd): likewise.
mc_config_history_get_recent_item() is not implemented optimally yet.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (edit_left_word_move): break the loop as fast as possible.
* (edit_right_word_move): likewise.
* (edit_left_delete_word): likewise.
* (edit_right_delete_word): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (oldgnu_get_sparse_info): change type for boolean variable from int
to gboolean.
* (star_get_sparse_info): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
tar-sparse.c:563:55: warning: variable 'rc' may be uninitialized when used here [-Wconditional-uninitialized]
for (ext_p = h->oldgnu_header.isextended ? 1 : 0; rc == add_ok && ext_p != 0;
^~
tar-sparse.c:551:5: note: variable 'rc' is declared here
enum oldgnu_add_status rc;
^
Found by clang-16.
Signed-off-by: Andreas Mohr <and@gmx.li>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use g_ascii_isspace() rather than isspace().
Sync with GNU tar 01f986b921d988ae51de6c937cc374b50a8b23b0.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (tty_color_free_all_tmp): rename to tty_color_free_temp and call
g_hash_table_foreach_remove().
* (tty_color_free_all_non_tmp): rename to tty_color_free_all and call
g_hash_table_remove_all().
* (tty_color_free_all): remove.
* (tty_color_free_condition_cb): rename to tty_color_free_temp_cb and
simplify.
* (mc_skin_deinit): use changed API.
* (edit_free_syntax_rules): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This fixes "sftp: failure establishing SSH session (-5)" error that
may appear on some systems when using SFTP link feature. The error
appears even when connecting to the same host via the "ssh" command
works. Whether the error appears or not depends on the content of
~/.ssh/known_hosts file.
Problem description:
Midnight Commander uses ~/.ssh/known_hosts for two reasons. Obviously,
one reason is checking for hostkey match after the SSH handshake. The
second reason is to set preferences which host key the remote side
should send us during the SSH handshake. And this is the problematic
place.
Entries in ~/.ssh/known_hosts store host names either in plain text or
in a hashed form. libssh2 does not export host name hashes, only plain
text host names. When mc tries to find a matching entry to set hostkey
preferences, it cannot cannot reliably match the hashed host names.
Before this change, mc assumed that any entry with hashed host name
matches the connecting host and set hostkey preference to the type of
that key. In many cases, this was incorrect. For example, when the
first hashed entry in ~/.ssh/known_hosts appeared before the matching
non-hashed one, and its key type was ssh-rsa, which is disabled by
default since OpenSSH 8.8 (released 2021-09-26), then mc requested
only the ssh-rsa host key from the remote host. Since this host key is
likely disabled these days, no key was sent by the remote host and mc
reported error -5 (LIBSSH2_ERROR_KEX_FAILURE).
Solution:
In this commit, we fix the problem as follows:
1. When finding a matching known_hosts entry in order to set the
preferred hostkey method, we ignore the entries with hashed host
names. If we find no matching entry with the plain text host name,
no preference is set, resulting in the server sending us whatever
key it wants and our libssh2 supports it. Likely, that key will
match an entry with hashed host name later during the host key
check.
2. If, on the other hand, a matching plain text entry is found, we use
its type as a preference, but newly, we add other methods as a
fallback. If the matched entry has a server-supported key type, it
will be used. If it is not supported by the server (e.g. the old
ssh-rsa type), the added fallback ensures that the server sends us
some host key, which will likely match an entry with hashed host
name later during the host key check.
This solution is not ideal, but I think it's good enough. For example,
the following situation is not solved ideally (I think): The
known_hosts file contains a single entry for some server. It has a
hashed host name and key of type B. Since we ignore hashed entries,
the server can send its host key as type A, which is higher on the
preference list. To the user, it will appear as that she has never
connected to that server before. After accepting the new key, it will
be added to known_hosts and the problem disappears.
Ideal solution would IMHO be to create libssh2_knownhost_find()
function in libssh2. It would allow finding all matching entries (even
with hashed host names) in known_hosts. Midnight commander would then
use all key types of found entries as its preference.
Note: Since the code modified by this commit was inspired by code from
curl, curl has the same problem. See
https://github.com/libssh2/libssh2/issues/676#issuecomment-1741877207.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When using "Shell link", filenames with cyrillic or diacritic symbols
are displayed as chains of numbers.
The problem is due to Perl version. With Perl v5.36.0, there is no
S_ISLNK in POSIX.pm. With Perl v5.38.0, there is S_ISLNK in POSIX.pm,
so S_IMODE and S_IFMT are not imported from Fcntl due to condition
unless defined &S_ISLNK.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Does anybody know any implementation of FISH server?
Should we keep the compatibility with unimplemented server?
Let's forget about the compatibility with FISH command formats. Let's
just send shell scripts with arguments that are convenient for us to the
remote host and get results of script work. The part of FISH protocol
relative to remote host answers will be used as is.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(copy_file_file): always set the destination file timestamps to the
source file ones at the end of copy operation regardless of destination
file is complete or not.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The bug was introduced in 00f84fbf24.
* (dview_load_options): avoid NULL dereference: don't caclulate the
width of line numbers field here because dview->a isn't created yet.
* (dview_update): caclulate the width of line numbers field using an
actual length of diff lines array.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* tar.c: add typeflag values for regular file.
* (tar_skip_member): set data offset here (and for regular file only)...
* (tar_insert_entry): ...not here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
...to avoid following error:
comparison of unsigned expression < 0 is always false [-Werror=type-limits]
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (sftpfs_op_init): make public and use it...
* (sftpfs_opendir): here,
* (sftpfs_mkdir): here,
* (sftpfs_rmdir): and here.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>