* (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>
(erase_dir_after_copy): don't call g_queue_is_empty() if erase_list is NULL.
erase_list is NULL in case of move an empty directory across filesystems.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* m4.include/ax_path_lib_pcre.m4: replace by recent version from GNU
Autoconf Archive.
* m4.include/ax_check_pcre2.m4: get grom GNU Autoconf Archive.
* m4.include/mc-check-search-type.m4: support both PCRE versions.
* */*/Makefile.am: remove @CHECK_CFLAGS@ and @PCRE_LIBS@ ads they are
added via AX_PATH_LIB_PCRE and AX_CHECK_PCRE2.
* lib/search.h, lib/search/: add support of PCRE2. Thanks broly <gagan@hotmail.com>
for the initial patch.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Create UI to show confirmation dialog in case of foreground operation
regardless of ENABLE_BACKGROUND.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (simple_status_msg_init_cb): pass NULL instead of "" to label_new()
to get rid of an empty string duplication.
* (advanced_chown_dlg_create): likewise.
* (chown_dlg_create): likewise.
* (dirsize_status_init_cb): likewise.
* (file_op_context_create_ui): likewise.
* (setup_gui): likewise.
* (init_hotlist): likewise.
* (init_learn): likewise.
* (file_progress_show_source): pass NULL instead of "" to
label_set_text() to get rid of an empty string duplication.
* (file_progress_show_target): likewise.
* (create_file_manager): pass NULL instead of 0 to label_new().
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Sync with GNU tar b8feb2b14247d76200fd53607d3613c82b6e5b81.
Access header->buffer + offsetof (struct posix_header, magic), instead
of header->header.magic, when reading or writing the OLDGNU_MAGIC
pattern. The code violates the C standard without this change, and GCC
warns about this if fortify checking is enabled. It's not a bug on
traditional (i.e., non-debugging) platforms, but it does violate the C
standard so it should be fixed. Problem originally reported by John
Emil Karlson in
<http://lists.gnu.org/archive/html/bug-tar/2010-04/msg00023.html>.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Sync with GNU tar 33b63ebe94b8a2dc2cb8fb907d8b7c16591b05bc.
(struct extra_header): Removed unused structure.
(union block.extra_header): Removed unused member.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When using zsh with starship.rs prompt generator, MC sometimes fails
to show the subshell prompt. This is not deterministic. Sometimes the
prompt is shown and sometimes it isn't.
The reason is that the shell prints the prompt in multiple chunks. The
first chunk contains the "real" prompt and the second is an escape
sequence for enabling bracketed paste mode. If both chunks are read by
MC in a single invocation of read_subshell_prompt(), the prompt is
shown correctly. If, however, read_subshell_prompt() reads each chunk
in separate invocations (because the second chunk is not ready during
the first invocation), the prompt is not shown. More precisely, only
the bracketed paste mode escape sequence is shown as a prompt in MC.
This can be demonstrated with the following commands:
export SHELL=$(which zsh)
export ZDOTDIR=/tmp/zshdotdir
export STARSHIP_CONFIG=/tmp/starship-test.toml
mkdir -p "$ZDOTDIR"
echo 'eval "$(starship init zsh)"' > "$ZDOTDIR/.zshrc"
echo 'format = "XXXX: $directory$character"' > "$STARSHIP_CONFIG"
mc
In my case, the prompt is usualy shown after mc start and it
disappears after changing a directory in mc. In that case, the prompt
is read() in the following two chunks:
- 63 bytes: \xd\x1b[0m\x1b[27m\x1b[24m\x1b[J\xd\xaXXXX: \x1b[1;36mmc/.git\x1b[0m \x1b[1;32m\xe2\x9d\xaf\x1b[0m \x1b[K
- 8 bytes: \x1b[?2004h
To fix the problem, we remove clearing of the prompt string in
read_subshell_prompt(). It is sufficient that the prompt is cleared
when receiving '\n' and in feed_subshell().
Signed-off-by: Michal Sojka <michal.sojka@cvut.cz>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If start directory of find files matches to the relative ignore
directory, nothing is found.
(do_search): the start directory is the first one in the directory
stack. Do not apply ignore_dir to it.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The default margin is 72 characters, but the editor would keep 73 character
long lines without breaking them.
The visual length of strings was calculated incorrectly. The way "for" loop
was implemented, the byte length would be incremented before exiting the
loop. That would correspond to a character that doesn't fit the line.
Increment the byte length in a separate statement.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Previously, both file panels share panelization results.
Now each file panel has own panelization buffer.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
The shebang's max length is usually 128 as defined in
/usr/include/linux/binfmts.h:
#define BINPRM_BUF_SIZE 128
To get around this, '/usr/bin/env perl' in place of @PERL@ can be used, but
'/usr/bin/env perl -w' doesn't work:
/usr/bin/env: perl -w: No such file or directory
So replace "perl -w" with "use warnings" to make it work.
The man2hlp.in already has "use warnings;", so just removing '-w' is OK.
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Found via `codespell -S
po,doc,./misc/syntax,./src/vfs/extfs/helpers/README.it -L
parm,rouge,sav,ect,vie,te,dum,clen,wee,dynamc,childs,ths,fo,nin,unx,nd,iif,iterm,ser,makrs,wil`
Co-authored-by: Yury V. Zaytsev <yury@shurup.com>
Signed-off-by: Kian-Meng Ang <kianmeng@cpan.org>
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Use GString for syntax keywords to calculate keyword length at once
when syntax file is being parsed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* src/filemanager/panelize.[ch]: keep function related to the external
panelize command only. Functions related to the panelized mode of file
panel move to panel.[ch]. Clean up includes.
* rename functions:
cd_panelize_cmd -> panel_panelize_cd
panelize_change_root -> panel_panelize_change_root
panelize_absolutize_if_needed -> panel_panelize_absolutize_if_needed
panelize_save_panel -> panel_panelize_save
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(regex_command_for): execute the required action from the 'Default'
section if this action is not specified in the found section.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
zip archive can contain files outside archive root:
$ unzip -l tmp.zip
Archive: tmp.zip
Length Date Time Name
--------- ---------- ----- ----
0 2023-01-04 19:43 a
0 2023-01-04 19:43 b
0 2023-01-04 19:43 ../c
0 2023-01-04 19:43 ../../d
--------- -------
0 4 files
Enter into such archive leads to a segfault.
(extfs_find_entry_int): fix possible NULL dereference. The result of this
fix is an impossibility to enter into such archive.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Fix location of all user's syntax related stuff. Now it is the
~/.local/share/mc/syntax/ directory.
Don't use the system configuration directory (/etc/mc) as a storage
of syntax definitions.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If subshell is initializing more than 1 second - we have no subshell.
(feed_subshell): change timeout to 10 secons. I belive that is more than
enough time to run subshell.
Thanks Alexandr Zamaraev (aka Tonal) <tonal.promsoft@gmail.com> and
antonio_so <sozonnik@gmail.com> for finding out the cause of the
problem.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Directory comparision expects only file names in both panels.
In panelized panel, files named can contain paths:
| boxes.c | 43220|| 1/boxes.c | 43220|
| boxes.h | 1429 || 1/boxes.h | 1429|
| | || boxes.c | 43220|
| | || boxes.h | 1429|
Even if boxes.c and 1/boxes.c files are the same, they are marked as
different because strings "boxes.c" and "1/boxes.c" are different.
The solution: for panelized panel, ignore path and use file name only
(like output of basename(3)) for comparision.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(mc_search_t): use GString to keep original search string. Join search string
and charset to structure.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
If file name is too long, message window is wider than screen.
Truncate file name to fit it in the screen.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Ticket #2773: 'include' keyword (for command class def) have no effect
if it was defined before 'Include' keyword (for command def).
Ticket #3742: update comment in mc.ext.ini.
doc: remove mc.ext.ini format description from manual page.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (mcview_growbuf_read_until): the previous call to mcview_show_error()
invalidates sp by freeing view->ds_stdio_pipe. Reintroduce the check
that was removed in a68f2d1202 but take
sp's invalidity into account.
* (mc_pclose): add a NULL pointer check to play safe.
Signed-off-by: Michael Schuster <michael@schuster.ms>
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Most of mc uses of PERL is to embed path to the interpreter in VFS
helpers. There we can use path to perl for --host. But
`date-of-man-include.am` is the place where perl is used for --build.
On most systems both paths are expected to be /usr/bin/perl.
But on some systems paths might differ a bit. Most prominent
example is NixOS, where packages get installed into unique prefixes:
$ file /nix/store/...-perl-5.36.0/bin/perl \
/nix/store/...-perl-powerpc64-unknown-linux-gnu-5.36.0/bin/perl
/nix/store/...-perl-5.36.0/bin/perl:
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), ...
/nix/store/...-perl-powerpc64-unknown-linux-gnu-5.36.0/bin/perl:
ELF 64-bit MSB executable, 64-bit PowerPC or cisco 7500, ...
This allows running both binaries via qemu-user if needed for tests.
The change introduces PERL_FOR_BUILD (similar to autoconf's CC_FOR_BUILD
and friends) to allow passing both PERLs when needed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Use it instead of direct access to WInput's buffer.
(handle_cmdline_enter): additional minor refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* (input_get_text): never return NULL. If buffer is empty, return an
empty allocated string.
* (input_push_history): use new input_get_text.
* (find_parameters): likewise.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
When files are selected keeping the right mouse button pressed,
some files are not selected.
* Add new macros for mouse pointer location relative to file list.
* (mark_if_marking): select/unselect all files between previous
selected file and new one.
* (panel_mouse_is_on_item): return clarified value of mouse pointer location.
* (panel_mouse_callback): modify mouse drag event handling in accordance with
the mouse pointer location relatively to the file list.
Also fixes ticket #4119: "Cannot scroll panel listing upwards using mouse".
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Menu according for "Sort order" item was changed in
d19b247c6d in order to fix shotrcut
conflict. Restore it back according to user requests.
óhange accelerator for "SFTP link" from S to N.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
* configure.ac: test if "file" utility has -b option.
* (regex_check_type): don't compare file names if "file -b" is used.
Reduce variable scope. Rename variable.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Get rid of sort condition double check.
Condition
ad == bd || panels_options.mix_all_files
was checked twice: first in sort_xxx(), then in sort_name() called in
sort_xxx().
Now this condition is checked in sort_xxx() only.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Handle errors of bind(), getsockname(), and listen() calls.
Return if one of these functions fails and setup errno to indicate the
cause of the error.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Call of mc_build_filename(remote_path, ".") is pointless
because the path canonicalization is performed and trailing
"/." is removed.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(edit_load_file_from_filename): make public, use it as main function to
load file and create editor window.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
(ftpfs_init_data_socket): handle return value of
getpeername()/getsockname() and try to reconnect to FTP server
for 10 attempts in case of error.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
How to reproduce:
start mc (with fish as your shell);
resize mc window;
type any command in the command prompt, for example, "ls";
result: nothing happens;
type the same command again;
it works now, the second time.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>